From c06a7cd73e4c0153931e942312a68975c2d6fa23 Mon Sep 17 00:00:00 2001 From: Ayden Jahola Date: Thu, 26 Sep 2024 10:36:29 +0100 Subject: [PATCH] mod commands: update mod commands to use the PermissionFlagsBits rather than specifying manually --- commands/moderation/clearLeaderboard.js | 6 ++++-- commands/moderation/kick.js | 10 ++++++++-- commands/moderation/purge.js | 10 ++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/commands/moderation/clearLeaderboard.js b/commands/moderation/clearLeaderboard.js index 7251f1c..b38fb64 100644 --- a/commands/moderation/clearLeaderboard.js +++ b/commands/moderation/clearLeaderboard.js @@ -1,4 +1,4 @@ -const { SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); const Leaderboard = require("../../models/Leaderboard"); module.exports = { @@ -10,7 +10,9 @@ module.exports = { async execute(interaction) { try { // Check if the user has the Manage Server permission - if (!interaction.member.permissions.has("ManageGuild")) { + if ( + !interaction.member.permissions.has(PermissionFlagsBits.ManageGuild) + ) { await interaction.reply({ content: "You do not have permission to use this command!", ephemeral: true, diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 7a5f0f2..128e817 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -1,4 +1,8 @@ -const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); +const { + SlashCommandBuilder, + EmbedBuilder, + PermissionFlagsBits, +} = require("discord.js"); const KickedUser = require("../../models/KickedUser"); module.exports = { @@ -22,7 +26,9 @@ module.exports = { async execute(interaction) { try { // Check if the user has the Kick Members permission - if (!interaction.member.permissions.has("KickMembers")) { + if ( + !interaction.member.permissions.has(PermissionFlagsBits.KickMembers) + ) { await interaction.reply({ content: "You do not have permission to use this command!", ephemeral: true, diff --git a/commands/moderation/purge.js b/commands/moderation/purge.js index 1b20467..6a547f1 100644 --- a/commands/moderation/purge.js +++ b/commands/moderation/purge.js @@ -1,4 +1,8 @@ -const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); +const { + SlashCommandBuilder, + EmbedBuilder, + PermissionFlagsBits, +} = require("discord.js"); module.exports = { data: new SlashCommandBuilder() @@ -27,7 +31,9 @@ module.exports = { async execute(interaction) { try { // Check if the user has the Manage Messages permission - if (!interaction.member.permissions.has("ManageMessages")) { + if ( + !interaction.member.permissions.has(PermissionFlagsBits.ManageMessages) + ) { await interaction.reply({ content: "You do not have permission to use this command!", ephemeral: true,