Untitled

 avatar
unknown
plain_text
2 years ago
1.6 kB
5
Indexable
const { ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder, PermissionsBitField, StringSelectMenuBuilder, StringSelectMenuOptionBuilder } = require('discord.js');

module.exports = {
	data: new SlashCommandBuilder()
    .setName('actions')
    .setDescription('Ban with confirm')
    .addUserOption(option=>option.setName('target').setDescription('User to ban'))
    .addStringOption(option=>option.setName('reason').setDescription('Reason of the ban')),
	async execute(interaction) {
    const member = interaction.options.getUser('target');
    if (member.permissions.has(PermissionsBitField.Flags.KickMembers)) {
      const reason = interaction.options.getString('reason') ?? "No reason provided";
      const select = new StringSelectMenuBuilder()
			 .setCustomId('ConfirmAct')
			 .setPlaceholder('Actions')
			 .addOptions(
				new StringSelectMenuOptionBuilder()
					.setLabel('Kick')
					.setDescription('Kick the user')
					.setValue('kick'),
        new StringSelectMenuOptionBuilder()
					.setLabel('Ban')
					.setDescription('Ban the user.')
					.setValue('ban'),
        new StringSelectMenuOptionBuilder()
					.setLabel('Timeout')
					.setDescription('Timeout the user.')
					.setValue('timeout'),
        );
      const row = new ActionRowBuilder()
			.addComponents(select);
		await interaction.reply({
			content: `Actions for the user: ${user}, selected reason: ${reason}`,
      ephemeral: true,
			components: [row],
		});
    } else {
      await interaction.reply({content: `You don't have the required permission to run this command!`, ephemeral: true});
    }
	},
};
Editor is loading...