This snippet allows you to delete a role in a server. All you have to do to set this up is go to the Slash Command Builder, and make a required role option. Then you can use the command like this /deleterole ROLE. IF YOU NEED HELP SETTING UP, you can ping @Zeno in the Autocode Discord for support. Hope you enjoy!
// Using Node.js 14.x +
// use "lib" package from npm
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let isADMINISTRATOR =
(context.params.event.member.permissions & (1 << 3)) === 1 << 3;
if (isADMINISTRATOR) {
// make API request
let role = context.params.event.data.options[0].value;
let result = await lib.discord.guilds['@0.1.0'].roles.destroy({
role_id: `${role}`,
guild_id: `${context.params.event.guild_id}`, // required
});
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `**<@${context.params.event.member.user.id}> - role 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 Role command**`,
});
}