This snippet allows users with the ADMINISTRATOR permission to delete a given channel in a server. To set up just go to the Slash Command Builder and make a /deletechannel command with a channel option, then you can use the command like this: /deletechannel CHANNEL. IF YOU NEED HELP SETTING UP, you can ping @Zeno in the Autocode Discord for support. Hope you enjoy!
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let isADMINISTRATOR =
(context.params.event.member.permissions & (1 << 3)) === 1 << 3;
if (isADMINISTRATOR) {
let channel = context.params.event.data.options[0].value;
let result = await lib.discord.channels['@0.2.1'].destroy({
channel_id: `${channel}`, // required
});
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `**<@${context.params.event.member.user.id}> - channel successfully deleted!**`,
});
} else {
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `**<@${context.params.event.member.user.id}> - You need the ADMINISTRATOR permission to use the Delete Channel command**`,
});
}