This command allows members with the BAN_MEMBERS command to unban previously banned users using their ID. The command also mentions the unbanned user so you can send them a new invite to your server if you want. To set up go to the Slash Command Builder and make a new unban command with a required user option, then you can use the command like this: /unban USER_ID. IF YOU NEED HELP SETTING UP, you can ping @Zeno in the Autocode Discord for support. Hope you enjoy!
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
// Using Node.js 14.x +
// use "lib" package from npm
let userId = context.params.event.data.options[0].value;
let isBAN_MEMBERS =
(context.params.event.member.permissions & (1 << 2)) === 1 << 2;
if (isBAN_MEMBERS) {
// make API request
let result = await lib.discord.guilds['@0.1.0'].bans.destroy({
user_id: `${userId}`, // required
guild_id: `${context.params.event.guild_id}`,
});
await lib.discord.channels['@0.1.1'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `**<@${context.params.event.member.user.id}> - has unbanned <@${userId}> - ID: ${userId}**`,
});
} 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 BAN_MEMBERS permission to use the Unban command**`,
});
}