Add activity
This commit is contained in:
parent
c2ee6cf8e4
commit
943da83993
@ -27,6 +27,14 @@ class DiscordClient extends Client {
|
|||||||
this._options = options;
|
this._options = options;
|
||||||
this._built = false;
|
this._built = false;
|
||||||
|
|
||||||
|
this.once('ready', () => {
|
||||||
|
this._setActivity();
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
this._setActivity();
|
||||||
|
}, 1800000); // I think this is 30 minutes. I could be wrong.
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async build() {
|
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() {
|
get singleton() {
|
||||||
return Boolean(this.shard.ids[0] === 0);
|
return Boolean(this.shard.ids[0] === 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user