diff options
author | marzavec <admin@marzavec.com> | 2019-11-07 23:34:38 +0100 |
---|---|---|
committer | marzavec <admin@marzavec.com> | 2019-11-07 23:34:38 +0100 |
commit | 7b69c47f3392edff0db1464eec9c2ff541b45c68 (patch) | |
tree | 05dacb410e9e9f397e268b47ef8b375e9730a434 | |
parent | Minor bug fixes (diff) | |
download | hackchat-7b69c47f3392edff0db1464eec9c2ff541b45c68.tar.gz hackchat-7b69c47f3392edff0db1464eec9c2ff541b45c68.zip |
Updated help.js, now uses markdown
Diffstat (limited to '')
-rw-r--r-- | server/src/commands/core/help.js | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/server/src/commands/core/help.js b/server/src/commands/core/help.js index f33dd12..56fb18b 100644 --- a/server/src/commands/core/help.js +++ b/server/src/commands/core/help.js @@ -2,9 +2,6 @@ Description: Outputs the current command module list or command categories */ -// module support functions -const { stripIndents } = require('common-tags'); - // module main export async function run(core, server, socket, payload) { // check for spam @@ -22,29 +19,29 @@ export async function run(core, server, socket, payload) { let reply = ''; if (typeof payload.command === 'undefined') { - reply = stripIndents`Listing all current commands. For specific help on certain commands, use either: - Text: /help <command name> - API: {cmd: 'help', command: '<command name>'}`; - reply += '\n\n-------------------------------------\n\n'; + reply += '# All commands:\n|Category:|Name:|\n|---:|---|\n'; const categories = core.commands.categoriesList.sort(); for (let i = 0, j = categories.length; i < j; i += 1) { - reply += `${categories[i].replace('../src/commands/', '').replace(/^\w/, (c) => c.toUpperCase())} Commands:\n`; + reply += `|${categories[i].replace('../src/commands/', '').replace(/^\w/, (c) => c.toUpperCase())}:|`; const catCommands = core.commands.all(categories[i]).sort((a, b) => a.info.name.localeCompare(b.info.name)); - reply += ` ${catCommands.map((c) => `${c.info.name}`).join(', ')}\n\n`; + reply += `${catCommands.map((c) => `${c.info.name}`).join(', ')}|\n`; } + + reply += '---\nFor specific help on certain commands, use either:\nText: `/help <command name>`\nAPI: `{cmd: \'help\', command: \'<command name>\'}`'; } else { const command = core.commands.get(payload.command); if (typeof command === 'undefined') { - reply = 'Unknown command'; + reply += 'Unknown command'; } else { - reply = stripIndents`Name: ${command.info.name} - Aliases: ${typeof command.info.aliases !== 'undefined' ? command.info.aliases.join(', ') : 'None'} - Category: ${command.info.category.replace('../src/commands/', '').replace(/^\w/, (c) => c.toUpperCase())} - Required Parameters: ${command.requiredData || 'None'}\n - Description: ${command.info.description || '¯\_(ツ)_/¯'}\n - Usage: ${command.info.usage || command.info.name}`; + reply += `# ${command.info.name} command:\n| | |\n|---:|---|\n`; + reply += `|**Name:**|${command.info.name}|\n`; + reply += `|**Aliases:**|${typeof command.info.aliases !== 'undefined' ? command.info.aliases.join(', ') : 'None'}|\n`; + reply += `|**Category:**|${command.info.category.replace('../src/commands/', '').replace(/^\w/, (c) => c.toUpperCase())}|\n`; + reply += `|**Required Parameters:**|${command.requiredData || 'None'}|\n`; + reply += `|**Description:**|${command.info.description || '¯\_(ツ)_/¯'}|\n\n`; + reply += `**Usage:** ${command.info.usage || command.info.name}`; } } |