forked from Galactic/galactic-bot
Interval discord activities, support cross-shard guild fetching for activities, and allow for expandability for more statuses.
This commit is contained in:
parent
a4216cba59
commit
d6337126c0
@ -48,8 +48,13 @@ class DiscordClient extends Client {
|
||||
|
||||
process.on('message', this._handleMessage.bind(this));
|
||||
if (this._options.libDebug) this.on('debug', this.logger.debug.bind(this.logger));
|
||||
this.on('ready', () => {
|
||||
this.user.setActivity(`over ${this.guilds.cache.size} servers.`, { type: 'WATCHING' });
|
||||
|
||||
this._activity = 0;
|
||||
|
||||
this.once('ready', () => {
|
||||
this._setActivity();
|
||||
|
||||
this.setInterval(this._setActivity, 1800000); // I think this is 30 minutes. I could be wrong.
|
||||
});
|
||||
|
||||
}
|
||||
@ -183,7 +188,24 @@ class DiscordClient extends Client {
|
||||
return this.storageManager;
|
||||
}
|
||||
|
||||
async aggregateStatistics() {
|
||||
async _setActivity() {
|
||||
const activities = {
|
||||
0: async () => {
|
||||
const guildCount = (await this.shard.broadcastEval('this.guilds.cache.size')).reduce((p, v) => p+v, 0);
|
||||
this.user.setActivity(`${guildCount} servers`, { type: 'WATCHING' });
|
||||
},
|
||||
1: async () => {
|
||||
const userCount = (await this.shard.broadcastEval('this.users.cache.size')).reduce((p, v) => p+v, 0);
|
||||
this.user.setActivity(`to ${userCount} users`, { type: 'LISTENING' });
|
||||
},
|
||||
2: async () => {
|
||||
this.user.setActivity("to -help", { type: 'LISTENING' });
|
||||
}
|
||||
};
|
||||
|
||||
await activities[this._activity]();
|
||||
if(this._activity === Math.max(...Object.keys(activities))) this._activity = 0;
|
||||
else this._activity++;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user