From efcf613ea4f08619fd0e3b8736e70f018ee60a75 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 31 Jan 2025 19:30:39 -0500 Subject: [PATCH] . --- _list-guilds.js | 1 - config.json | 3 ++- functions.js | 22 ++++++++++++++++++++++ main.js | 3 +++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/_list-guilds.js b/_list-guilds.js index 70edcba..0829c91 100644 --- a/_list-guilds.js +++ b/_list-guilds.js @@ -30,7 +30,6 @@ client.on('ready', async () => { }); guildChecks.push(p); }); - console.log('Done.'); await Promise.all(guildChecks); console.log('All guilds checked.'); client.destroy(); diff --git a/config.json b/config.json index 488a934..9a73f7e 100644 --- a/config.json +++ b/config.json @@ -3,5 +3,6 @@ "validCommands": [], "roaches": [], "icaoIds": [], - "datisICAOs": [] + "datisICAOs": [], + "bannedServers": ["1224396616555823124"] } \ No newline at end of file diff --git a/functions.js b/functions.js index 01466b5..9fdfd11 100644 --- a/functions.js +++ b/functions.js @@ -671,6 +671,28 @@ const functions = { }); }); }, + checkBannedServers(client) { + if ( !config.bannedServers ) return; + const guildChecks = []; + console.log('Guild Check:'); + client.guilds.cache.forEach((guild) => { + const p = new Promise((resolve, reject) => { + console.log(` - ${guild.name} (${guild.id})`); + if (guildsToLeave.includes(guild.id)) { + console.log(` Leaving banned server: ${guild.name}`); + guild.leave().then(resolve).catch(reject); + } else { + resolve(); + } + }); + guildChecks.push(p); + }); + Promise.all(guildChecks).then(() => { + console.log('All guilds checked.'); + }).catch((err) => { + console.error(err); + }); + }, autoresponses: { // Specific responses for certain keywords in sent messages checkForAll(messageContent) { let responses = []; diff --git a/main.js b/main.js index 0d0e695..9a227cf 100644 --- a/main.js +++ b/main.js @@ -51,6 +51,8 @@ client.once('ready', async () => { // console.log(JSON.stringify(icaoArray)); statusChannel = await client.channels.fetch(statusChannelId).catch(e => console.error(e)); await statusChannel.send(`${new Date().toISOString()} -- <@${process.env.ownerId}>\nStartup Sequence Complete`).catch(e => console.error(e)); + // Check for banned servers + fn.checkBannedServers(client); }); // slash-commands @@ -150,6 +152,7 @@ client.on('messageCreate', message => { client.on('guildCreate', guild => { statusChannel.send(`I've been added to a new guild: ${guild.name} (${guild.id})`) .catch(e => console.error(e)); + fn.checkBannedServers(client); }); client.on('guildDelete', guild => {