This snippet automatically removes your bot from a banned guild when invited. It also sends a dm to the owner of the guild informing them of the bot's removal.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const { event: { id: guild, owner_id , name } } = context.params;
const bannedGuilds = [
'',
'', // Add the guild id's you don't want your bot being invited to.
];
const guildDestroy = lib.discord.users['@0.2.0'].me.guilds.destroy({ guild_id: guild });
if (bannedGuilds.includes(guild)) {
await guildDestroy;
console.log(`Banned guild left: ${name}`);
try {
await lib.discord.users['@0.2.1'].dms.create({ recipient_id: owner_id,
content: `Your guild has been banned from inviting me.`,
});
console.log(`DM to the server owner was sent.`);
} catch (e) {
console.log(`DM to the server owner failed.`);
}
}