From b046d1025ed502ded28bf8ee55768b621b3118b4 Mon Sep 17 00:00:00 2001 From: Zack Campbell Date: Wed, 19 Apr 2017 13:48:01 -0500 Subject: [PATCH] Fix prefix removal, change removal keyword to `clear` --- src/command/CommandDispatcher.ts | 4 ++-- src/command/base/SetPrefix.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/command/CommandDispatcher.ts b/src/command/CommandDispatcher.ts index 8aa69480..5343731b 100644 --- a/src/command/CommandDispatcher.ts +++ b/src/command/CommandDispatcher.ts @@ -124,8 +124,8 @@ export class CommandDispatcher let prefix: string = prefixes.find(a => message.content.trim().startsWith(a)); - if (dm && !prefix) prefix = ''; - if (!prefix && !dm) return [false, null, null, null]; + if (dm && typeof prefix === 'undefined') prefix = ''; + if (typeof prefix === 'undefined' && !dm) return [false, null, null, null]; const commandName: string = message.content.trim() .slice(prefix.length).trim() diff --git a/src/command/base/SetPrefix.ts b/src/command/base/SetPrefix.ts index d108f545..bb25630b 100644 --- a/src/command/base/SetPrefix.ts +++ b/src/command/base/SetPrefix.ts @@ -11,7 +11,7 @@ export default class extends Command description: 'Set or check the bot command prefix for this guild', aliases: ['prefix'], usage: 'setprefix [prefix]', - extraHelp: 'Prefixes may be 1-10 characters in length and may not include backslashes or backticks. Set the prefix to "noprefix" to allow commands to be called without a prefix.', + extraHelp: 'Prefixes may be 1-10 characters in length and may not include backslashes or backticks. Use "clear" to clear the prefix and allow commands to be called without a prefix.', callerPermissions: ['ADMINISTRATOR'] }); } @@ -29,13 +29,13 @@ export default class extends Command if (/[\\`]/.test(prefix)) return this.respond(message, `Prefixes may not contain backticks or backslashes.`); - if (prefix === 'noprefix') prefix = ''; + if (prefix === 'clear') prefix = ''; if (this.client.selfbot) for (const guild of this.client.storage.guilds.values()) await guild.settings.set('prefix', prefix); - else await message.guild.storage.settings.set('prefix', prefix); + this.respond(message, prefix === '' ? 'Command prefix removed.' : `Command prefix set to \`${prefix}\``); }