autoleave non-authorized guilds

This commit is contained in:
Christopher Cookman 2023-03-11 17:07:13 -07:00
parent 5582bcc8c3
commit dba2478a9a
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
2 changed files with 11 additions and 1 deletions

View file

@ -1,7 +1,8 @@
{
"discord": {
"token": "",
"authorized_channels": [""]
"authorized_channels": [""],
"authorized_guilds": [""]
},
"openai": {
"key": "",

View file

@ -69,6 +69,15 @@ client.on("ready", () => {
console.error(error);
}
})();
// Automatically leave servers that aren't in the authorized channels list
console.log(`${colors.cyan("[INFO]")} Leaving Servers...`)
client.guilds.cache.forEach((guild) => {
if (!config.discord.authorized_guilds.includes(guild.id)) {
guild.leave();
console.log(`${colors.cyan("[INFO]")} Left ${colors.green(guild.name)}`)
}
});
});
client.on('interactionCreate', async (interaction) => {