From 2d58660e0f72aaac8cbb80becfa6a8b336cbe9ac Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Sun, 20 Feb 2022 16:47:58 +0500 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=B5=D0=B7=20=D1=80=D0=B5=D0=B0=D0=BA?= =?UTF-8?q?=D1=86=D0=B8=D0=B9=20=D0=B2=20=D0=9B=D0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/Owner/servers-list.js | 116 +++++++++++++++++---------------- 1 file changed, 59 insertions(+), 57 deletions(-) diff --git a/commands/Owner/servers-list.js b/commands/Owner/servers-list.js index 8c296c72..f17d3c1c 100644 --- a/commands/Owner/servers-list.js +++ b/commands/Owner/servers-list.js @@ -18,7 +18,7 @@ class ServersList extends Command { } async run(message, args, data) { - if (message.channel.type !== "DM") message.delete(); + if (message.deletable) message.delete(); let i0 = 0, i1 = 10, @@ -50,76 +50,78 @@ class ServersList extends Command { embeds: [embed] }); - await msg.react("⬅"); - await msg.react("➡"); - await msg.react("❌"); + if (message.channel.type !== "DM") { + await msg.react("⬅"); + await msg.react("➡"); + await msg.react("❌"); - const filter = (reaction, user) => user.id === message.author.id; - const collector = msg.createReactionCollector({ - filter, - time: 30000 - }); + const filter = (reaction, user) => user.id === message.author.id; + const collector = msg.createReactionCollector({ + filter, + time: 30000 + }); - collector.on("collect", async (reaction) => { - if (message.channel.type === "DM") return; + collector.on("collect", async (reaction) => { + if (message.channel.type === "DM") return; - if (reaction._emoji.name === "⬅") { - // Updates variables - i0 = i0 - 10; - i1 = i1 - 10; - page = page - 1; + if (reaction._emoji.name === "⬅") { + // Updates variables + i0 = i0 - 10; + i1 = i1 - 10; + page = page - 1; - // if there is no guild to display, delete the message - if (i0 < 0) return msg.delete(); - if (!i0 || !i1) return msg.delete(); + // if there is no guild to display, delete the message + if (i0 < 0) return msg.delete(); + if (!i0 || !i1) return msg.delete(); - description = `${message.translate("common:SERVERS")}: ${this.client.guilds.cache.size}\n\n` + - this.client.guilds.cache.sort((a, b) => b.memberCount - a.memberCount).map((r) => r) - .map((r, i) => `**${i + 1}** - ${r.name} | ${r.memberCount} ${message.translate("common:MEMBERS")}`) - .slice(i0, i1) - .join("\n"); + description = `${message.translate("common:SERVERS")}: ${this.client.guilds.cache.size}\n\n` + + this.client.guilds.cache.sort((a, b) => b.memberCount - a.memberCount).map((r) => r) + .map((r, i) => `**${i + 1}** - ${r.name} | ${r.memberCount} ${message.translate("common:MEMBERS")}`) + .slice(i0, i1) + .join("\n"); - // Update the embed with new informations - embed.setTitle(`${message.translate("common:PAGE")}: ${page}/${Math.round(this.client.guilds.cache.size/10)}`) - .setDescription(description); + // Update the embed with new informations + embed.setTitle(`${message.translate("common:PAGE")}: ${page}/${Math.round(this.client.guilds.cache.size/10)}`) + .setDescription(description); - // Edit the message - msg.edit({ - embeds: [embed] - }); - } + // Edit the message + msg.edit({ + embeds: [embed] + }); + } - if (reaction._emoji.name === "➡") { - // Updates variables - i0 = i0 + 10; - i1 = i1 + 10; - page = page + 1; + if (reaction._emoji.name === "➡") { + // Updates variables + i0 = i0 + 10; + i1 = i1 + 10; + page = page + 1; - // if there is no guild to display, delete the message - if (i1 > this.client.guilds.cache.size + 10) return msg.delete(); - if (!i0 || !i1) return msg.delete(); + // if there is no guild to display, delete the message + if (i1 > this.client.guilds.cache.size + 10) return msg.delete(); + if (!i0 || !i1) return msg.delete(); - description = `${message.translate("common:SERVERS")}: ${this.client.guilds.cache.size}\n\n` + - this.client.guilds.cache.sort((a, b) => b.memberCount - a.memberCount).map((r) => r) - .map((r, i) => `**${i + 1}** - ${r.name} | ${r.memberCount} ${message.translate("common:MEMBERS").toLowerCase()}`) - .slice(i0, i1) - .join("\n"); + description = `${message.translate("common:SERVERS")}: ${this.client.guilds.cache.size}\n\n` + + this.client.guilds.cache.sort((a, b) => b.memberCount - a.memberCount).map((r) => r) + .map((r, i) => `**${i + 1}** - ${r.name} | ${r.memberCount} ${message.translate("common:MEMBERS").toLowerCase()}`) + .slice(i0, i1) + .join("\n"); - // Update the embed with new informations - embed.setTitle(`${message.translate("common:PAGE")}: ${page}/${Math.round(this.client.guilds.cache.size/10)}`) - .setDescription(description); + // Update the embed with new informations + embed.setTitle(`${message.translate("common:PAGE")}: ${page}/${Math.round(this.client.guilds.cache.size/10)}`) + .setDescription(description); - // Edit the message - msg.edit({ - embeds: [embed] - }); - } + // Edit the message + msg.edit({ + embeds: [embed] + }); + } - if (reaction._emoji.name === "❌") return msg.delete(); + if (reaction._emoji.name === "❌") return msg.delete(); - // Remove the reaction when the user react to the message - await reaction.users.remove(message.author.id); - }); + // Remove the reaction when the user react to the message + await reaction.users.remove(message.author.id); + }); + } } }