From 81386d22d4bc0aec817b7b9fcb47132913385e9f Mon Sep 17 00:00:00 2001 From: Sachin Prasanth <142246653+SachinPrasanth777@users.noreply.github.com> Date: Sun, 10 Mar 2024 11:38:53 +0530 Subject: [PATCH] refactor: refactor isMod (#76) --- src/events/interactionCreate.ts | 37 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts index 8418266..781def3 100644 --- a/src/events/interactionCreate.ts +++ b/src/events/interactionCreate.ts @@ -15,26 +15,25 @@ export default { await interaction.reply({ content: "Command not found", ephemeral: true }); return; } - if (command.isMod) { - const interactionChannelId = interaction.channelId; - const envChannelId = env.MOD_CHANNEL_ID; - if (interactionChannelId !== envChannelId) { - await interaction.reply({ - content: "This command can only be executed in a specific channel.", - ephemeral: true, - }); - return; - } - try { - command.execute(interaction); - } catch (err) { - console.error(err); - await interaction.reply({ - content: "There was an error while executing this command!", - ephemeral: true, - }); - } + const interactionChannelId = interaction.channelId; + const envChannelId = env.MOD_CHANNEL_ID; + if (command.isMod && interactionChannelId !== envChannelId) { + await interaction.reply({ + content: "This command can only be executed in a specific channel.", + ephemeral: true, + }); + return; + } + + try { + command.execute(interaction); + } catch (err) { + console.error(err); + await interaction.reply({ + content: "There was an error while executing this command!", + ephemeral: true, + }); } }, };