2024-09-19 23:58:06 +05:00
|
|
|
const { SlashCommandBuilder, PermissionsBitField, version: discordJsVersion, InteractionContextType, ApplicationIntegrationType } = require("discord.js");
|
2022-08-04 19:26:17 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Stats extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../base/Client")} client
|
2022-08-04 19:26:17 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("stats")
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDescription(client.translate("general/stats:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("general/stats:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("general/stats:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2024-09-19 23:58:06 +05:00
|
|
|
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall])
|
|
|
|
.setContexts([InteractionContextType.BotDM, InteractionContextType.PrivateChannel, InteractionContextType.Guild])
|
|
|
|
.addBooleanOption(option =>
|
|
|
|
option
|
|
|
|
.setName("ephemeral")
|
|
|
|
.setDescription(client.translate("misc:EPHEMERAL_RESPONSE"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("misc:EPHEMERAL_RESPONSE", null, "uk-UA"),
|
|
|
|
ru: client.translate("misc:EPHEMERAL_RESPONSE", null, "ru-RU"),
|
|
|
|
}),
|
|
|
|
),
|
2022-08-04 19:26:17 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-04 19:26:17 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-08-04 19:26:17 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-04 19:26:17 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
|
|
*/
|
2023-12-14 18:58:19 +05:00
|
|
|
async execute(client, interaction) {
|
2024-09-19 23:58:06 +05:00
|
|
|
await interaction.deferReply({ ephemeral: interaction.options.getBoolean("ephemeral") || false });
|
|
|
|
|
2024-08-13 12:12:39 +05:00
|
|
|
const servers = client.guilds.cache.size;
|
2023-03-30 15:52:58 +05:00
|
|
|
let users = 0;
|
|
|
|
client.guilds.cache.forEach(g => {
|
|
|
|
users += g.memberCount;
|
|
|
|
});
|
2022-08-04 19:26:17 +05:00
|
|
|
|
2024-02-06 21:45:53 +05:00
|
|
|
const embed = client.embed({
|
|
|
|
author: interaction.translate("common:STATS"),
|
|
|
|
descirption: interaction.translate("general/stats:MADE"),
|
|
|
|
fields: [
|
2022-08-04 19:26:17 +05:00
|
|
|
{
|
|
|
|
name: client.customEmojis.stats + " " + interaction.translate("general/stats:COUNTS_TITLE"),
|
|
|
|
value: interaction.translate("general/stats:COUNTS_CONTENT", {
|
|
|
|
servers: servers,
|
2022-12-15 21:02:38 +05:00
|
|
|
users: users,
|
2022-08-04 19:26:17 +05:00
|
|
|
}),
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
2022-08-04 19:26:17 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: client.customEmojis.version + " " + interaction.translate("general/stats:VERSIONS_TITLE"),
|
2024-09-14 19:52:56 +05:00
|
|
|
value: `\`Discord.js: v${discordJsVersion}\`\n\`Nodejs: v${process.versions.node}\``,
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
2022-08-04 19:26:17 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: client.customEmojis.ram + " " + interaction.translate("general/stats:RAM_TITLE"),
|
2024-03-06 09:22:00 +05:00
|
|
|
value: `\`${Math.floor(process.memoryUsage().heapUsed / 1024 / 1024)}MB\``,
|
2022-12-15 21:02:38 +05:00
|
|
|
inline: true,
|
2022-08-04 19:26:17 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: client.customEmojis.status.online + " " + interaction.translate("general/stats:ONLINE_TITLE"),
|
|
|
|
value: interaction.translate("general/stats:ONLINE_CONTENT", {
|
2024-02-27 16:51:37 +05:00
|
|
|
time: `<t:${Math.floor((Date.now() - client.uptime) / 1000)}:R>`,
|
2022-12-15 21:02:38 +05:00
|
|
|
}),
|
2022-08-04 19:26:17 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: client.customEmojis.voice + " " + interaction.translate("general/stats:MUSIC_TITLE"),
|
|
|
|
value: interaction.translate("general/stats:MUSIC_CONTENT", {
|
2023-07-05 00:58:06 +05:00
|
|
|
count: `${client.player.nodes.cache.size} ${client.functions.getNoun(
|
|
|
|
client.player.nodes.cache.size,
|
|
|
|
interaction.translate("misc:NOUNS:SERVERS:1"),
|
|
|
|
interaction.translate("misc:NOUNS:SERVERS:2"),
|
|
|
|
interaction.translate("misc:NOUNS:SERVERS:5"),
|
|
|
|
)}`,
|
2022-12-15 21:02:38 +05:00
|
|
|
}),
|
2022-08-04 19:26:17 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: interaction.translate("general/stats:CREDITS_TITLE"),
|
2022-12-15 21:02:38 +05:00
|
|
|
value: interaction.translate("general/stats:CREDITS_CONTENT"),
|
2022-08-04 19:26:17 +05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: client.customEmojis.link + " " + interaction.translate("general/stats:LINKS_TITLE"),
|
|
|
|
value: interaction.translate("misc:STATS_FOOTER", {
|
2023-02-12 14:50:59 +05:00
|
|
|
supportLink: "https://discord.gg/Ptkj2n9nzZ",
|
2023-07-05 00:58:06 +05:00
|
|
|
inviteLink: client.generateInvite({ scopes: ["bot", "applications.commands"], permissions: [PermissionsBitField.Flags.Administrator] }),
|
2022-12-15 21:02:38 +05:00
|
|
|
owner: client.config.owner.id,
|
|
|
|
}),
|
|
|
|
},
|
2024-02-06 21:45:53 +05:00
|
|
|
],
|
|
|
|
});
|
2022-08-04 19:26:17 +05:00
|
|
|
|
2024-09-19 23:58:06 +05:00
|
|
|
interaction.editReply({
|
2024-02-06 21:45:53 +05:00
|
|
|
embeds: [embed],
|
2022-08-04 19:26:17 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Stats;
|