mod commands: update mod commands to use the PermissionFlagsBits rather than specifying manually

This commit is contained in:
Ayden Jahola 2024-09-26 10:36:29 +01:00
parent afd2c9f6a4
commit c06a7cd73e
No known key found for this signature in database
GPG key ID: 71DD90AE4AE92742
3 changed files with 20 additions and 6 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,