From 468d54bb6303eec778e3cd0c2d164bae3ff53833 Mon Sep 17 00:00:00 2001 From: naseif Date: Mon, 30 Aug 2021 09:44:26 +0000 Subject: [PATCH] [Fix] Added permission check for deleteMessages command. (Only members with MANAGE_MESSAGES permission flag) --- commands/admin/deleteMessages.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/commands/admin/deleteMessages.js b/commands/admin/deleteMessages.js index 7f52577..ca919ef 100644 --- a/commands/admin/deleteMessages.js +++ b/commands/admin/deleteMessages.js @@ -1,4 +1,6 @@ const { SlashCommandBuilder } = require("@discordjs/builders"); +const { Permissions } = require("discord.js"); +const { embedMessage } = require("../../modules/embedSimple"); module.exports = { data: new SlashCommandBuilder() @@ -11,6 +13,18 @@ module.exports = { const integer = interaction.options.getInteger("int"); await interaction.deferReply(); + if ( + !interaction.member.permissions.has([Permissions.FLAGS.MANAGE_MESSAGES]) + ) + return await interaction.followUp({ + embeds: [ + embedMessage( + "#9dcc37", + `❌ | You do not have permission to delete Messages!` + ), + ], + }); + try { const getMessages = await interaction.channel.messages.fetch({ limit: 100,