This snippet will make your bot leave a given server, the command format is !leave [GUILD ID] then the bot will leave!
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
//The Guild the bot is leaving
//Your bot needs to be in the guild for any of this to work
let guild = context.params.event.content.split(' ')[1];
//Retrieves the Guild you provided and then gets info about it like name, id, etc
let retrieve = await lib.discord.guilds['@0.1.1'].retrieve({
guild_id: `${guild}`,
});
//This checks if you provided a Guild ID to leave
if (!guild) {
await lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `You need to give me a Guild ID to leave!`,
message_reference: {message_id: `${context.params.event.id}`},
});
} else {
//This is the part that leaves the Guild, itu ses the me.guilds.destory API
await lib.discord.users['@0.2.0'].me.guilds.destroy({
guild_id: `${guild}`,
});
await lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `I've left \`${retrieve.name}\``,
});
}
//Just do !leave [SERVER ID] and bam, bot leaves
//This can also be used to leave servers that you're not in