diff --git a/src/commands/ban.ts b/src/commands/ban.ts index 08140f4d..c113fd51 100644 --- a/src/commands/ban.ts +++ b/src/commands/ban.ts @@ -7,17 +7,15 @@ export default { .addUserOption((option) => option.setName('user').setDescription('User to ban').setRequired(true)) .addStringOption((option) => option.setName('reason').setDescription('Reason for banning the user').setRequired(false), - ), + ) + .setDMPermission(false), run: async (interaction: ChatInputCommandInteraction) => { // Typeguard in order to ensure having access to ChatInputCommand interaction options. if (!interaction.isChatInputCommand()) return; - if (interaction.inGuild() === false) { - return interaction.reply({ content: "❌ I can't execute this command inside DMs!", ephemeral: true }); - } if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.BanMembers)) { return interaction.reply({ - content: '❌ Sorry, I need the `Ban Members` permission n order to execute this command.', + content: '❌ Sorry, I need the `Ban Members` permission in order to execute this command.', ephemeral: true, }); } diff --git a/src/commands/kick.ts b/src/commands/kick.ts index e4062be1..17f7a358 100644 --- a/src/commands/kick.ts +++ b/src/commands/kick.ts @@ -7,14 +7,12 @@ export default { .addUserOption((option) => option.setName('user').setDescription('User to kick').setRequired(true)) .addStringOption((option) => option.setName('reason').setDescription('Reason for kicking the user').setRequired(false), - ), + ) + .setDMPermission(false), run: async (interaction: ChatInputCommandInteraction) => { // Typeguard in order to ensure having access to ChatInputCommand interaction options. if (!interaction.isChatInputCommand()) return; - if (interaction.inGuild() === false) { - return interaction.reply({ content: "❌ I can't execute this command inside DMs!", ephemeral: true }); - } if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.KickMembers)) { return interaction.reply({ content: '❌ Sorry, I need the `Kick Members` in order to execute this command.', diff --git a/src/commands/prune.ts b/src/commands/prune.ts index f76cbb04..c68a6e10 100644 --- a/src/commands/prune.ts +++ b/src/commands/prune.ts @@ -12,14 +12,12 @@ export default { .setDescription('Deletes up to 100 messages.') .addIntegerOption((option) => option.setName('amount').setDescription('Amount of messages to delete').setRequired(true), - ), + ) + .setDMPermission(false), run: async (interaction: ChatInputCommandInteraction) => { // Typeguard in order to ensure having access to ChatInputCommand interaction options. if (!interaction.isChatInputCommand()) return; - if (interaction.inGuild() === false) { - return interaction.reply({ content: "❌ I can't execute this command inside DMs!", ephemeral: true }); - } if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.ManageMessages)) { return interaction.reply({ content: '❌ Sorry, I need the `Manage Messages` permission in order to execute this command.', diff --git a/src/commands/role-info.ts b/src/commands/role-info.ts index c2fee3b5..0bf500d1 100644 --- a/src/commands/role-info.ts +++ b/src/commands/role-info.ts @@ -16,14 +16,12 @@ export default { .setName('show_permissions') .setDescription("Whether to show the role's permissions") .setRequired(false), - ), + ) + .setDMPermission(false), run: async (interaction: ChatInputCommandInteraction) => { // Typeguard in order to ensure having access to ChatInputCommand interaction options. if (!interaction.isChatInputCommand()) return; - if (interaction.inGuild() === false) { - return interaction.reply({ content: "❌ I can't execute this command inside DMs!", ephemeral: true }); - } const apiRole = interaction.options.getRole('role', true); const role: Role = interaction.guild.roles.cache.get(apiRole.id); diff --git a/src/commands/server.ts b/src/commands/server.ts index 645952ce..ba1fb2d8 100644 --- a/src/commands/server.ts +++ b/src/commands/server.ts @@ -7,14 +7,12 @@ export default { .setDescription('Displays info about your server') .addBooleanOption((option) => option.setName('show_roles').setDescription("Whether to show the server's roles").setRequired(false), - ), + ) + .setDMPermission(false), run: async (interaction: ChatInputCommandInteraction, client: Client) => { // Typeguard in order to ensure having access to ChatInputCommand interaction options. if (!interaction.isChatInputCommand()) return; - if (interaction.inGuild() === false) { - return interaction.reply({ content: "❌ I can't execute this command inside DMs!", ephemeral: true }); - } const embed = new EmbedBuilder() .setColor('Random') .setTitle(`${interaction.guild.name}`) diff --git a/src/commands/unban.ts b/src/commands/unban.ts index 76ef4543..ec43dc5b 100644 --- a/src/commands/unban.ts +++ b/src/commands/unban.ts @@ -14,14 +14,12 @@ export default { .addUserOption((option) => option.setName('user').setDescription('User to unban').setRequired(true)) .addStringOption((option) => option.setName('reason').setDescription('Reason for unbanning the user').setRequired(false), - ), + ) + .setDMPermission(false), run: async (interaction: ChatInputCommandInteraction, client: Client) => { // Typeguard in order to ensure having access to ChatInputCommand interaction options. if (!interaction.isChatInputCommand()) return; - if (interaction.inGuild() === false) { - return interaction.reply({ content: "❌ I can't execute this command inside DMs!", ephemeral: true }); - } if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.BanMembers)) { return interaction.reply({ content: '❌ Sorry, I need the `Ban Members` permission in order to execute this command.', diff --git a/src/commands/user-info.ts b/src/commands/user-info.ts index 09696b54..4dbcf6b4 100644 --- a/src/commands/user-info.ts +++ b/src/commands/user-info.ts @@ -13,14 +13,12 @@ export default { .setName('show_permissions') .setDescription("Whether to show the user's permissions") .setRequired(false), - ), + ) + .setDMPermission(false), run: async (interaction: ChatInputCommandInteraction) => { // Typeguard in order to ensure having access to ChatInputCommand interaction options. if (!interaction.isChatInputCommand()) return; - if (interaction.inGuild() === false) { - return interaction.reply({ content: "❌ I can't execute this command inside DMs!", ephemeral: true }); - } const user = interaction.options?.getUser('user') ?? interaction.user; const member = interaction.guild.members.cache.get(user.id);