From 0727e16ba5fd5b95fed3ac9dd4a47023b1c2e2ff Mon Sep 17 00:00:00 2001 From: Taken Date: Sun, 1 Oct 2023 19:08:59 +0200 Subject: [PATCH] Adding waiting list remove command --- commands/remove.js | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 commands/remove.js diff --git a/commands/remove.js b/commands/remove.js new file mode 100644 index 0000000..6e8aecb --- /dev/null +++ b/commands/remove.js @@ -0,0 +1,54 @@ +const { SlashCommandBuilder, PermissionFlagsBits, userMention } = require('discord.js'); +const { color } = require('../config/options.json'); +const { waitinglistSchema } = require("../schemas/waitinglistSchema.js") + +module.exports = { + name: 'remove', + description: 'Remove a person on the waiting list.', + + data: new SlashCommandBuilder() + .setName('remove') + .setDescription('Remove a person on the waiting list.') + .addUserOption(option => + option + .setName('user') + .setDescription('The user to remove.') + .setRequired(true) + ) + .addStringOption(option => + option + .setName('reason') + .setDescription('The reason for removing the user.') + .setRequired(false) + ) + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .setDMPermission(false), + + async execute(interaction) { + const user = interaction.options.getUser('user'); + const reason = interaction.options.getString('reason') || "No reason provided." + const mod = interaction.user + const color = Number(color.replace('#', '0x')) + + const waitinglist = await waitinglistSchema.findOne({ UserID: user.id }) + + if (!waitinglist) { + await interaction.reply({ + embeds: [{ + description: userMention(user.id) + " is not on the waiting list.", + color: color + }] + }) + return + } + + await waitinglistSchema.findOneAndDelete({ UserID: user.id }) + + await interaction.reply({ + embeds: [{ + description: userMention(user.id) + " has been removed from the waiting list.", + color: color + }] + }) + } +}