From b151f04c485ac7d5ddc636b35926ef7647085b1a Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sat, 6 Jan 2024 20:49:12 +1100 Subject: [PATCH] Refactor CmdModule.ts --- src/modules/CmdModule.ts | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/modules/CmdModule.ts b/src/modules/CmdModule.ts index f2a0119..6a5f290 100644 --- a/src/modules/CmdModule.ts +++ b/src/modules/CmdModule.ts @@ -7,22 +7,20 @@ export default class CmdTrigger { return message.content.toLowerCase().startsWith(this.prefix+trigger) } static registerCmds(client:TClient, message:Message, trigger:string) { - if (this.SenseTrigger(message, trigger) && client.config.whitelist.includes(message.author.id)) { - (client.guilds.cache.get(message.guildId) as Guild).commands.set(client.registry) - .then(()=>message.reply('Deployed the slash commands successfully!')) - .catch(e=>message.reply(`Failed to deploy slash commands:\n\`\`\`${e.message}\`\`\``)); - } + if (!this.SenseTrigger(message, trigger) ?? !client.config.whitelist.includes(message.author.id)) return; + (client.guilds.cache.get(message.guildId) as Guild).commands.set(client.registry) + .then(()=>message.reply('Deployed the slash commands successfully!')) + .catch(e=>message.reply(`Failed to deploy slash commands:\n\`\`\`${e.message}\`\`\``)); } static MFPwTrigger(message:Message, trigger:string) { - if (this.SenseTrigger(message, trigger)) { - let passwordText = 'The farm password is '; - const mapping = { - '1149138133514981386': 'koops', - '1149138202662293555': 'junkers' - } - for (const [channelId, farmPw] of Object.entries(mapping)) { - if (message.channelId === channelId) message.reply(passwordText += `\`${farmPw}\``); - } + if (!this.SenseTrigger(message, trigger)) return; + let passwordText = 'The farm password is '; + const mapping = { + '1149138133514981386': 'koops', + '1149138202662293555': 'junkers' + } + for (const [channelId, farmPw] of Object.entries(mapping)) { + if (message.channelId === channelId) message.reply(passwordText += `\`${farmPw}\``); } } }