mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 13:53:12 +02:00
Remove Guild Pruning
This commit is contained in:
+1
-3
@@ -11,9 +11,7 @@ const client = new CommandoClient({
|
||||
messageCacheLifetime: 600,
|
||||
messageSweepInterval: 120,
|
||||
dBotsToken: DBOTS_KEY,
|
||||
dBotsOrgToken: DBOTSORG_KEY,
|
||||
guildWhitelist: ['110373943822540800', '264445053596991498'],
|
||||
guildPruneLevel: 25
|
||||
dBotsOrgToken: DBOTSORG_KEY
|
||||
});
|
||||
|
||||
client.registry
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
const { Client } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { Collection } = require('discord.js');
|
||||
|
||||
class CommandoClient extends Client {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
if (typeof this.options.guildPruneLevel === 'undefined') this.options.guildPruneLevel = Infinity;
|
||||
if (typeof this.options.guildWhitelist === 'undefined') this.options.guildWhitelist = [];
|
||||
Object.defineProperty(this, 'dBotsToken', { value: options.dBotsToken });
|
||||
Object.defineProperty(this, 'dBotsOrgToken', { value: options.dBotsOrgToken });
|
||||
|
||||
this.on('guildCreate', guild => {
|
||||
this.pruneGuilds(guild);
|
||||
this.on('guildCreate', () => {
|
||||
this.dBots();
|
||||
this.dBotsOrg();
|
||||
});
|
||||
@@ -20,7 +16,6 @@ class CommandoClient extends Client {
|
||||
this.dBots();
|
||||
this.dBotsOrg();
|
||||
});
|
||||
this.setInterval(() => this.pruneGuilds(), 600000);
|
||||
}
|
||||
|
||||
async dBots() {
|
||||
@@ -58,34 +53,6 @@ class CommandoClient extends Client {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async pruneGuilds(guild) {
|
||||
let guilds = new Collection();
|
||||
if (typeof guild === 'undefined') {
|
||||
for (const g of this.guilds.values()) {
|
||||
if (this.options.guildWhitelist.includes(g.id)) continue;
|
||||
if (g.members.filter(member => member.user.bot).size > this.options.guildPruneLevel) {
|
||||
try {
|
||||
guilds.set(g.id, g);
|
||||
await g.leave();
|
||||
} catch (err) {
|
||||
this.emit('error', `Failed to leave guild ${g.name}. (${g.id})`, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.options.guildWhitelist.includes(guild.id)) return guilds;
|
||||
if (guild.members.filter(member => member.user.bot).size > this.options.guildPruneLevel) {
|
||||
try {
|
||||
guilds.set(guild.id, guild);
|
||||
await guild.leave();
|
||||
} catch (err) {
|
||||
this.emit('error', `Failed to leave guild ${g.name}. (${g.id})`, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
return guilds;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CommandoClient;
|
||||
|
||||
Reference in New Issue
Block a user