Move blacklist check to after command stuff

This commit is contained in:
Isaac 2021-05-30 18:05:05 +01:00
parent 0e881b85f6
commit 2b5e4a27bb
No known key found for this signature in database
GPG Key ID: F6812DBC6719B4E3

View File

@ -74,6 +74,18 @@ module.exports = class CommandManager {
const settings = await message.guild.getSettings();
const i18n = this.client.i18n.getLocale(settings.locale);
const prefix = settings.command_prefix;
const escaped_prefix = prefix.toLowerCase().replace(/(?=\W)/g, '\\'); // (lazy) escape every character so it can be used in a RexExp
const client_mention = `<@!?${this.client.user.id}>`;
let cmd_name = message.content.match(new RegExp(`^(${escaped_prefix}|${client_mention}\\s?)(\\S+)`, 'mi')); // capture prefix and command
if (!cmd_name) return; // stop here if the message is not a command
const raw_args = message.content.replace(cmd_name[0], '').trim(); // remove the prefix and command
cmd_name = cmd_name[2].toLowerCase(); // set cmd_name to the actual command alias, effectively removing the prefix
const cmd = this.commands.find(cmd => cmd.aliases.includes(cmd_name));
if (!cmd) return;
let is_blacklisted = false;
if (settings.blacklist?.includes(message.author.id)) {
@ -96,19 +108,6 @@ module.exports = class CommandManager {
}
}
const prefix = settings.command_prefix;
const escaped_prefix = prefix.toLowerCase().replace(/(?=\W)/g, '\\'); // (lazy) escape every character so it can be used in a RexExp
const client_mention = `<@!?${this.client.user.id}>`;
let cmd_name = message.content.match(new RegExp(`^(${escaped_prefix}|${client_mention}\\s?)(\\S+)`, 'mi')); // capture prefix and command
if (!cmd_name) return; // stop here if the message is not a command
const raw_args = message.content.replace(cmd_name[0], '').trim(); // remove the prefix and command
cmd_name = cmd_name[2].toLowerCase(); // set cmd_name to the actual command alias, effectively removing the prefix
const cmd = this.commands.find(cmd => cmd.aliases.includes(cmd_name));
if (!cmd) return;
const bot_permissions = message.guild.me.permissionsIn(message.channel);
const required_bot_permissions = [
'ADD_REACTIONS',