mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-06 22:42:58 +02:00
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
const { PermissionsBitField} = require("discord.js")
|
|
module.exports = {
|
|
name: 'renew',
|
|
description: 'Renew un salon',
|
|
emote: '🔄',
|
|
utilisation: 'renew',
|
|
category: 'gestion',
|
|
async execute(message, args, client) {
|
|
const guild = message.guild;
|
|
const channel = message.mentions.channels.first() || message.channel;
|
|
const botMember = guild.members.cache.get(client.user.id);
|
|
// Check if the bot has the 'MANAGE_CHANNELS' permission
|
|
if (!botMember.permissions.has(PermissionsBitField.Flags.ManageChannels)) {
|
|
return message.reply("Je n'ai pas la permission de gére les salon");
|
|
}
|
|
|
|
// Check if the channel is deletable
|
|
if (channel.deletable) {
|
|
// Clone the channel
|
|
const newChannel = await channel.clone();
|
|
|
|
// Delete the old channel
|
|
await channel.delete();
|
|
|
|
// Send a message in the new channel
|
|
newChannel.send(`${message.author}, ce salon a été renouvelé.`);
|
|
} else {
|
|
return message.reply("Je ne peux pas supprimer ce salon.");
|
|
}
|
|
},
|
|
}; |