diff --git a/commands/Economy/leaderboard.js b/commands/Economy/leaderboard.js index 05d148c8..4df7b45d 100644 --- a/commands/Economy/leaderboard.js +++ b/commands/Economy/leaderboard.js @@ -54,7 +54,7 @@ class Leaderboard extends BaseCommand { const membersLeaderboard = [], membersData = await client.membersData.find({ guildID: interaction.guildId }).lean(); - await client.functions.asyncForEach(membersData, async member => { + client.functions.asyncForEach(membersData, member => { membersLeaderboard.push({ id: member.id, money: member.money + member.bankSold, @@ -97,7 +97,7 @@ class Leaderboard extends BaseCommand { const membersLeaderboard = [], membersData = await client.membersData.find({ guildID: interaction.guildId }).lean(); - await client.functions.asyncForEach(membersData, async member => { + client.functions.asyncForEach(membersData, async member => { membersLeaderboard.push({ id: member.id, level: member.level, @@ -151,7 +151,7 @@ class Leaderboard extends BaseCommand { const usersLeaderboard = [], usersData = await client.usersData.find({ rep: { $gt: 0 } }).lean(); - await client.functions.asyncForEach(usersData, async user => { + client.functions.asyncForEach(usersData, async user => { usersLeaderboard.push({ id: user.id, rep: user.rep, diff --git a/commands/General/stats.js b/commands/General/stats.js index ef82e113..0dbd3e89 100644 --- a/commands/General/stats.js +++ b/commands/General/stats.js @@ -31,9 +31,13 @@ class Stats extends BaseCommand { * @param {Object} data */ async execute(client, interaction, data) { - const hiddenGuild = await client.guilds.fetch("568120814776614924"); - const users = client.users.cache.size - hiddenGuild.memberCount; + const hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount; const servers = client.guilds.cache.size - 1; + let users = 0; + client.guilds.cache.forEach(g => { + users += g.memberCount; + }); + users = users - hiddenGuildMembersCount; const statsEmbed = new EmbedBuilder() .setColor(client.config.embed.color) diff --git a/events/ready.js b/events/ready.js index 4bbf995a..505abcfd 100644 --- a/events/ready.js +++ b/events/ready.js @@ -14,13 +14,19 @@ class Ready extends BaseEvent { */ async execute(client) { const commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()]; - let hiddenGuild = await client.guilds.fetch("568120814776614924"); - let tUsers = client.users.cache.size - hiddenGuild.memberCount; + + 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; client.logger.log(`Loaded a total of ${commands.length} command(s).`, "ready"); - client.logger.log(`${client.user.tag}, ready to serve ${tUsers} users in ${tServers} servers.`, "ready"); + client.logger.log(`${client.user.tag}, ready to serve ${tUsers} members in ${tServers} servers.`, "ready"); client.logger.log(`Invite Link: ${client.generateInvite({ scopes: ["bot", "applications.commands"], permissions: [ PermissionsBitField.Flags.Administrator ] })}`, "ready"); + console.timeEnd("botReady"); const birthdays = require("../helpers/birthdays"); birthdays.init(client); @@ -46,18 +52,21 @@ class Ready extends BaseEvent { let i = 0; setInterval(async function () { - hiddenGuild = await client.guilds.fetch("568120814776614924"); - tUsers = client.users.cache.size - hiddenGuild.memberCount; + hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount; tServers = client.guilds.cache.size - 1; - const toShow = status[i]; + tUsers = 0; + client.guilds.cache.forEach(g => { + tUsers += g.memberCount; + }); + tUsers = tUsers - hiddenGuildMembersCount; - client.user.setActivity(`${toShow.name} | v${version}`, { - type: toShow.type, + client.user.setActivity(`${status[i].name} | v${version}`, { + type: status[i].type, }); if (status[i + 1]) i++; else i = 0; - }, 10000); // Every 10 seconds + }, 30 * 1000); // Every 30 seconds } } diff --git a/index.js b/index.js index 0a365446..b7febc81 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,7 @@ const client = new JaBa({ await client.loadEvents("../events"); await client.loadCommands("../commands"); await client.init(); + console.time("botReady"); })(); client.on("disconnect", () => client.logger.log("Bot is disconnecting...", "warn")) diff --git a/scripts/verify-config.js b/scripts/verify-config.js index 2d531328..bbb69c93 100644 --- a/scripts/verify-config.js +++ b/scripts/verify-config.js @@ -11,7 +11,7 @@ const checks = [ () => { console.log("\n\nEnvironnement"); return new Promise(res => { - if (parseInt(process.version.split(".")[0].split("v")[1]) >= 18) { + if (parseInt(process.versions.node.split(".")[0]) >= 18) { success("node.js version equal or higher than v18"); } else { error("node.js version should be equal or higher than v18");