Skip to content

Commit

Permalink
refactor: refactor isMod (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
SachinPrasanth777 authored Mar 10, 2024
1 parent 1b95ae9 commit 81386d2
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/events/interactionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
},
};

0 comments on commit 81386d2

Please sign in to comment.