From e89cc4641380ba390a61a7705232951f809a475b Mon Sep 17 00:00:00 2001 From: ScriptSorcerer20 Date: Tue, 28 Jan 2025 22:40:05 +0100 Subject: [PATCH] added kick command --- commands/moderation/kick.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 commands/moderation/kick.js diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js new file mode 100644 index 0000000..00d19e8 --- /dev/null +++ b/commands/moderation/kick.js @@ -0,0 +1,34 @@ +const { SlashCommandBuilder } = require("discord.js"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("kick") + .setDescription("Kick misbehaving people") + .addUserOption(option => + option + .setName('target') + .setDescription('The member to kick') + .setRequired(true)) + .addStringOption(option => + option + .setName('reason') + .setDescription('The reason of the kick')), + async execute(interaction) { + const user = interaction.options.getUser('target'); + const reason = interaction.options.getString('reason') || 'No reason provided'; + + try { + const member = await interaction.guild.members.fetch(user.id); + + await member.kick(reason); + + await interaction.reply(`Kicked ${user.tag} for: ${reason}`); + } catch (error) { + console.error(error); + await interaction.reply({ + content: 'I was not able to kick the user..', + ephemeral: true, + }); + } + }, +};