From 87497770b44f9e4084c7dae5a772c59efa4bfc31 Mon Sep 17 00:00:00 2001 From: Ibrahim Ansari Date: Wed, 21 Apr 2021 19:48:10 +0530 Subject: [PATCH] Fix /help being broken for most commands. --- server/bot/commands/help.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/server/bot/commands/help.ts b/server/bot/commands/help.ts index 05d5bcd..19373f5 100644 --- a/server/bot/commands/help.ts +++ b/server/bot/commands/help.ts @@ -68,18 +68,21 @@ TP \`/request\` - Request a specific feature. } const generateDocs = (command: Command) => { - const permissions = command.requirements.permissions - ? `Needs the permissions: ${Object.keys(command.requirements.permissions).map(perm => ( - perm.substr(0, 1).toUpperCase() + perm.substr(1) - ).replace(/[A-Z]+/g, s => ' ' + s).trim()).join(', ').replace('TTSMessages', 'TTS Messages')} | ` : '' - const roleNames = command.requirements.roleNames - ? `Needs the roles: ${command.requirements.roleNames.join(', ')} | ` : '' - const roleIDs = command.requirements.roleIDs ? 'Usable by users with a certain role | ' : '' - const userIDs = command.requirements.userIDs ? 'Usable by certain users | ' : '' - const custom = command.requirements.custom - ? '\n**Requirements:** Has some unknown permission checks | ' : '' - const requirements = custom || (permissions || roleIDs || roleNames || userIDs - ? `\n**Requirements:** ${custom}${permissions}${roleIDs}${roleNames}${userIDs}` : '') + let requirements = '' + if (command.requirements) { + const permissions = command.requirements.permissions + ? `Needs the permissions: ${Object.keys(command.requirements.permissions).map(perm => ( + perm.substr(0, 1).toUpperCase() + perm.substr(1) + ).replace(/[A-Z]+/g, s => ' ' + s).trim()).join(', ').replace('TTSMessages', 'TTS Messages')} | ` : '' + const roleNames = command.requirements.roleNames + ? `Needs the roles: ${command.requirements.roleNames.join(', ')} | ` : '' + const roleIDs = command.requirements.roleIDs ? 'Usable by users with a certain role | ' : '' + const userIDs = command.requirements.userIDs ? 'Usable by certain users | ' : '' + const custom = command.requirements.custom + ? '\n**Requirements:** Has some unknown permission checks | ' : '' + requirements = custom || (permissions || roleIDs || roleNames || userIDs + ? `\n**Requirements:** ${custom}${permissions}${roleIDs}${roleNames}${userIDs}` : '') + } if (command.aliases && command.aliases.length) { return `