JaBa/commands/Tickets/removeuser.js

35 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-07-07 17:34:23 +05:00
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('removeuser')
.setDescription('Remove a user from a ticket')
.addMentionableOption(option =>
option.setName('user')
.setDescription('The user to remove')
.setRequired(true))
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
async execute(interaction) {
try {
const user = interaction.options.getMentionable('user');
const currentChannel = interaction.channel;
if (currentChannel) {
if (!interaction.channel.name.includes('support') && !interaction.channel.name.includes('application')) {
interaction.reply('This command can only be used in a ticket channel.');
return;
}
const member = await interaction.guild.members.fetch(user.id);
await interaction.channel.permissionOverwrites.edit(member, { ViewChannel: false });
interaction.reply(`Removed ${user} to the ticket.`);
}
else {
interaction.reply('This channel is not a ticket.');
}
}
catch (error) {
console.log(error);
interaction.reply('Error adding user to ticket.');
}
},
};