mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 13:14:58 +05:00
Исправлен подсчёт пользователей
This commit is contained in:
parent
7aaaa914f5
commit
77fbca032c
5 changed files with 29 additions and 15 deletions
|
@ -54,7 +54,7 @@ class Leaderboard extends BaseCommand {
|
||||||
const membersLeaderboard = [],
|
const membersLeaderboard = [],
|
||||||
membersData = await client.membersData.find({ guildID: interaction.guildId }).lean();
|
membersData = await client.membersData.find({ guildID: interaction.guildId }).lean();
|
||||||
|
|
||||||
await client.functions.asyncForEach(membersData, async member => {
|
client.functions.asyncForEach(membersData, member => {
|
||||||
membersLeaderboard.push({
|
membersLeaderboard.push({
|
||||||
id: member.id,
|
id: member.id,
|
||||||
money: member.money + member.bankSold,
|
money: member.money + member.bankSold,
|
||||||
|
@ -97,7 +97,7 @@ class Leaderboard extends BaseCommand {
|
||||||
const membersLeaderboard = [],
|
const membersLeaderboard = [],
|
||||||
membersData = await client.membersData.find({ guildID: interaction.guildId }).lean();
|
membersData = await client.membersData.find({ guildID: interaction.guildId }).lean();
|
||||||
|
|
||||||
await client.functions.asyncForEach(membersData, async member => {
|
client.functions.asyncForEach(membersData, async member => {
|
||||||
membersLeaderboard.push({
|
membersLeaderboard.push({
|
||||||
id: member.id,
|
id: member.id,
|
||||||
level: member.level,
|
level: member.level,
|
||||||
|
@ -151,7 +151,7 @@ class Leaderboard extends BaseCommand {
|
||||||
const usersLeaderboard = [],
|
const usersLeaderboard = [],
|
||||||
usersData = await client.usersData.find({ rep: { $gt: 0 } }).lean();
|
usersData = await client.usersData.find({ rep: { $gt: 0 } }).lean();
|
||||||
|
|
||||||
await client.functions.asyncForEach(usersData, async user => {
|
client.functions.asyncForEach(usersData, async user => {
|
||||||
usersLeaderboard.push({
|
usersLeaderboard.push({
|
||||||
id: user.id,
|
id: user.id,
|
||||||
rep: user.rep,
|
rep: user.rep,
|
||||||
|
|
|
@ -31,9 +31,13 @@ class Stats extends BaseCommand {
|
||||||
* @param {Object} data
|
* @param {Object} data
|
||||||
*/
|
*/
|
||||||
async execute(client, interaction, data) {
|
async execute(client, interaction, data) {
|
||||||
const hiddenGuild = await client.guilds.fetch("568120814776614924");
|
const hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount;
|
||||||
const users = client.users.cache.size - hiddenGuild.memberCount;
|
|
||||||
const servers = client.guilds.cache.size - 1;
|
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()
|
const statsEmbed = new EmbedBuilder()
|
||||||
.setColor(client.config.embed.color)
|
.setColor(client.config.embed.color)
|
||||||
|
|
|
@ -14,13 +14,19 @@ class Ready extends BaseEvent {
|
||||||
*/
|
*/
|
||||||
async execute(client) {
|
async execute(client) {
|
||||||
const commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()];
|
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 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(`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");
|
client.logger.log(`Invite Link: ${client.generateInvite({ scopes: ["bot", "applications.commands"], permissions: [ PermissionsBitField.Flags.Administrator ] })}`, "ready");
|
||||||
|
console.timeEnd("botReady");
|
||||||
|
|
||||||
const birthdays = require("../helpers/birthdays");
|
const birthdays = require("../helpers/birthdays");
|
||||||
birthdays.init(client);
|
birthdays.init(client);
|
||||||
|
@ -46,18 +52,21 @@ class Ready extends BaseEvent {
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
setInterval(async function () {
|
setInterval(async function () {
|
||||||
hiddenGuild = await client.guilds.fetch("568120814776614924");
|
hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount;
|
||||||
tUsers = client.users.cache.size - hiddenGuild.memberCount;
|
|
||||||
tServers = client.guilds.cache.size - 1;
|
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}`, {
|
client.user.setActivity(`${status[i].name} | v${version}`, {
|
||||||
type: toShow.type,
|
type: status[i].type,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (status[i + 1]) i++;
|
if (status[i + 1]) i++;
|
||||||
else i = 0;
|
else i = 0;
|
||||||
}, 10000); // Every 10 seconds
|
}, 30 * 1000); // Every 30 seconds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
index.js
1
index.js
|
@ -14,6 +14,7 @@ const client = new JaBa({
|
||||||
await client.loadEvents("../events");
|
await client.loadEvents("../events");
|
||||||
await client.loadCommands("../commands");
|
await client.loadCommands("../commands");
|
||||||
await client.init();
|
await client.init();
|
||||||
|
console.time("botReady");
|
||||||
})();
|
})();
|
||||||
|
|
||||||
client.on("disconnect", () => client.logger.log("Bot is disconnecting...", "warn"))
|
client.on("disconnect", () => client.logger.log("Bot is disconnecting...", "warn"))
|
||||||
|
|
|
@ -11,7 +11,7 @@ const checks = [
|
||||||
() => {
|
() => {
|
||||||
console.log("\n\nEnvironnement");
|
console.log("\n\nEnvironnement");
|
||||||
return new Promise(res => {
|
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");
|
success("node.js version equal or higher than v18");
|
||||||
} else {
|
} else {
|
||||||
error("node.js version should be equal or higher than v18");
|
error("node.js version should be equal or higher than v18");
|
||||||
|
|
Loading…
Reference in a new issue