nodbot/_list-guilds.js
Skylar Grant efcf613ea4
Some checks failed
NodBot PE Dockerization / build (push) Has been cancelled
.
2025-01-31 19:30:39 -05:00

38 lines
1.0 KiB
JavaScript

/*
* Quick and dirty script to list out what guilds the bot is in and optionally leave some.
*/
const guildsToLeave = ['1224396616555823124'];
const dotenv = require('dotenv').config();
const token = process.env.TOKEN;
const Discord = require('discord.js');
const client = new Discord.Client({
intents: [
'GUILDS'
]
});
client.on('ready', async () => {
const guildChecks = [];
console.log(`Logged in as ${client.user.tag}`);
console.log('Guilds:');
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 ${guild.name}`);
guild.leave().then(resolve).catch(reject);
} else {
resolve();
}
});
guildChecks.push(p);
});
await Promise.all(guildChecks);
console.log('All guilds checked.');
client.destroy();
});
client.login(token);