diff --git a/src/structure/DiscordClient.js b/src/structure/DiscordClient.js index 096efe0..ae3948f 100644 --- a/src/structure/DiscordClient.js +++ b/src/structure/DiscordClient.js @@ -27,6 +27,14 @@ class DiscordClient extends Client { this._options = options; this._built = false; + this.once('ready', () => { + this._setActivity(); + + setInterval(() => { + this._setActivity(); + }, 1800000); // I think this is 30 minutes. I could be wrong. + }); + } async build() { @@ -54,6 +62,27 @@ class DiscordClient extends Client { } + 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++; + + } + get singleton() { return Boolean(this.shard.ids[0] === 0); }