Add help slash command

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2019-07-29 17:58:34 +01:00
parent 7f2fdd4315
commit d2e2c4edb6
2 changed files with 36 additions and 0 deletions

View File

@ -809,6 +809,38 @@ export const CommandMap = {
return success(MatrixClientPeg.get().sendHtmlEmote(roomId, args, textToHtmlRainbow(args)));
},
}),
help: new Command({
name: "help",
description: _td("Displays list of commands with usages and descriptions"),
runFn: function() {
const InfoDialog = sdk.getComponent('dialogs.InfoDialog');
Modal.createTrackedDialog('Slash Commands', 'Help', InfoDialog, {
title: _t("Command Help"),
description: <table>
<thead>
<tr>
<td>{_t("Command")}</td>
<td>{_t("Arguments")}</td>
<td>{_t("Description")}</td>
</tr>
</thead>
<tbody>
{
Object.values(CommandMap).map(cmd => {
return <tr key={cmd.command}>
<td>{cmd.command}</td>
<td>{cmd.args}</td>
<td>{cmd.description}</td>
</tr>;
})
}
</tbody>
</table>,
});
return success();
},
}),
};
/* eslint-enable babel/no-invalid-this */

View File

@ -182,6 +182,10 @@
"Forces the current outbound group session in an encrypted room to be discarded": "Forces the current outbound group session in an encrypted room to be discarded",
"Sends the given message coloured as a rainbow": "Sends the given message coloured as a rainbow",
"Sends the given emote coloured as a rainbow": "Sends the given emote coloured as a rainbow",
"Displays list of commands with usages and descriptions": "Displays list of commands with usages and descriptions",
"Command Help": "Command Help",
"Command": "Command",
"Arguments": "Arguments",
"Unrecognised command:": "Unrecognised command:",
"Reason": "Reason",
"%(targetName)s accepted the invitation for %(displayName)s.": "%(targetName)s accepted the invitation for %(displayName)s.",