Automagically deletes and recreates a role with the same setting. This makes it easy to mass "remove" people from a role without being rate limited.
// 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 roles = await lib.discord.guilds['@0.2.2'].roles.list({
guild_id: `${context.params.event.guild_id}`,
});
let role_name = "shark haters." // Replace this with the name of the role which you want to delete/recreate
let role;
for (let i = 0; i < roles.length; i++) {
if (roles[i].name == role_name) {
role = roles[i];
break;
}
}
await lib.discord.guilds['@0.2.2'].roles.destroy({
role_id: `${role.id}`,
guild_id: `${context.params.event.guild_id}`,
});
await lib.discord.guilds['@0.2.2'].roles.create({
guild_id: `${context.params.event.guild_id}`,
name: role.name,
permissions: role.permissions,
color: role.color,
hoist: role.hoist,
mentionable: role.mentionable,
});