2022-07-31 17:08:00 +05:00
|
|
|
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
2022-07-29 23:31:08 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Servers extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("servers")
|
|
|
|
.setDescription(client.translate("owner/servers:DESCRIPTION")),
|
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
|
|
|
guildOnly: true,
|
|
|
|
ownerOnly: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
2022-08-01 20:06:09 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-07-29 23:31:08 +05:00
|
|
|
* @param {Array} data
|
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
|
|
|
let i0 = 0,
|
|
|
|
i1 = 10,
|
|
|
|
page = 1;
|
|
|
|
|
|
|
|
let description = `${interaction.translate("common:SERVERS")}: ${client.guilds.cache.size}\n\n` +
|
|
|
|
client.guilds.cache
|
|
|
|
.sort((a, b) => b.memberCount - a.memberCount)
|
|
|
|
.map((r) => r)
|
|
|
|
.map((r, i) => `**${i + 1}** - ${r.name} | ${r.memberCount} ${client.getNoun(r.memberCount, interaction.translate("misc:NOUNS:MEMBERS:1"), interaction.translate("misc:NOUNS:MEMBERS:2"), interaction.translate("misc:NOUNS:MEMBERS:5"))}`)
|
|
|
|
.slice(0, 10)
|
|
|
|
.join("\n");
|
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
const embed = new EmbedBuilder()
|
2022-07-29 23:31:08 +05:00
|
|
|
.setAuthor({
|
|
|
|
name: interaction.user.tag,
|
|
|
|
iconURL: interaction.user.displayAvatarURL({
|
|
|
|
size: 512,
|
|
|
|
format: "png"
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.setColor(client.config.embed.color)
|
|
|
|
.setFooter({
|
|
|
|
text: client.user.username
|
|
|
|
})
|
|
|
|
.setTitle(`${interaction.translate("common:PAGE")}: ${page}/${client.guilds.cache.size}`)
|
|
|
|
.setDescription(description);
|
|
|
|
|
|
|
|
await interaction.reply({
|
|
|
|
embeds: [embed],
|
|
|
|
});
|
|
|
|
|
|
|
|
const msg = await interaction.fetchReply();
|
|
|
|
|
|
|
|
await msg.react("⬅");
|
|
|
|
await msg.react("➡");
|
|
|
|
await msg.react("❌");
|
|
|
|
|
|
|
|
const collector = msg.createReactionCollector({
|
|
|
|
time: 60 * 1000
|
|
|
|
});
|
|
|
|
|
2022-08-01 20:06:09 +05:00
|
|
|
collector.on("collect", async reaction => {
|
2022-07-29 23:31:08 +05:00
|
|
|
if (reaction._emoji.name === "⬅") {
|
|
|
|
i0 = i0 - 10;
|
|
|
|
i1 = i1 - 10;
|
|
|
|
page = page - 1;
|
|
|
|
|
|
|
|
if (i0 < 0) return msg.delete();
|
|
|
|
if (!i0 || !i1) return msg.delete();
|
|
|
|
|
|
|
|
description = `${interaction.translate("common:SERVERS")}: ${client.guilds.cache.size}\n\n` +
|
|
|
|
client.guilds.cache
|
|
|
|
.sort((a, b) => b.memberCount - a.memberCount)
|
|
|
|
.map((r) => r)
|
|
|
|
.map((r, i) => `**${i + 1}** - ${r.name} | ${r.memberCount} ${client.getNoun(r.memberCount, interaction.translate("misc:NOUNS:MEMBERS:1"), interaction.translate("misc:NOUNS:MEMBERS:2"), interaction.translate("misc:NOUNS:MEMBERS:5"))}`)
|
|
|
|
.slice(i0, i1)
|
|
|
|
.join("\n");
|
|
|
|
|
|
|
|
embed
|
|
|
|
.setTitle(`${interaction.translate("common:PAGE")}: ${page}/${client.guilds.cache.size}`)
|
|
|
|
.setDescription(description);
|
|
|
|
|
|
|
|
msg.edit({
|
|
|
|
embeds: [embed]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reaction._emoji.name === "➡") {
|
|
|
|
i0 = i0 + 10;
|
|
|
|
i1 = i1 + 10;
|
|
|
|
page = page + 1;
|
|
|
|
|
|
|
|
if (i1 > client.guilds.cache.size + 10) return msg.delete();
|
|
|
|
if (!i0 || !i1) return msg.delete();
|
|
|
|
|
|
|
|
description = `${interaction.translate("common:SERVERS")}: ${client.guilds.cache.size}\n\n` +
|
|
|
|
client.guilds.cache
|
|
|
|
.sort((a, b) => b.memberCount - a.memberCount)
|
|
|
|
.map((r) => r)
|
|
|
|
.map((r, i) => `**${i + 1}** - ${r.name} | ${r.memberCount} ${client.getNoun(r.memberCount, interaction.translate("misc:NOUNS:MEMBERS:1"), interaction.translate("misc:NOUNS:MEMBERS:2"), interaction.translate("misc:NOUNS:MEMBERS:5"))}`)
|
|
|
|
.slice(i0, i1)
|
|
|
|
.join("\n");
|
|
|
|
|
|
|
|
embed.setTitle(`${interaction.translate("common:PAGE")}: ${page}/${Math.round(client.guilds.cache.size / 10)}`)
|
|
|
|
.setDescription(description);
|
|
|
|
|
|
|
|
msg.edit({
|
|
|
|
embeds: [embed]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (reaction._emoji.name === "❌") return msg.delete();
|
|
|
|
|
|
|
|
await reaction.users.remove(interaction.user.id);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Servers;
|