mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 08:13:09 +02:00
Move blacklist check to after command stuff
This commit is contained in:
parent
0e881b85f6
commit
2b5e4a27bb
@ -74,6 +74,18 @@ module.exports = class CommandManager {
|
|||||||
|
|
||||||
const settings = await message.guild.getSettings();
|
const settings = await message.guild.getSettings();
|
||||||
const i18n = this.client.i18n.getLocale(settings.locale);
|
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;
|
let is_blacklisted = false;
|
||||||
if (settings.blacklist?.includes(message.author.id)) {
|
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 bot_permissions = message.guild.me.permissionsIn(message.channel);
|
||||||
const required_bot_permissions = [
|
const required_bot_permissions = [
|
||||||
'ADD_REACTIONS',
|
'ADD_REACTIONS',
|
||||||
|
Loading…
Reference in New Issue
Block a user