mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-24 14:14:59 +05:00
63 lines
2.1 KiB
JavaScript
63 lines
2.1 KiB
JavaScript
const { ActivityType } = require("discord.js");
|
|
const BaseEvent = require("../base/BaseEvent");
|
|
|
|
class Ready extends BaseEvent {
|
|
constructor() {
|
|
super({
|
|
name: "ready",
|
|
once: false,
|
|
});
|
|
}
|
|
/**
|
|
*
|
|
* @param {import("../base/Client")} client
|
|
*/
|
|
async execute(client) {
|
|
const commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()];
|
|
|
|
let servers = client.guilds.cache.size;
|
|
let users = 0;
|
|
client.guilds.cache.forEach(g => {
|
|
users += g.memberCount;
|
|
});
|
|
|
|
const birthdays = require("../helpers/birthdays");
|
|
birthdays.init(client);
|
|
|
|
const checkReminds = require("../helpers/checkReminds");
|
|
checkReminds.init(client);
|
|
|
|
if (client.config.dashboard.enabled) await client.dashboard.load(client);
|
|
|
|
client.logger.ready(`Loaded a total of ${commands.length} command(s).`);
|
|
client.logger.ready(`${client.user.getUsername()}, ready to serve ${users} members in ${servers} servers.`);
|
|
|
|
console.timeEnd("botReady");
|
|
|
|
const version = require("../package.json").version;
|
|
const status = [
|
|
{ name: "/help", type: ActivityType.Watching },
|
|
{ name: `${commands.length} ${client.functions.getNoun(commands.length, client.translate("misc:NOUNS:COMMANDS:1"), client.translate("misc:NOUNS:COMMANDS:2"), client.translate("misc:NOUNS:COMMANDS:5"))}`, type: ActivityType.Listening },
|
|
{ name: `${servers} ${client.functions.getNoun(servers, client.translate("misc:NOUNS:SERVER:1"), client.translate("misc:NOUNS:SERVER:2"), client.translate("misc:NOUNS:SERVER:5"))}`, type: ActivityType.Watching },
|
|
{ name: `${users} ${client.functions.getNoun(users, client.translate("misc:NOUNS:USERS:1"), client.translate("misc:NOUNS:USERS:2"), client.translate("misc:NOUNS:USERS:5"))}`, type: ActivityType.Watching },
|
|
];
|
|
|
|
let i = 0;
|
|
setInterval(async function () {
|
|
servers = client.guilds.cache.size;
|
|
users = 0;
|
|
client.guilds.cache.forEach(g => {
|
|
users += g.memberCount;
|
|
});
|
|
|
|
client.user.setActivity(`${status[i].name} | v${version}`, {
|
|
type: status[i].type,
|
|
});
|
|
|
|
if (status[i + 1]) i++;
|
|
else i = 0;
|
|
}, 30 * 1000); // Every 30 seconds
|
|
}
|
|
}
|
|
|
|
module.exports = Ready;
|