Skip to content

Commit

Permalink
Fix prefix removal, change removal keyword to clear
Browse files Browse the repository at this point in the history
  • Loading branch information
zajrik committed Apr 19, 2017
1 parent 977e463 commit b046d10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/command/CommandDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export class CommandDispatcher<T extends Client>

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()
Expand Down
6 changes: 3 additions & 3 deletions src/command/base/SetPrefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class extends Command<Client>
description: 'Set or check the bot command prefix for this guild',
aliases: ['prefix'],
usage: '<prefix>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']
});
}
Expand All @@ -29,13 +29,13 @@ export default class extends Command<Client>
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}\``);
}
Expand Down

0 comments on commit b046d10

Please sign in to comment.