This commit is contained in:
Erik 2022-04-25 19:29:18 +03:00
parent 8ae1e757eb
commit 7a06e8c32e
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -63,13 +63,13 @@ class DiscordClient extends Client {
this._loadEevents();
process.on('uncaughtException', (err) => {
this.logger.error(`Uncaught exception:\n${err.stack || err}`);
});
// process.on('uncaughtException', (err) => {
// this.logger.error(`Uncaught exception:\n${err.stack || err}`);
// });
process.on('unhandledRejection', (err) => {
this.logger.error(`Unhandled rejection:\n${err.stack || err}`);
});
// process.on('unhandledRejection', (err) => {
// this.logger.error(`Unhandled rejection:\n${err.stack || err}`);
// });
}
@ -101,6 +101,11 @@ class DiscordClient extends Client {
await super.login();
await ready;
this._setActivity();
this._activityInterval = setInterval(() => {
this._setActivity();
}, 1800_000); // 30 min
return this;
}
@ -144,15 +149,15 @@ 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);
const guildCount = (await this.shard.broadcastEval((client) => client.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);
const userCount = (await this.shard.broadcastEval((client) => client.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' });
this.user.setActivity("for /help", { type: 'LISTENING' });
}
};
@ -253,6 +258,7 @@ class DiscordClient extends Client {
});
}
get prefix() {
return this._options.discord.prefix;