diff --git a/public/scripts/slash-commands/SlashCommand.js b/public/scripts/slash-commands/SlashCommand.js index a00b77498..6457f99c1 100644 --- a/public/scripts/slash-commands/SlashCommand.js +++ b/public/scripts/slash-commands/SlashCommand.js @@ -5,4 +5,17 @@ export class SlashCommand { /**@type {Boolean}*/ interruptsGeneration; /**@type {Boolean}*/ purgeFromMessage; /**@type {String[]}*/ aliases; + + get helpStringFormatted() { + let aliases = ''; + if (this.aliases?.length > 0) { + aliases = ' (alias: '; + aliases += this.aliases + .map(it=>`/${it}`) + .join(', ') + ; + aliases += ')'; + } + return `/${this.name}${this.helpString}${aliases}`; + } } diff --git a/public/scripts/slash-commands/SlashCommandParser.js b/public/scripts/slash-commands/SlashCommandParser.js index dcccfb7fd..4db7958ef 100644 --- a/public/scripts/slash-commands/SlashCommandParser.js +++ b/public/scripts/slash-commands/SlashCommandParser.js @@ -154,9 +154,11 @@ export class SlashCommandParser { getHelpString() { const listItems = Object - .entries(this.helpStrings) - .sort((a, b) => a[0].localeCompare(b[0])) - .map(x => x[1]) + .keys(this.commands) + .filter(key=>this.commands[key].name == key) + .map(key=>this.commands[key]) + .sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())) + .map(x => x.helpStringFormatted) .map(x => `
  • ${x}
  • `) .join('\n'); return `

    Slash commands:

      ${listItems}