From 75b600420369c35e77ab47294633e728ed173d41 Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Tue, 30 Aug 2022 14:26:56 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/Economy/profile.js | 3 ++- commands/Music/queue.js | 8 ++++---- commands/Owner/eval.js | 12 ++++++------ commands/Owner/servers.js | 6 +++--- events/ready.js | 4 ++-- helpers/autoUpdateDocs.js | 4 ++++ helpers/birthdays.js | 4 ++++ helpers/checkReminds.js | 4 ++++ helpers/checkUnmutes.js | 4 ++++ helpers/{clearTransactions.js => cleanup.js} | 20 ++++++++++++++++++++ 10 files changed, 53 insertions(+), 16 deletions(-) rename helpers/{clearTransactions.js => cleanup.js} (51%) diff --git a/commands/Economy/profile.js b/commands/Economy/profile.js index 49d863de..392d5ee2 100644 --- a/commands/Economy/profile.js +++ b/commands/Economy/profile.js @@ -41,6 +41,7 @@ class Profile extends BaseCommand { */ async execute(client, interaction, data) { await interaction.deferReply(); + const member = interaction.options.getMember("user") || interaction.member; if (member.user.bot) return interaction.error("economy/profile:BOT_USER"); @@ -66,7 +67,7 @@ class Profile extends BaseCommand { const profileEmbed = new EmbedBuilder() .setAuthor({ name: interaction.translate("economy/profile:TITLE", { - username: member.user.tag + user: member.nickname }), iconURL: member.displayAvatarURL() }) diff --git a/commands/Music/queue.js b/commands/Music/queue.js index e84fea14..8277340c 100644 --- a/commands/Music/queue.js +++ b/commands/Music/queue.js @@ -63,7 +63,7 @@ class Queue extends BaseCommand { ); await interaction.reply({ - content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/${embeds.length}`, + content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`, embeds: [embeds[currentPage]], components: [row] }); @@ -80,7 +80,7 @@ class Queue extends BaseCommand { if (currentPage !== 0) { --currentPage; interaction.editReply({ - content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/${embeds.length}`, + content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`, embeds: [embeds[currentPage]], components: [row] }); @@ -92,7 +92,7 @@ class Queue extends BaseCommand { if (currentPage < embeds.length - 1) { currentPage++; interaction.editReply({ - content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/${embeds.length}`, + content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`, embeds: [embeds[currentPage]], components: [row] }); @@ -116,7 +116,7 @@ class Queue extends BaseCommand { if (embeds[collected.first().content - 1]) { currentPage = collected.first().content - 1; interaction.editReply({ - content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/${embeds.length}`, + content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`, embeds: [embeds[currentPage]], components: [row] }); diff --git a/commands/Owner/eval.js b/commands/Owner/eval.js index f5113a6c..3bcab8f8 100644 --- a/commands/Owner/eval.js +++ b/commands/Owner/eval.js @@ -35,6 +35,8 @@ class Eval extends BaseCommand { */ // eslint-disable-next-line no-unused-vars async execute(client, interaction, data) { + await interaction.deferReply({ ephemeral: true }); + const code = interaction.options.getString("code"); const result = new Promise(resolve => resolve(eval(code))); @@ -42,18 +44,16 @@ class Eval extends BaseCommand { if (typeof output != "string") output = require("util").inspect(output, { depth: 0 }); if (output.includes(client.token)) output = output.replace(client.token, "T0K3N"); - interaction.reply({ - content: "```js\n" + output + "```", - ephemeral: true + interaction.editReply({ + content: "```js\n" + output + "```" }); }).catch(err => { console.error(err); err = err.toString(); if (err.includes(client.token)) err = err.replace(client.token, "T0K3N"); - interaction.reply({ - content: "```js\n" + err + "```", - ephemeral: true + interaction.editReply({ + content: "```js\n" + err + "```" }); }); } diff --git a/commands/Owner/servers.js b/commands/Owner/servers.js index 1b97daba..8a328f9e 100644 --- a/commands/Owner/servers.js +++ b/commands/Owner/servers.js @@ -73,7 +73,7 @@ class Servers extends BaseCommand { if (currentPage !== 0) { --currentPage; interaction.editReply({ - content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/${embeds.length}`, + content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`, embeds: [embeds[currentPage]], components: [row] }); @@ -84,7 +84,7 @@ class Servers extends BaseCommand { if (currentPage < embeds.length - 1) { currentPage++; interaction.editReply({ - content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/${embeds.length}`, + content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`, embeds: [embeds[currentPage]], components: [row] }); @@ -107,7 +107,7 @@ class Servers extends BaseCommand { if (embeds[collected.first().content - 1]) { currentPage = collected.first().content - 1; interaction.editReply({ - content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/${embeds.length}`, + content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`, embeds: [embeds[currentPage]], components: [row] }); diff --git a/events/ready.js b/events/ready.js index 4cbf5c4e..880bf781 100644 --- a/events/ready.js +++ b/events/ready.js @@ -36,8 +36,8 @@ class Ready extends BaseEvent { checkReminds.init(client); // Clear transactions - const clearTransactions = require("../helpers/clearTransactions"); - clearTransactions.init(client); + const cleanup = require("../helpers/cleanup"); + cleanup.init(client); // Start the dashboard if (client.config.dashboard.enabled) client.dashboard.init(client); diff --git a/helpers/autoUpdateDocs.js b/helpers/autoUpdateDocs.js index 87c54569..69f993f6 100644 --- a/helpers/autoUpdateDocs.js +++ b/helpers/autoUpdateDocs.js @@ -1,6 +1,10 @@ const table = require("markdown-table"), fs = require("fs"); +/** + * + * @param {import("../base/JaBa")} client + */ module.exports.update = function (client) { const commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()], categories = []; diff --git a/helpers/birthdays.js b/helpers/birthdays.js index b6a2fea6..8c130c02 100644 --- a/helpers/birthdays.js +++ b/helpers/birthdays.js @@ -1,6 +1,10 @@ const { CronJob } = require("cron"), { EmbedBuilder } = require("discord.js"); +/** + * + * @param {import("../base/JaBa")} client + */ module.exports.init = async function (client) { new CronJob("0 5 * * *", async function () { client.guilds.cache.forEach(async (guild) => { diff --git a/helpers/checkReminds.js b/helpers/checkReminds.js index b50dd799..3dcdb2ed 100644 --- a/helpers/checkReminds.js +++ b/helpers/checkReminds.js @@ -1,5 +1,9 @@ const { EmbedBuilder } = require("discord.js"); +/** + * + * @param {import("../base/JaBa")} client + */ module.exports.init = function (client) { client.usersData .find({ reminds: { $gt: [] } }) diff --git a/helpers/checkUnmutes.js b/helpers/checkUnmutes.js index 63194b2c..0f1104b3 100644 --- a/helpers/checkUnmutes.js +++ b/helpers/checkUnmutes.js @@ -1,5 +1,9 @@ const { EmbedBuilder } = require("discord.js"); +/** + * + * @param {import("../base/JaBa")} client + */ module.exports.init = async function (client) { client.membersData .find({ "mute.muted": true }) diff --git a/helpers/clearTransactions.js b/helpers/cleanup.js similarity index 51% rename from helpers/clearTransactions.js rename to helpers/cleanup.js index aa816e0b..f701c390 100644 --- a/helpers/clearTransactions.js +++ b/helpers/cleanup.js @@ -1,3 +1,7 @@ +/** + * + * @param {import("../base/JaBa")} client + */ module.exports.init = async function (client) { setInterval(async () => { const timestamp = Date.now() + (30 * 24 * 60 * 60 * 1000); // 1 month @@ -14,4 +18,20 @@ module.exports.init = async function (client) { } } }, (7 * 24 * 60 * 60 * 1000)); // every 7 days + + /* + setInterval(async () => { + client.usersData.find({}, function (err, res) { + for (const user of res) { + client.users.fetch(user.id).then(u => { + if (u.username.match(/.*Deleted User.* [A-z0-9]+/g)) { + client.databaseCache.users.delete(user.id); + client.usersData.deleteOne({ id: user.id }); + console.log(`Removed from database deleted user - ID: ${u.id} Username: ${u.username}`); + } + }); + } + }); + }, (7 * 24 * 60 * 60 * 1000)); // every 7 days + */ }; \ No newline at end of file