From dba2478a9a129ab3e1ca07e9cde8899fa8fb9343 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sat, 11 Mar 2023 17:07:13 -0700 Subject: [PATCH] autoleave non-authorized guilds --- config.json.default | 3 ++- index.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config.json.default b/config.json.default index 36b5f19..37cb5d4 100644 --- a/config.json.default +++ b/config.json.default @@ -1,7 +1,8 @@ { "discord": { "token": "", - "authorized_channels": [""] + "authorized_channels": [""], + "authorized_guilds": [""] }, "openai": { "key": "", diff --git a/index.js b/index.js index 5b388ff..0bd5186 100644 --- a/index.js +++ b/index.js @@ -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) => {