JaBa/events/ready.js

72 lines
2.5 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
}
/**
*
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()];
let hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount;
let tServers = client.guilds.cache.size - 1;
let tUsers = 0;
client.guilds.cache.forEach(g => {
tUsers += g.memberCount;
});
tUsers = tUsers - hiddenGuildMembersCount;
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).`);
client.logger.ready(`${client.user.getUsername()}, ready to serve ${tUsers} members in ${tServers} 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 = [
2023-06-27 19:01:39 +05:00
{ 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: `${tServers} ${client.functions.getNoun(tServers, client.translate("misc:NOUNS:SERVER:1"), client.translate("misc:NOUNS:SERVER:2"), client.translate("misc:NOUNS:SERVER:5"))}`, type: ActivityType.Watching },
{ name: `${tUsers} ${client.functions.getNoun(tUsers, client.translate("misc:NOUNS:USERS:1"), client.translate("misc:NOUNS:USERS:2"), client.translate("misc:NOUNS:USERS:5"))}`, type: ActivityType.Watching },
2022-01-04 02:18:28 +05:00
];
let i = 0;
setInterval(async function () {
hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount;
2022-01-24 19:40:47 +05:00
tServers = client.guilds.cache.size - 1;
tUsers = 0;
client.guilds.cache.forEach(g => {
tUsers += g.memberCount;
});
tUsers = tUsers - hiddenGuildMembersCount;
2022-01-04 02:18:28 +05:00
client.user.setActivity(`${status[i].name} | v${version}`, {
type: status[i].type,
2022-01-04 02:18:28 +05:00
});
2022-08-04 21:02:45 +05:00
if (status[i + 1]) i++;
2022-01-04 02:18:28 +05:00
else i = 0;
}, 30 * 1000); // Every 30 seconds
2024-04-29 15:57:02 +05:00
await client.lavalink.init({ ...client.user });
client.on("raw", d => client.lavalink.sendRawData(d));
client.logger.ready("Lavalink ready.");
2022-01-04 02:18:28 +05:00
}
}
2023-07-05 00:58:06 +05:00
module.exports = Ready;