JaBa/events/Ready.js

67 lines
2.1 KiB
JavaScript
Raw Normal View History

const { ActivityType } = require("discord.js");
2022-08-04 21:02:45 +05:00
const BaseEvent = require("../base/BaseEvent");
2022-01-04 02:18:28 +05:00
class Ready extends BaseEvent {
constructor() {
super({
name: "ready",
once: false,
});
2022-01-04 02:18:28 +05:00
}
2024-10-03 11:07:02 +05:00
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../base/Client")} client
*/
async execute(client) {
const commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()];
2024-08-10 21:52:23 +05:00
let servers = client.guilds.cache.size;
let users = 0;
2024-10-03 11:07:02 +05:00
client.guilds.cache.forEach(g => {
2024-08-10 21:52:23 +05:00
users += g.memberCount;
});
2022-01-04 02:18:28 +05:00
const birthdays = require("../helpers/birthdays");
birthdays.init(client);
const checkReminds = require("../helpers/checkReminds");
checkReminds.init(client);
2023-06-27 19:01:39 +05:00
if (client.config.dashboard.enabled) await client.dashboard.load(client);
client.logger.ready(`Loaded a total of ${commands.length} command(s).`);
2024-08-10 21:52:23 +05:00
client.logger.ready(`${client.user.getUsername()}, ready to serve ${users} members in ${servers} servers.`);
2023-06-27 19:01:39 +05:00
console.timeEnd("botReady");
2022-01-04 02:18:28 +05:00
const version = require("../package.json").version;
const status = [
2024-08-25 15:13:18 +05:00
`${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"))} available!`,
2024-09-14 19:52:56 +05:00
`I'm in ${servers} ${client.functions.getNoun(servers, client.translate("misc:NOUNS:SERVER:1"), client.translate("misc:NOUNS:SERVER:2"), client.translate("misc:NOUNS:SERVER:5"))}!`,
`Cached ${users} ${client.functions.getNoun(users, client.translate("misc:NOUNS:USERS:1"), client.translate("misc:NOUNS:USERS:2"), client.translate("misc:NOUNS:USERS:5"))}.`,
"Use /help for commands list!",
"Did you know that I have a brother called JaBa IT? Yeah! Ask Jonny about him.",
2022-01-04 02:18:28 +05:00
];
let i = 0;
2024-10-03 11:07:02 +05:00
setInterval(async () => {
servers = (await client.guilds.fetch()).size;
2024-08-10 21:52:23 +05:00
users = 0;
2024-10-03 11:07:02 +05:00
client.guilds.cache.forEach(g => {
2024-08-10 21:52:23 +05:00
users += g.memberCount;
});
2022-01-04 02:18:28 +05:00
2024-08-25 15:13:18 +05:00
client.user.setActivity({
type: ActivityType.Custom,
name: "custom",
state: `${status[i]} | v${version}`,
2022-01-04 02:18:28 +05:00
});
2024-10-03 11:07:02 +05:00
i = (i + 1) % status.length; // Wrap around to the start when reaching the end
}, 30 * 1000); // Every 30 seconds
2022-01-04 02:18:28 +05:00
}
}
2023-07-05 00:58:06 +05:00
module.exports = Ready;