From cc0fd759f7222aae39ca4a99173ca58d8662f395 Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Fri, 9 Feb 2024 23:26:57 +0500 Subject: [PATCH] v4.4.3 --- base/Client.js | 16 +++--- commands/!DISABLED/ban.js | 1 - commands/!DISABLED/importmee6.js | 11 ++-- commands/!DISABLED/kick.js | 1 - commands/!DISABLED/memes.js | 3 +- commands/!DISABLED/staff.js | 1 - commands/Administration/automod.js | 18 +++---- commands/Administration/autorole.js | 18 +++---- commands/Administration/config.js | 46 ++++++++--------- commands/Administration/goodbye.js | 18 +++---- commands/Administration/selectroles.js | 4 +- commands/Administration/set.js | 1 - commands/Administration/setlang.js | 12 ++--- commands/Administration/stealemoji.js | 6 +-- commands/Administration/welcome.js | 18 +++---- commands/Economy/achievements.js | 5 +- commands/Economy/bank.js | 40 ++++++++------- commands/Economy/birthdate.js | 12 ++--- commands/Economy/divorce.js | 27 +++++----- commands/Economy/leaderboard.js | 1 - commands/Economy/marry.js | 39 +++++++------- commands/Economy/money.js | 6 +-- commands/Economy/pay.js | 38 +++++++------- commands/Economy/profile.js | 11 ++-- commands/Economy/rep.js | 30 +++++------ commands/Economy/rob.js | 50 +++++++++--------- commands/Economy/setbio.js | 12 ++--- commands/Economy/slots.js | 70 +++++++++++++------------- commands/Economy/transactions.js | 15 +++--- commands/Economy/work.js | 45 +++++++++-------- commands/Fun/8ball.js | 1 - commands/Fun/cat.js | 1 - commands/Fun/dog.js | 1 - commands/Fun/lmgtfy.js | 1 - commands/Fun/lovecalc.js | 1 - commands/Fun/number.js | 1 - commands/Fun/tictactoe.js | 1 - commands/General/afk.js | 12 ++--- commands/General/avatar.c.js | 1 - commands/General/avatar.js | 1 - commands/General/boosters.js | 9 ++-- commands/General/emoji.js | 1 - commands/General/help.js | 3 ++ commands/General/minecraft.js | 1 - commands/General/ping.js | 1 - commands/General/remindme.js | 28 +++++------ commands/General/report.js | 6 +-- commands/General/serverinfo.js | 3 +- commands/General/shorturl.js | 1 - commands/General/stats.js | 1 - commands/General/suggest.js | 6 +-- commands/General/whois.js | 1 - commands/IAT/checkjar.js | 3 +- commands/Moderation/clear.js | 1 - commands/Moderation/clearwarns.js | 1 - commands/Moderation/giveaway.js | 1 - commands/Moderation/poll.js | 1 - commands/Moderation/unban.js | 1 - commands/Moderation/untimeout.js | 1 - commands/Moderation/warn.c.js | 9 ++-- commands/Moderation/warns.js | 1 - commands/Music/back.js | 1 - commands/Music/clips.js | 1 - commands/Music/loop.js | 1 - commands/Music/nowplaying.js | 19 ++++--- commands/Music/play.c.js | 1 - commands/Music/play.js | 1 - commands/Music/queue.js | 4 +- commands/Music/seek.js | 1 - commands/Music/shuffle.js | 1 - commands/Music/skip.js | 1 - commands/Music/skipto.js | 1 - commands/Music/stop.js | 1 - commands/Music/volume.js | 1 - commands/NSFW/nsfw.js | 6 ++- commands/Owner/debug.js | 1 - commands/Owner/eval.js | 4 +- commands/Owner/reload.js | 1 - commands/Owner/say.js | 1 - commands/Owner/servers.js | 1 - commands/Tickets/adduser.js | 1 - commands/Tickets/closeticket.js | 11 ++-- commands/Tickets/createticketembed.js | 21 ++++---- commands/Tickets/removeuser.js | 1 - events/CommandHandler.js | 41 +++++++++------ events/MessageHandler.js | 43 ++++++++-------- events/Monitoring/messageDelete.js | 2 +- events/Monitoring/messageUpdate.js | 2 +- helpers/checkReminds.js | 6 +-- helpers/extenders.js | 10 ++-- helpers/functions.js | 4 +- package.json | 2 +- 92 files changed, 428 insertions(+), 440 deletions(-) diff --git a/base/Client.js b/base/Client.js index aa093fe3..86a23d47 100644 --- a/base/Client.js +++ b/base/Client.js @@ -41,7 +41,7 @@ class JaBaClient extends Client { this.player.events.on("playerStart", async (queue, track) => { const m = ( await queue.metadata.channel.send({ - content: this.translate("music/play:NOW_PLAYING", { songName: track.title }, queue.metadata.channel.guild.data.language), + content: this.translate("music/play:NOW_PLAYING", { songName: track.title }, queue.metadata.data.guild.language), }) ).id; @@ -58,14 +58,14 @@ class JaBaClient extends Client { if (message && message.deletable) message.delete(); }, 5 * 60 * 1000); }); - this.player.events.on("emptyQueue", queue => queue.metadata.channel.send(this.translate("music/play:QUEUE_ENDED", null, queue.metadata.channel.guild.data.language))); - this.player.events.on("emptyChannel", queue => queue.metadata.channel.send(this.translate("music/play:STOP_EMPTY", null, queue.metadata.channel.guild.data.language))); + this.player.events.on("emptyQueue", queue => queue.metadata.channel.send(this.translate("music/play:QUEUE_ENDED", null, queue.metadata.data.guild.language))); + this.player.events.on("emptyChannel", queue => queue.metadata.channel.send(this.translate("music/play:STOP_EMPTY", null, queue.metadata.data.guild.language))); this.player.events.on("playerError", (queue, e) => { - queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.channel.guild.data.language) }); + queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.data.guild.language) }); console.log(e); }); this.player.events.on("error", (queue, e) => { - queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.channel.guild.data.language) }); + queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.data.guild.language) }); console.log(e); }); @@ -150,7 +150,7 @@ class JaBaClient extends Client { * @returns {String} Bot's default language */ get defaultLanguage() { - return this.languages.find(language => language.default).name; + return this.languages.find(language => language.default); } /** @@ -159,7 +159,7 @@ class JaBaClient extends Client { * @param {Array} args Arguments for translation * @param {String} locale Language */ - translate(key, args, locale = this.defaultLanguage) { + translate(key, args, locale = this.defaultLanguage.name) { const lang = this.translations.get(locale); return lang(key, args); @@ -224,7 +224,7 @@ class JaBaClient extends Client { } /** - * Unloads a command + * Removes a command from cache * @param {String} dir Directory where command is located * @param {String} name Command name * @returns diff --git a/commands/!DISABLED/ban.js b/commands/!DISABLED/ban.js index 50b4ae44..1dad1d88 100644 --- a/commands/!DISABLED/ban.js +++ b/commands/!DISABLED/ban.js @@ -46,7 +46,6 @@ class Ban extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/!DISABLED/importmee6.js b/commands/!DISABLED/importmee6.js index 2d86bbfd..ce413ffb 100644 --- a/commands/!DISABLED/importmee6.js +++ b/commands/!DISABLED/importmee6.js @@ -23,17 +23,18 @@ class ImportMee6 extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { + async execute(client, interaction) { await interaction.deferReply(); const level = (await Mee6Api.getUserXp(interaction.guildId, interaction.member)).level; - data.memberData.level = level; + interaction.data.member.level = level; + interaction.data.member.exp = 0; - data.memberData.markModified("level"); - await data.memberData.save(); + interaction.data.member.markModified("level"); + interaction.data.member.markModified("exp"); + await interaction.data.member.save(); interaction.editReply({ content: interaction.translate("owner/debug:SUCCESS_LEVEL", { diff --git a/commands/!DISABLED/kick.js b/commands/!DISABLED/kick.js index 8731dd8e..18c1b9d5 100644 --- a/commands/!DISABLED/kick.js +++ b/commands/!DISABLED/kick.js @@ -46,7 +46,6 @@ class Kick extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/!DISABLED/memes.js b/commands/!DISABLED/memes.js index 514f4fb3..f2caf243 100644 --- a/commands/!DISABLED/memes.js +++ b/commands/!DISABLED/memes.js @@ -33,6 +33,8 @@ class Memes extends BaseCommand { if (interaction.customId === "memes_select") { interaction.deferUpdate(); + interaction.guild.data = await client.findOrCreateGuild(interaction.guildId); + const tag = interaction.values[0]; const res = await fetch(`https://meme-api.com/gimme/${tag}`).then(response => response.json()); @@ -53,7 +55,6 @@ class Memes extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); diff --git a/commands/!DISABLED/staff.js b/commands/!DISABLED/staff.js index a3271d70..514bd04b 100644 --- a/commands/!DISABLED/staff.js +++ b/commands/!DISABLED/staff.js @@ -25,7 +25,6 @@ class Staff extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.guild.members.fetch(); diff --git a/commands/Administration/automod.js b/commands/Administration/automod.js index e7a22a31..cadff970 100644 --- a/commands/Administration/automod.js +++ b/commands/Administration/automod.js @@ -65,28 +65,28 @@ class Automod extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const state = interaction.options.getBoolean("state"), + async execute(client, interaction) { + const { data } = interaction, + state = interaction.options.getBoolean("state"), channel = interaction.options.getChannel("channel"), command = interaction.options.getSubcommand(); if (command === "toggle") { - data.guildData.plugins.automod = { + data.guild.plugins.automod = { enabled: state, ignored: [], }; - data.guildData.markModified("plugins.automod"); - await data.guildData.save(); + data.guild.markModified("plugins.automod"); + await data.guild.save(); interaction.success(`administration/automod:${state ? "ENABLED" : "DISABLED"}`); } else if (command === "ignore") { - data.guildData.plugins.automod.ignored.push(channel.id); + data.guild.plugins.automod.ignored.push(channel.id); - data.guildData.markModified("plugins.automod"); - await data.guildData.save(); + data.guild.markModified("plugins.automod"); + await data.guild.save(); interaction.success("administration/automod:DISABLED_CHANNEL", { channel: channel.toString(), diff --git a/commands/Administration/autorole.js b/commands/Administration/autorole.js index 442fe7e8..dbf86c63 100644 --- a/commands/Administration/autorole.js +++ b/commands/Administration/autorole.js @@ -45,29 +45,29 @@ class Autorole extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const state = interaction.options.getBoolean("state"), + async execute(client, interaction) { + const guildData = interaction.data.guild, + state = interaction.options.getBoolean("state"), role = interaction.options.getRole("role"); - data.guildData.plugins.autorole = { + guildData.plugins.autorole = { enabled: state, role, }; if (state && role) { - data.guildData.markModified("plugins.autorole"); - await data.guildData.save(); + guildData.markModified("plugins.autorole"); + await guildData.save(); interaction.success("administration/autorole:ENABLED", { role: role.toString(), }); } else { - data.guildData.plugins.autorole.enabled = false; + guildData.plugins.autorole.enabled = false; - data.guildData.markModified("plugins.autorole"); - await data.guildData.save(); + guildData.markModified("plugins.autorole"); + await guildData.save(); interaction.success("administration/autorole:DISABLED"); } diff --git a/commands/Administration/config.js b/commands/Administration/config.js index 14650b4e..5e5c9a72 100644 --- a/commands/Administration/config.js +++ b/commands/Administration/config.js @@ -84,14 +84,12 @@ class Config extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const command = interaction.options.getSubcommand(); + async execute(client, interaction) { + const guildData = interaction.data.guild, + command = interaction.options.getSubcommand(); if (command === "list") { - const guildData = data.guildData; - const embed = client.embed({ author: { name: interaction.guild.name, @@ -173,7 +171,7 @@ class Config extends BaseCommand { state = interaction.options.getBoolean("state"), channel = interaction.options.getChannel("channel"); - await changeSetting(interaction, setting, state, channel, data.guildData); + await changeSetting(interaction, setting, state, channel); } } } @@ -184,20 +182,20 @@ class Config extends BaseCommand { * @param {String} setting * @param {Boolean} state * @param {import("discord.js").GuildTextBasedChannel | import("discord.js").CategoryChannel} channel - * @param {import("../../base/Guild")} guildData * @returns */ -async function changeSetting(interaction, setting, state, channel, guildData) { - const settingSplitted = setting.split("."); +async function changeSetting(interaction, setting, state, channel) { + const settingSplitted = setting.split("."), + data = interaction.data.guild; if (settingSplitted.length === 2) { - if (guildData.plugins[settingSplitted[0]] === undefined) guildData.plugins[settingSplitted[0]] = {}; + if (data.plugins[settingSplitted[0]] === undefined) data.plugins[settingSplitted[0]] = {}; if (!state) { - guildData.plugins[settingSplitted[0]][settingSplitted[1]] = null; + data.plugins[settingSplitted[0]][settingSplitted[1]] = null; - guildData.markModified(`plugins.${settingSplitted[0]}`); - await guildData.save(); + data.markModified(`plugins.${settingSplitted[0]}`); + await data.save(); return interaction.reply({ content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`, @@ -207,10 +205,10 @@ async function changeSetting(interaction, setting, state, channel, guildData) { if (settingSplitted[1] === "ticketsCategory" && channel.type !== ChannelType.GuildCategory) return interaction.reply({ content: interaction.translate("administration/config:TICKETS_NOT_CATEGORY"), ephemeral: true }); if (channel) { - guildData.plugins[settingSplitted[0]][settingSplitted[1]] = channel.id; + data.plugins[settingSplitted[0]][settingSplitted[1]] = channel.id; - guildData.markModified(`plugins.${settingSplitted[0]}`); - await guildData.save(); + data.markModified(`plugins.${settingSplitted[0]}`); + await data.save(); return interaction.reply({ content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`, @@ -219,17 +217,17 @@ async function changeSetting(interaction, setting, state, channel, guildData) { } else return interaction.reply({ content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: ${ - guildData.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${guildData.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**` + data.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${data.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**` }`, ephemeral: true, }); } } else { if (!state) { - guildData.plugins[setting] = null; + data.plugins[setting] = null; - guildData.markModified(`plugins.${setting}`); - await guildData.save(); + data.markModified(`plugins.${setting}`); + await data.save(); return interaction.reply({ content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`, @@ -237,10 +235,10 @@ async function changeSetting(interaction, setting, state, channel, guildData) { }); } else { if (channel) { - guildData.plugins[setting] = channel.id; + data.plugins[setting] = channel.id; - guildData.markModified(`plugins.${setting}`); - await guildData.save(); + data.markModified(`plugins.${setting}`); + await data.save(); return interaction.reply({ content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`, @@ -249,7 +247,7 @@ async function changeSetting(interaction, setting, state, channel, guildData) { } else return interaction.reply({ content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: ${ - guildData.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${guildData.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**` + data.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${data.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**` }`, ephemeral: true, }); diff --git a/commands/Administration/goodbye.js b/commands/Administration/goodbye.js index 41af0f14..d0a8604c 100644 --- a/commands/Administration/goodbye.js +++ b/commands/Administration/goodbye.js @@ -81,10 +81,10 @@ class Goodbye extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const command = interaction.options.getSubcommand(); + async execute(client, interaction) { + const guildData = interaction.data.guild, + command = interaction.options.getSubcommand(); if (command === "test") { client.emit("guildMemberRemove", interaction.member); @@ -94,15 +94,15 @@ class Goodbye extends BaseCommand { const state = interaction.options.getBoolean("state"); if (!state) { - data.guildData.plugins.goodbye = { + guildData.plugins.goodbye = { enabled: false, message: null, channelID: null, withImage: null, }; - data.guildData.markModified("plugins.goodbye"); - await data.guildData.save(); + guildData.markModified("plugins.goodbye"); + await guildData.save(); interaction.success("administration/goodbye:DISABLED", null, { ephemeral: true }); } else { @@ -110,15 +110,15 @@ class Goodbye extends BaseCommand { const message = interaction.options.getString("message") || interaction.translate("administration/goodbye:DEFAULT_MESSAGE"); const image = interaction.options.getBoolean("image") === true ? true : false; - data.guildData.plugins.goodbye = { + guildData.plugins.goodbye = { enabled: true, channel: channel.id, message: message, withImage: image, }; - data.guildData.markModified("plugins.goodbye"); - await data.guildData.save(); + guildData.markModified("plugins.goodbye"); + await guildData.save(); interaction.success("administration/goodbye:ENABLED", { channel: `${channel.toString()}`, diff --git a/commands/Administration/selectroles.js b/commands/Administration/selectroles.js index 89214751..a7c9939d 100644 --- a/commands/Administration/selectroles.js +++ b/commands/Administration/selectroles.js @@ -89,6 +89,9 @@ class Selectroles extends BaseCommand { if (!interaction.isStringSelectMenu()) return; if (interaction.customId === "auto_roles") { + interaction.data = []; + interaction.data.guild = await client.findOrCreateGuild(interaction.guildId); + const removed = interaction.component.options.filter(option => { return !interaction.values.includes(option.value); }); @@ -113,7 +116,6 @@ class Selectroles extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); diff --git a/commands/Administration/set.js b/commands/Administration/set.js index a2bf01f1..e008b5df 100644 --- a/commands/Administration/set.js +++ b/commands/Administration/set.js @@ -62,7 +62,6 @@ class Set extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const type = interaction.options.getString("type"), diff --git a/commands/Administration/setlang.js b/commands/Administration/setlang.js index 126d662c..986718f0 100644 --- a/commands/Administration/setlang.js +++ b/commands/Administration/setlang.js @@ -37,16 +37,16 @@ class Setlang extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const lang = interaction.options.getString("language"), + async execute(client, interaction) { + const guildData = interaction.data.guild, + lang = interaction.options.getString("language"), language = client.languages.find(l => l.name === lang); - data.guildData.language = language.name; + guildData.language = language.name; - data.guildData.markModified("language"); - await data.guildData.save(); + guildData.markModified("language"); + await guildData.save(); return interaction.success("administration/setlang:SUCCESS", { lang: language.nativeName, diff --git a/commands/Administration/stealemoji.js b/commands/Administration/stealemoji.js index 39326590..529cab3c 100644 --- a/commands/Administration/stealemoji.js +++ b/commands/Administration/stealemoji.js @@ -36,16 +36,14 @@ class Stealemoji extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { - const parsedEmoji = parseEmoji(interaction.options.getString("emoji")), - ext = parsedEmoji.animated ? "gif" : "png"; + const parsedEmoji = parseEmoji(interaction.options.getString("emoji")); interaction.guild.emojis .create({ name: parsedEmoji.name, - attachment: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${ext}`, + attachment: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${parsedEmoji.animated ? "gif" : "png"}`, }) .then(emoji => interaction.success("administration/stealemoji:SUCCESS", { diff --git a/commands/Administration/welcome.js b/commands/Administration/welcome.js index 91a7cb6f..3c48f00a 100644 --- a/commands/Administration/welcome.js +++ b/commands/Administration/welcome.js @@ -81,10 +81,10 @@ class Welcome extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const command = interaction.options.getSubcommand(); + async execute(client, interaction) { + const guildData = interaction.data.guild, + command = interaction.options.getSubcommand(); if (command === "test") { client.emit("guildMemberAdd", interaction.member); @@ -94,15 +94,15 @@ class Welcome extends BaseCommand { const state = interaction.options.getBoolean("state"); if (!state) { - data.guildData.plugins.welcome = { + guildData.plugins.welcome = { enabled: false, message: null, channelID: null, withImage: null, }; - data.guildData.markModified("plugins.welcome"); - await data.guildData.save(); + guildData.markModified("plugins.welcome"); + await guildData.save(); interaction.success("administration/welcome:DISABLED", null, { ephemeral: true }); } else { @@ -110,15 +110,15 @@ class Welcome extends BaseCommand { const message = interaction.options.getString("message") || interaction.translate("administration/welcome:DEFAULT_MESSAGE"); const image = interaction.options.getBoolean("image") === true ? true : false; - data.guildData.plugins.welcome = { + guildData.plugins.welcome = { enabled: true, channel: channel.id, message: message, withImage: image, }; - data.guildData.markModified("plugins.welcome"); - await data.guildData.save(); + guildData.markModified("plugins.welcome"); + await guildData.save(); interaction.success("administration/welcome:ENABLED", { channel: `${channel.toString()}`, diff --git a/commands/Economy/achievements.js b/commands/Economy/achievements.js index 63c5f4dc..482d630c 100644 --- a/commands/Economy/achievements.js +++ b/commands/Economy/achievements.js @@ -34,13 +34,12 @@ class Achievements extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { + async execute(client, interaction) { const user = interaction.options.getUser("user") || interaction.member; if (user.bot) return interaction.error("economy/profile:BOT_USER"); - const userData = user.id === interaction.user.id ? data.userData : await client.findOrCreateUser(user.id); + const userData = user.id === interaction.user.id ? interaction.data.user : await client.findOrCreateUser(user.id); const embed = client.embed({ author: { diff --git a/commands/Economy/bank.js b/commands/Economy/bank.js index 3b89c06e..3d20db98 100644 --- a/commands/Economy/bank.js +++ b/commands/Economy/bank.js @@ -46,25 +46,26 @@ class Bank extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const choice = interaction.options.getString("option"); + async execute(client, interaction) { + const memberData = interaction.data.member, + choice = interaction.options.getString("option"); if (choice === "deposit") { - const credits = interaction.options.getString("credits").toLowerCase() === "all" ? data.memberData.money : interaction.options.getString("credits"); + const credits = interaction.options.getString("credits").toLowerCase() === "all" ? memberData.money : interaction.options.getString("credits"); + if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL"); - if (data.memberData.money < credits) + if (memberData.money < credits) return interaction.error("economy/bank:NOT_ENOUGH_CREDIT", { money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, }); - data.memberData.money -= credits; - data.memberData.bankSold += credits; + memberData.money -= credits; + memberData.bankSold += credits; - data.memberData.markModified("money"); - data.memberData.markModified("bankSold"); - await data.memberData.save(); + memberData.markModified("money"); + memberData.markModified("bankSold"); + await memberData.save(); const info = { user: interaction.translate("economy/transactions:BANK"), @@ -72,15 +73,16 @@ class Bank extends BaseCommand { date: Date.now(), type: "send", }; - data.memberData.transactions.push(info); + memberData.transactions.push(info); interaction.success("economy/bank:SUCCESS_DEP", { money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, }); } else { - const credits = interaction.options.getString("credits") === "all" ? data.memberData.bankSold : interaction.options.getString("credits"); + const credits = interaction.options.getString("credits") === "all" ? memberData.bankSold : interaction.options.getString("credits"); + if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL"); - if (data.memberData.bankSold < credits) + if (memberData.bankSold < credits) return interaction.error("economy/bank:NOT_ENOUGH_BANK", { money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, }); @@ -92,14 +94,14 @@ class Bank extends BaseCommand { type: "got", }; - data.memberData.transactions.push(info); + memberData.transactions.push(info); - data.memberData.money += credits; - data.memberData.bankSold -= credits; + memberData.money += credits; + memberData.bankSold -= credits; - data.memberData.markModified("money"); - data.memberData.markModified("bankSold"); - await data.memberData.save(); + memberData.markModified("money"); + memberData.markModified("bankSold"); + await memberData.save(); interaction.success("economy/bank:SUCCESS_WD", { money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, diff --git a/commands/Economy/birthdate.js b/commands/Economy/birthdate.js index cea21894..30bdb845 100644 --- a/commands/Economy/birthdate.js +++ b/commands/Economy/birthdate.js @@ -69,10 +69,10 @@ class Birthdate extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const day = interaction.options.getInteger("day"), + async execute(client, interaction) { + const userData = interaction.data.user, + day = interaction.options.getInteger("day"), month = interaction.options.getInteger("month"), year = interaction.options.getInteger("year"), date = new Date(year, month - 1, day), @@ -82,10 +82,10 @@ class Birthdate extends BaseCommand { if (date.getTime() > Date.now()) return interaction.error("economy/birthdate:DATE_TOO_HIGH"); if (date.getTime() < Date.now() - 2.523e12) return interaction.error("economy/birthdate:DATE_TOO_LOW"); - data.userData.birthdate = d; + userData.birthdate = d; - data.userData.markModified("birthdate"); - await data.userData.save(); + userData.markModified("birthdate"); + await userData.save(); interaction.success("economy/birthdate:SUCCESS", { date: ``, diff --git a/commands/Economy/divorce.js b/commands/Economy/divorce.js index 40e57699..a8aeb5ef 100644 --- a/commands/Economy/divorce.js +++ b/commands/Economy/divorce.js @@ -25,16 +25,17 @@ class Divorce extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - if (!data.userData.lover) return interaction.error("economy/divorce:NOT_MARRIED"); - const user = client.users.cache.get(data.userData.lover) || (await client.users.fetch(data.userData.lover)); + async execute(client, interaction) { + const userData = interaction.data.user; - data.userData.lover = null; + if (!userData.lover) return interaction.error("economy/divorce:NOT_MARRIED"); + const user = client.users.cache.get(userData.lover) || await client.users.fetch(userData.lover); - data.userData.markModified("lover"); - await data.userData.save(); + userData.lover = null; + + userData.markModified("lover"); + await userData.save(); const oldLover = await client.findOrCreateUser(user.id); oldLover.lover = null; @@ -46,11 +47,13 @@ class Divorce extends BaseCommand { user: user.toString(), }); - user.send({ - content: interaction.translate("economy/divorce:DIVORCED_U", { - user: interaction.member.toString(), - }), - }); + try { + user.send({ + content: interaction.translate("economy/divorce:DIVORCED_U", { + user: interaction.member.toString(), + }), + }); + } catch (e) { /**/ } } } diff --git a/commands/Economy/leaderboard.js b/commands/Economy/leaderboard.js index 450be9ce..8fa57dbb 100644 --- a/commands/Economy/leaderboard.js +++ b/commands/Economy/leaderboard.js @@ -36,7 +36,6 @@ class Leaderboard extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Economy/marry.js b/commands/Economy/marry.js index 7eccdb22..2df4131c 100644 --- a/commands/Economy/marry.js +++ b/commands/Economy/marry.js @@ -36,17 +36,18 @@ class Marry extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - if (data.userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED"); + async execute(client, interaction) { + const userData = interaction.data.user; + + if (userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED"); const member = interaction.options.getMember("user"); if (member.user.bot) return interaction.error("economy/marry:BOT_USER"); if (member.id === interaction.member.id) return interaction.error("economy/marry:YOURSELF"); - const userData = await client.findOrCreateUser(member.id); - if (userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED_USER", { user: member.toString() }); + const otherUserData = await client.findOrCreateUser(member.id); + if (otherUserData.lover) return interaction.error("economy/marry:ALREADY_MARRIED_USER", { user: member.toString() }); for (const requester in pendings) { const receiver = pendings[requester]; @@ -118,13 +119,13 @@ class Marry extends BaseCommand { } if (reason) { - data.userData.lover = member.id; - userData.lover = interaction.member.id; + userData.lover = member.id; + otherUserData.lover = interaction.member.id; - data.userData.markModified("lover"); userData.markModified("lover"); - await data.userData.save(); + otherUserData.markModified("lover"); await userData.save(); + await otherUserData.save(); const messageOptions = { content: `${member.toString()} :heart: ${interaction.member.toString()}`, @@ -137,9 +138,18 @@ class Marry extends BaseCommand { }; let sent = false; - if (!userData.achievements.married.achieved) { + if (!otherUserData.achievements.married.achieved) { interaction.followUp(messageOptions); sent = true; + otherUserData.achievements.married.achieved = true; + otherUserData.achievements.married.progress.now = 1; + + otherUserData.markModified("achievements"); + await otherUserData.save(); + } + + if (!userData.achievements.married.achieved) { + if (!sent) interaction.followUp(messageOptions); userData.achievements.married.achieved = true; userData.achievements.married.progress.now = 1; @@ -147,15 +157,6 @@ class Marry extends BaseCommand { await userData.save(); } - if (!data.userData.achievements.married.achieved) { - if (!sent) interaction.followUp(messageOptions); - data.userData.achievements.married.achieved = true; - data.userData.achievements.married.progress.now = 1; - - data.userData.markModified("achievements"); - await data.userData.save(); - } - return interaction.editReply({ content: interaction.translate("economy/marry:SUCCESS", { creator: interaction.member.toString(), diff --git a/commands/Economy/money.js b/commands/Economy/money.js index 594a9ac5..b15f7b56 100644 --- a/commands/Economy/money.js +++ b/commands/Economy/money.js @@ -34,17 +34,17 @@ class Money extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { + async execute(client, interaction) { await interaction.deferReply(); const member = interaction.options.getMember("user") || interaction.member; if (member.user.bot) return interaction.error("economy/money:BOT_USER"); - const memberData = member.id === interaction.user.id ? data.memberData : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId }); + const memberData = member.id === interaction.user.id ? interaction.data.member : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId }); const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id)); + let globalMoney = 0; await client.functions.asyncForEach(guilds, async guild => { const data = await client.findOrCreateMember({ diff --git a/commands/Economy/pay.js b/commands/Economy/pay.js index 545abae3..f31e1188 100644 --- a/commands/Economy/pay.js +++ b/commands/Economy/pay.js @@ -45,53 +45,53 @@ class Pay extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const member = interaction.options.getMember("user"); - if (member.user.bot) return interaction.error("economy/pay:BOT_USER"); - if (member.id === interaction.member.id) return interaction.error("economy/pay:YOURSELF"); + async execute(client, interaction) { + const memberData = interaction.data.member, + otherMember = interaction.options.getMember("user"); + if (otherMember.user.bot) return interaction.error("economy/pay:BOT_USER"); + if (otherMember.id === interaction.member.id) return interaction.error("economy/pay:YOURSELF"); const amount = interaction.options.getInteger("amount"); if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO"); - if (amount > data.memberData.money) + if (amount > memberData.money) return interaction.error("economy/pay:ENOUGH_MONEY", { amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDITS:1"), interaction.translate("misc:NOUNS:CREDITS:2"), interaction.translate("misc:NOUNS:CREDITS:5"))}`, }); - const memberData = await client.findOrCreateMember({ - id: member.id, + const otherMemberData = await client.findOrCreateMember({ + id: otherMember.id, guildId: interaction.guildId, }); - data.memberData.money -= amount; - - data.memberData.markModified("money"); - await data.memberData.save(); - - memberData.money += amount; + memberData.money -= amount; memberData.markModified("money"); await memberData.save(); + otherMemberData.money += amount; + + otherMemberData.markModified("money"); + await otherMemberData.save(); + const info1 = { - user: member.user.getUsername(), + user: otherMember.user.getUsername(), amount: amount, date: Date.now(), type: "send", }; - data.memberData.transactions.push(info1); + memberData.transactions.push(info1); const info2 = { - user: member.user.getUsername(), + user: otherMember.user.getUsername(), amount: amount, date: Date.now(), type: "got", }; - data.memberData.transactions.push(info2); + otherMemberData.transactions.push(info2); interaction.success("economy/pay:SUCCESS", { - user: member.toString(), + user: otherMember.toString(), amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, }); } diff --git a/commands/Economy/profile.js b/commands/Economy/profile.js index d6197e14..d6715167 100644 --- a/commands/Economy/profile.js +++ b/commands/Economy/profile.js @@ -34,16 +34,15 @@ class Profile extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { + async execute(client, interaction) { await interaction.deferReply(); const member = interaction.options.getMember("user") || interaction.member; if (member.user.bot) return interaction.error("economy/profile:BOT_USER"); - const memberData = member.id === interaction.user.id ? data.memberData : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId }); - const userData = member.id === interaction.user.id ? data.userData : await client.findOrCreateUser(member.id); + const memberData = member.id === interaction.user.id ? interaction.data.member : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId }); + const userData = member.id === interaction.user.id ? interaction.data.user : await client.findOrCreateUser(member.id); if (userData.lover && !client.users.cache.find(u => u.id === userData.lover)) await client.users.fetch(userData.lover, true); const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id)); @@ -123,14 +122,14 @@ class Profile extends BaseCommand { ], }); - const buffer = await userData.getAchievements(); + const achievements = await userData.getAchievements(); interaction.editReply({ embeds: [embed], files: [ { name: "achievements.png", - attachment: buffer, + attachment: achievements, }, ], }); diff --git a/commands/Economy/rep.js b/commands/Economy/rep.js index ac01f5ed..083660e4 100644 --- a/commands/Economy/rep.js +++ b/commands/Economy/rep.js @@ -35,10 +35,10 @@ class Rep extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const isInCooldown = data.userData.cooldowns?.rep; + async execute(client, interaction) { + const userData = interaction.data.user, + isInCooldown = userData.cooldowns?.rep; if (isInCooldown) { if (isInCooldown > Date.now()) @@ -52,21 +52,21 @@ class Rep extends BaseCommand { if (user.id === interaction.user.id) return interaction.error("economy/rep:YOURSELF"); const toWait = Math.floor((Date.now() + 12 * 60 * 60 * 1000) / 1000); // 12 hours - if (!data.userData.cooldowns) data.userData.cooldowns = {}; + if (!userData.cooldowns) userData.cooldowns = {}; - data.userData.cooldowns.rep = toWait; + userData.cooldowns.rep = toWait; - data.userData.markModified("cooldowns"); - await data.userData.save(); + userData.markModified("cooldowns"); + await userData.save(); - const userData = await client.findOrCreateUser(user.id); + const otherUserData = await client.findOrCreateUser(user.id); - userData.rep++; + otherUserData.rep++; - if (!userData.achievements.rep.achieved) { - userData.achievements.rep.progress.now = userData.rep > userData.achievements.rep.progress.total ? userData.achievements.rep.progress.total : userData.rep; - if (userData.achievements.rep.progress.now >= userData.achievements.rep.progress.total) { - userData.achievements.rep.achieved = true; + if (!otherUserData.achievements.rep.achieved) { + otherUserData.achievements.rep.progress.now = otherUserData.rep > otherUserData.achievements.rep.progress.total ? otherUserData.achievements.rep.progress.total : otherUserData.rep; + if (otherUserData.achievements.rep.progress.now >= otherUserData.achievements.rep.progress.total) { + otherUserData.achievements.rep.achieved = true; interaction.followUp({ content: `${user}`, files: [ @@ -79,8 +79,8 @@ class Rep extends BaseCommand { } } - userData.markModified("rep"); - await userData.save(); + otherUserData.markModified("rep"); + await otherUserData.save(); interaction.success("economy/rep:SUCCESS", { user: user.toString(), diff --git a/commands/Economy/rob.js b/commands/Economy/rob.js index cacfcc61..77437e36 100644 --- a/commands/Economy/rob.js +++ b/commands/Economy/rob.js @@ -45,32 +45,32 @@ class Rob extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const member = interaction.options.getMember("user"); - if (member.user.bot) return interaction.error("economy/pay:BOT_USER"); - if (member.id === interaction.member.id) return interaction.error("economy/rob:YOURSELF"); + async execute(client, interaction) { + const memberData = interaction.data.member, + otherMember = interaction.options.getMember("user"); + if (otherMember.user.bot) return interaction.error("economy/pay:BOT_USER"); + if (otherMember.id === interaction.member.id) return interaction.error("economy/rob:YOURSELF"); const amount = interaction.options.getInteger("amount"); if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO"); - const memberData = await client.findOrCreateMember({ - id: member.id, + const otherMemberData = await client.findOrCreateMember({ + id: otherMember.id, guildId: interaction.guildId, }); - if (amount > memberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: member.toString() }); + if (amount > otherMemberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: otherMember.toString() }); - const isInCooldown = memberData.cooldowns.rob || 0; + const isInCooldown = otherMemberData.cooldowns.rob || 0; if (isInCooldown) { - if (isInCooldown > Date.now()) return interaction.error("economy/rob:COOLDOWN", { user: member.toString() }); + if (isInCooldown > Date.now()) return interaction.error("economy/rob:COOLDOWN", { user: otherMember.toString() }); } const potentiallyLose = Math.floor(amount * 1.5); - if (potentiallyLose > data.memberData.money) + if (potentiallyLose > memberData.money) return interaction.error("economy/rob:NOT_ENOUGH_AUTHOR", { moneyMin: `**${potentiallyLose}** ${client.functions.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, - moneyCurrent: `**${data.memberData.money}** ${client.functions.getNoun(data.memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + moneyCurrent: `**${memberData.money}** ${client.functions.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, }); const itsAWon = Math.floor(client.functions.randomNum(0, 100) < 25); @@ -79,23 +79,23 @@ class Rob extends BaseCommand { const toWait = Date.now() + 6 * 60 * 60 * 1000, randomNum = client.functions.randomNum(1, 2); - memberData.cooldowns.rob = toWait; + otherMemberData.cooldowns.rob = toWait; - memberData.markModified("cooldowns"); - await memberData.save(); + otherMemberData.markModified("cooldowns"); + await otherMemberData.save(); interaction.replyT("economy/rob:ROB_WON_" + randomNum, { money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, - user: member.toString(), + user: otherMember.toString(), }); - data.memberData.money += amount; - memberData.money -= amount; + memberData.money += amount; + otherMemberData.money -= amount; - data.memberData.markModified("money"); memberData.markModified("money"); - await data.memberData.save(); + otherMemberData.markModified("money"); await memberData.save(); + await otherMemberData.save(); } else { const won = Math.floor(amount * 0.9), randomNum = client.functions.randomNum(1, 2); @@ -103,16 +103,16 @@ class Rob extends BaseCommand { interaction.replyT("economy/rob:ROB_LOSE_" + randomNum, { fine: `**${potentiallyLose}** ${client.functions.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, offset: `**${won}** ${client.functions.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, - user: member.toString(), + user: otherMember.toString(), }); - data.memberData.money -= potentiallyLose; - memberData.money += won; + memberData.money -= potentiallyLose; + otherMemberData.money += won; - data.memberData.markModified("money"); memberData.markModified("money"); - await data.memberData.save(); + otherMemberData.markModified("money"); await memberData.save(); + await otherMemberData.save(); } } } diff --git a/commands/Economy/setbio.js b/commands/Economy/setbio.js index e9315fd2..6b3eeb6f 100644 --- a/commands/Economy/setbio.js +++ b/commands/Economy/setbio.js @@ -35,16 +35,16 @@ class Setbio extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const newBio = interaction.options.getString("text"); + async execute(client, interaction) { + const userData = interaction.data.user, + newBio = interaction.options.getString("text"); if (newBio.length > 150) return interaction.error("economy/setbio:MAX_CHARACTERS"); - data.userData.bio = newBio; + userData.bio = newBio; - data.userData.markModified("bio"); - await data.userData.save(); + userData.markModified("bio"); + await userData.save(); interaction.success("economy/setbio:SUCCESS"); } diff --git a/commands/Economy/slots.js b/commands/Economy/slots.js index d935d4c7..f94a5a82 100644 --- a/commands/Economy/slots.js +++ b/commands/Economy/slots.js @@ -35,13 +35,13 @@ class Slots extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { + async execute(client, interaction) { await interaction.deferReply(); - const amount = interaction.options.getInteger("amount"); - if (amount > data.memberData.money) + const { member: memberData, user: userData } = interaction.data, + amount = interaction.options.getInteger("amount"); + if (amount > memberData.money) return interaction.error("economy/slots:NOT_ENOUGH", { money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, }, { edit: true }); @@ -119,13 +119,13 @@ class Slots extends BaseCommand { type: "got", }; - data.memberData.money += toAdd; - data.memberData.transactions.push(info); + memberData.money += toAdd; + memberData.transactions.push(info); - if (!data.userData.achievements.slots.achieved) { - data.userData.achievements.slots.progress.now += 1; - if (data.userData.achievements.slots.progress.now === data.userData.achievements.slots.progress.total) { - data.userData.achievements.slots.achieved = true; + if (!userData.achievements.slots.achieved) { + userData.achievements.slots.progress.now += 1; + if (userData.achievements.slots.progress.now === userData.achievements.slots.progress.total) { + userData.achievements.slots.achieved = true; interaction.followUp({ files: [ { @@ -136,13 +136,13 @@ class Slots extends BaseCommand { }); } - data.userData.markModified("achievements"); - await data.userData.save(); + userData.markModified("achievements"); + await userData.save(); } - data.memberData.markModified("money"); - data.memberData.markModified("transactions"); - await data.memberData.save(); + memberData.markModified("money"); + memberData.markModified("transactions"); + await memberData.save(); return; } @@ -170,13 +170,13 @@ class Slots extends BaseCommand { type: "got", }; - data.memberData.money += toAdd; - data.memberData.transactions.push(info); + memberData.money += toAdd; + memberData.transactions.push(info); - if (!data.userData.achievements.slots.achieved) { - data.userData.achievements.slots.progress.now += 1; - if (data.userData.achievements.slots.progress.now === data.userData.achievements.slots.progress.total) { - data.userData.achievements.slots.achieved = true; + if (!userData.achievements.slots.achieved) { + userData.achievements.slots.progress.now += 1; + if (userData.achievements.slots.progress.now === userData.achievements.slots.progress.total) { + userData.achievements.slots.achieved = true; interaction.followUp({ files: [ { @@ -187,13 +187,13 @@ class Slots extends BaseCommand { }); } - data.userData.markModified("achievements"); - await data.userData.save(); + userData.markModified("achievements"); + await userData.save(); } - data.memberData.markModified("money"); - data.memberData.markModified("transactions"); - await data.memberData.save(); + memberData.markModified("money"); + memberData.markModified("transactions"); + await memberData.save(); return; } @@ -213,19 +213,19 @@ class Slots extends BaseCommand { type: "send", }; - data.memberData.money -= amount; - data.memberData.transactions.push(info); + memberData.money -= amount; + memberData.transactions.push(info); - if (!data.userData.achievements.slots.achieved) { - data.userData.achievements.slots.progress.now = 0; + if (!userData.achievements.slots.achieved) { + userData.achievements.slots.progress.now = 0; - data.userData.markModified("achievements"); - await data.userData.save(); + userData.markModified("achievements"); + await userData.save(); } - data.memberData.markModified("money"); - data.memberData.markModified("transactions"); - await data.memberData.save(); + memberData.markModified("money"); + memberData.markModified("transactions"); + await memberData.save(); return; } diff --git a/commands/Economy/transactions.js b/commands/Economy/transactions.js index b62b66ce..9af4932b 100644 --- a/commands/Economy/transactions.js +++ b/commands/Economy/transactions.js @@ -34,14 +34,15 @@ class Transactions extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - if (interaction.options.getBoolean("clear")) { - data.memberData.transactions = []; + async execute(client, interaction) { + const memberData = interaction.data.member; - data.memberData.markModified("transactions"); - await data.memberData.save(); + if (interaction.options.getBoolean("clear")) { + memberData.transactions = []; + + memberData.markModified("transactions"); + await memberData.save(); return interaction.success("economy/transactions:CLEARED", null, { ephemeral: true }); } @@ -52,7 +53,7 @@ class Transactions extends BaseCommand { iconURL: interaction.member.displayAvatarURL(), }, }); - const transactions = data.memberData.transactions, + const transactions = memberData.transactions, sortedTransactions = [[], []]; transactions.slice(-20).forEach(t => { diff --git a/commands/Economy/work.js b/commands/Economy/work.js index 6eae04fb..f67a3bb0 100644 --- a/commands/Economy/work.js +++ b/commands/Economy/work.js @@ -25,10 +25,10 @@ class Work extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const isInCooldown = data.memberData.cooldowns?.work; + async execute(client, interaction) { + const { member: memberData, user: userData } = interaction.data, + isInCooldown = memberData.cooldowns?.work; if (isInCooldown) { if (isInCooldown > Date.now()) @@ -37,15 +37,15 @@ class Work extends BaseCommand { }); } - if (Date.now() > data.memberData.cooldowns.work + 24 * 60 * 60 * 1000) data.memberData.workStreak = 0; + if (Date.now() > memberData.cooldowns.work + 24 * 60 * 60 * 1000) memberData.workStreak = 0; const toWait = Math.floor((Date.now() + 24 * 60 * 60 * 1000) / 1000); // 24 hours - data.memberData.cooldowns.work = toWait; - data.memberData.workStreak = (data.memberData.workStreak || 0) + 1; + memberData.cooldowns.work = toWait; + memberData.workStreak = (memberData.workStreak || 0) + 1; - data.memberData.markModified("cooldowns"); - data.memberData.markModified("workStreak"); - await data.memberData.save(); + memberData.markModified("cooldowns"); + memberData.markModified("workStreak"); + await memberData.save(); const embed = client.embed({ footer: { @@ -57,7 +57,7 @@ class Work extends BaseCommand { const award = [client.customEmojis.letters.a, client.customEmojis.letters.w, client.customEmojis.letters.a, client.customEmojis.letters.r, client.customEmojis.letters.d]; let won = 200; - if (data.memberData.workStreak >= 5) { + if (memberData.workStreak >= 5) { won += 200; embed.fields = [ { @@ -71,10 +71,11 @@ class Work extends BaseCommand { value: interaction.translate("economy/work:STREAK_CONTENT"), }, ]; - data.memberData.workStreak = 0; + + memberData.workStreak = 0; } else { for (let i = 0; i < award.length; i++) { - if (data.memberData.workStreak > i) { + if (memberData.workStreak > i) { const letter = parseEmoji(award[i]).name.split("_")[1]; award[i] = `:regional_indicator_${letter.toLowerCase()}:`; } @@ -93,10 +94,10 @@ class Work extends BaseCommand { ]; } - data.memberData.money += won; + memberData.money += won; - data.memberData.markModified("money"); - await data.memberData.save(); + memberData.markModified("money"); + await memberData.save(); const info = { user: interaction.translate("economy/work:SALARY"), @@ -104,26 +105,26 @@ class Work extends BaseCommand { date: Date.now(), type: "got", }; - data.memberData.transactions.push(info); + memberData.transactions.push(info); const messageOptions = { embeds: [embed], }; - if (!data.userData.achievements.work.achieved) { - data.userData.achievements.work.progress.now += 1; - if (data.userData.achievements.work.progress.now === data.userData.achievements.work.progress.total) { + if (!userData.achievements.work.achieved) { + userData.achievements.work.progress.now += 1; + if (userData.achievements.work.progress.now === userData.achievements.work.progress.total) { messageOptions.files = [ { name: "unlocked.png", attachment: "./assets/img/achievements/achievement_unlocked1.png", }, ]; - data.userData.achievements.work.achieved = true; + userData.achievements.work.achieved = true; } - data.userData.markModified("achievements"); - await data.userData.save(); + userData.markModified("achievements"); + await userData.save(); } interaction.reply(messageOptions); diff --git a/commands/Fun/8ball.js b/commands/Fun/8ball.js index d03c794e..83748b9f 100644 --- a/commands/Fun/8ball.js +++ b/commands/Fun/8ball.js @@ -35,7 +35,6 @@ class Eightball extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Fun/cat.js b/commands/Fun/cat.js index 935d4779..d28c3607 100644 --- a/commands/Fun/cat.js +++ b/commands/Fun/cat.js @@ -26,7 +26,6 @@ class Cat extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Fun/dog.js b/commands/Fun/dog.js index 3125cc32..1330040c 100644 --- a/commands/Fun/dog.js +++ b/commands/Fun/dog.js @@ -26,7 +26,6 @@ class Dog extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Fun/lmgtfy.js b/commands/Fun/lmgtfy.js index ac3ae493..f1f31344 100644 --- a/commands/Fun/lmgtfy.js +++ b/commands/Fun/lmgtfy.js @@ -46,7 +46,6 @@ class LMGTFY extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); diff --git a/commands/Fun/lovecalc.js b/commands/Fun/lovecalc.js index 65699ba7..0e6bed61 100644 --- a/commands/Fun/lovecalc.js +++ b/commands/Fun/lovecalc.js @@ -45,7 +45,6 @@ class Lovecalc extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const firstMember = interaction.options.getMember("first_member"), diff --git a/commands/Fun/number.js b/commands/Fun/number.js index ee782044..0c12b27d 100644 --- a/commands/Fun/number.js +++ b/commands/Fun/number.js @@ -26,7 +26,6 @@ class Number extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction, data) { if (currentGames[interaction.guildId]) return interaction.error("fun/number:GAME_RUNNING"); diff --git a/commands/Fun/tictactoe.js b/commands/Fun/tictactoe.js index c6a4a21c..282e6af5 100644 --- a/commands/Fun/tictactoe.js +++ b/commands/Fun/tictactoe.js @@ -36,7 +36,6 @@ class TicTacToe extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { tictactoe(interaction, { diff --git a/commands/General/afk.js b/commands/General/afk.js index 05d48e73..8801dec7 100644 --- a/commands/General/afk.js +++ b/commands/General/afk.js @@ -35,17 +35,17 @@ class Afk extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { + async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); - const reason = interaction.options.getString("message"); + const userData = interaction.data.user, + reason = interaction.options.getString("message"); - data.userData.afk = reason; + userData.afk = reason; - data.userData.markModified("afk"); - await data.userData.save(); + userData.markModified("afk"); + await userData.save(); interaction.success("general/afk:SUCCESS", { reason, diff --git a/commands/General/avatar.c.js b/commands/General/avatar.c.js index 420518f6..5a684bac 100644 --- a/commands/General/avatar.c.js +++ b/commands/General/avatar.c.js @@ -21,7 +21,6 @@ class AvatarContext extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").UserContextMenuCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const avatarURL = interaction.targetUser.displayAvatarURL({ size: 2048 }); diff --git a/commands/General/avatar.js b/commands/General/avatar.js index 900e281d..58ceb977 100644 --- a/commands/General/avatar.js +++ b/commands/General/avatar.js @@ -43,7 +43,6 @@ class Avatar extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const member = interaction.options.getMember("user") || interaction.member; diff --git a/commands/General/boosters.js b/commands/General/boosters.js index 4f388e2c..3429bf4f 100644 --- a/commands/General/boosters.js +++ b/commands/General/boosters.js @@ -30,9 +30,11 @@ class Boosters extends BaseCommand { if (!interaction.isButton()) return; if (interaction.customId.startsWith("boosters_")) { - const guildData = client.findOrCreateGuild(interaction.guildId), - boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince), - embeds = generateBoostersEmbeds(client, interaction, boosters, guildData); + interaction.data = []; + interaction.data.guild = await client.findOrCreateGuild(interaction.guildId); + + const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince), + embeds = generateBoostersEmbeds(client, interaction, boosters); const row = new ActionRowBuilder().addComponents( new ButtonBuilder().setCustomId("boosters_prev_page").setStyle(ButtonStyle.Primary).setEmoji("⬅️"), @@ -115,7 +117,6 @@ class Boosters extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/General/emoji.js b/commands/General/emoji.js index 9b287658..0a3857da 100644 --- a/commands/General/emoji.js +++ b/commands/General/emoji.js @@ -35,7 +35,6 @@ class Emoji extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const rawEmoji = interaction.options.getString("emoji"); diff --git a/commands/General/help.js b/commands/General/help.js index 3288c1ea..edc26808 100644 --- a/commands/General/help.js +++ b/commands/General/help.js @@ -42,6 +42,9 @@ class Help extends BaseCommand { if (interaction.customId === "help_category_select") { await interaction.deferUpdate(); + interaction.data = []; + interaction.data.guild = await client.findOrCreateGuild(interaction.guildId); + const arg = interaction?.values[0]; const categoryCommands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()] .filter(cmd => cmd.category === arg) diff --git a/commands/General/minecraft.js b/commands/General/minecraft.js index 6251bab6..b7dfab36 100644 --- a/commands/General/minecraft.js +++ b/commands/General/minecraft.js @@ -36,7 +36,6 @@ class Minecraft extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/General/ping.js b/commands/General/ping.js index 4244ed82..6a08a6ca 100644 --- a/commands/General/ping.js +++ b/commands/General/ping.js @@ -25,7 +25,6 @@ class Ping extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const embed = client.embed({ diff --git a/commands/General/remindme.js b/commands/General/remindme.js index 8d81d654..68efa439 100644 --- a/commands/General/remindme.js +++ b/commands/General/remindme.js @@ -1,7 +1,6 @@ const { SlashCommandBuilder } = require("discord.js"); const BaseCommand = require("../../base/BaseCommand"), - ms = require("ms"), - moment = require("moment"); + ms = require("ms"); class Remindme extends BaseCommand { /** @@ -47,38 +46,39 @@ class Remindme extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { + async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); - if (!data.userData.reminds) data.userData.reminds = []; + const userData = interaction.data.user; + + if (!userData.reminds) userData.reminds = []; const dateNow = Date.now(); - const reminderData = { + const reminder = { message: interaction.options.getString("message"), - createdAt: dateNow, - sendAt: dateNow + ms(interaction.options.getString("time")), + createdAt: Math.floor(dateNow / 1000), + sendAt: Math.floor((dateNow + ms(interaction.options.getString("time"))) / 1000), }; - data.userData.reminds.push(reminderData); + userData.reminds.push(reminder); - data.userData.markModified("reminds"); - await data.userData.save(); + userData.markModified("reminds"); + await userData.save(); - client.databaseCache.usersReminds.set(interaction.user.id, data.userData); + client.databaseCache.usersReminds.set(interaction.user.id, userData); const embed = client.embed({ author: interaction.translate("general/remindme:EMBED_SAVED"), fields: [ { name: interaction.translate("general/remindme:EMBED_TIME"), - value: moment(reminderData.sendAt).locale(interaction.getLocale()).format("Do MMMM YYYY, HH:mm:ss"), + value: ``, }, { name: interaction.translate("common:MESSAGE"), - value: reminderData.message, + value: reminder.message, }, ], }); diff --git a/commands/General/report.js b/commands/General/report.js index 98095052..f6e67634 100644 --- a/commands/General/report.js +++ b/commands/General/report.js @@ -45,10 +45,10 @@ class Report extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const repChannel = interaction.guild.channels.cache.get(data.guildData.plugins.reports); + async execute(client, interaction) { + const guildData = interaction.data.guild, + repChannel = interaction.guild.channels.cache.get(guildData.plugins.reports); if (!repChannel) return interaction.error("general/report:MISSING_CHANNEL"); const member = interaction.options.getMember("user"); diff --git a/commands/General/serverinfo.js b/commands/General/serverinfo.js index 11a335d6..601a8af4 100644 --- a/commands/General/serverinfo.js +++ b/commands/General/serverinfo.js @@ -25,10 +25,9 @@ class Serverinfo extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { - const guild = interaction.guild; + const { guild } = interaction; await guild.members.fetch(); const owner = await guild.fetchOwner(); diff --git a/commands/General/shorturl.js b/commands/General/shorturl.js index 2a15135d..c8344184 100644 --- a/commands/General/shorturl.js +++ b/commands/General/shorturl.js @@ -36,7 +36,6 @@ class Shorturl extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const url = interaction.options.getString("url"); diff --git a/commands/General/stats.js b/commands/General/stats.js index 2a766074..204e7392 100644 --- a/commands/General/stats.js +++ b/commands/General/stats.js @@ -25,7 +25,6 @@ class Stats extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount; diff --git a/commands/General/suggest.js b/commands/General/suggest.js index d7fd40f2..02001214 100644 --- a/commands/General/suggest.js +++ b/commands/General/suggest.js @@ -35,10 +35,10 @@ class Suggest extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - const channel = interaction.guild.channels.cache.get(data.guildData.plugins.suggestions); + async execute(client, interaction) { + const guildData = interaction.data.guild, + channel = interaction.guild.channels.cache.get(guildData.plugins.suggestions); if (!channel) return interaction.error("general/suggest:MISSING_CHANNEL"); const suggestion = interaction.options.getString("message"); diff --git a/commands/General/whois.js b/commands/General/whois.js index 25b7ee05..834018c9 100644 --- a/commands/General/whois.js +++ b/commands/General/whois.js @@ -36,7 +36,6 @@ class Whois extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/IAT/checkjar.js b/commands/IAT/checkjar.js index ec9c79ec..22e14086 100644 --- a/commands/IAT/checkjar.js +++ b/commands/IAT/checkjar.js @@ -55,12 +55,13 @@ class Checkjar extends BaseCommand { jarTransactions.length = 10; jarTransactions.forEach(t => { + // TODO const time = moment.unix(t.time); embed.data.fields.push([ { name: `${t.description}`, - value: `Дата: ${time.locale("uk-UA").format("DD MMMM YYYY, HH:mm")}\nСумма: ${t.amount / Math.pow(10, 2)} грн`, + value: `Дата: \nСумма: ${t.amount / Math.pow(10, 2)} грн`, }, ]); }); diff --git a/commands/Moderation/clear.js b/commands/Moderation/clear.js index c1f2c7a7..092d1d79 100644 --- a/commands/Moderation/clear.js +++ b/commands/Moderation/clear.js @@ -54,7 +54,6 @@ class Clear extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); diff --git a/commands/Moderation/clearwarns.js b/commands/Moderation/clearwarns.js index fbf09f97..a5de0e82 100644 --- a/commands/Moderation/clearwarns.js +++ b/commands/Moderation/clearwarns.js @@ -36,7 +36,6 @@ class Clearwarns extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const member = interaction.options.getMember("user"); diff --git a/commands/Moderation/giveaway.js b/commands/Moderation/giveaway.js index ad08246d..227cb672 100644 --- a/commands/Moderation/giveaway.js +++ b/commands/Moderation/giveaway.js @@ -133,7 +133,6 @@ class Giveaway extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const command = interaction.options.getSubcommand(); diff --git a/commands/Moderation/poll.js b/commands/Moderation/poll.js index 4e210d4a..0e623093 100644 --- a/commands/Moderation/poll.js +++ b/commands/Moderation/poll.js @@ -36,7 +36,6 @@ class Poll extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const question = interaction.options.getString("question"); diff --git a/commands/Moderation/unban.js b/commands/Moderation/unban.js index 510e9514..6c042d78 100644 --- a/commands/Moderation/unban.js +++ b/commands/Moderation/unban.js @@ -36,7 +36,6 @@ class Unban extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const id = interaction.options.getString("user_id"), diff --git a/commands/Moderation/untimeout.js b/commands/Moderation/untimeout.js index edf14a40..80ace0c9 100644 --- a/commands/Moderation/untimeout.js +++ b/commands/Moderation/untimeout.js @@ -36,7 +36,6 @@ class Ban extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Moderation/warn.c.js b/commands/Moderation/warn.c.js index ecd8d6e0..6d8c84a9 100644 --- a/commands/Moderation/warn.c.js +++ b/commands/Moderation/warn.c.js @@ -22,9 +22,8 @@ class WarnContext extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").UserContextMenuCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { + async execute(client, interaction) { const member = interaction.targetMember, memberPosition = member.roles.highest.position, moderationPosition = interaction.member.roles.highest.position; @@ -180,8 +179,10 @@ class WarnContext extends BaseCommand { memberData.markModified("sanctions"); await memberData.save(); - if (data.guildData.plugins.modlogs) { - const channel = interaction.guild.channels.cache.get(data.guildData.plugins.modlogs); + const guildData = interaction.data.guild; + + if (guildData.plugins.modlogs) { + const channel = interaction.guild.channels.cache.get(guildData.plugins.modlogs); if (!channel) return; channel.send({ diff --git a/commands/Moderation/warns.js b/commands/Moderation/warns.js index 75bb539d..3a121e48 100644 --- a/commands/Moderation/warns.js +++ b/commands/Moderation/warns.js @@ -36,7 +36,6 @@ class Warns extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const member = interaction.options.getMember("user"); diff --git a/commands/Music/back.js b/commands/Music/back.js index 87fa1eb0..71307d25 100644 --- a/commands/Music/back.js +++ b/commands/Music/back.js @@ -25,7 +25,6 @@ class Back extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/Music/clips.js b/commands/Music/clips.js index 32d391d1..87dd5ffd 100644 --- a/commands/Music/clips.js +++ b/commands/Music/clips.js @@ -38,7 +38,6 @@ class Clips extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Music/loop.js b/commands/Music/loop.js index f4ff743e..00519b71 100644 --- a/commands/Music/loop.js +++ b/commands/Music/loop.js @@ -42,7 +42,6 @@ class Loop extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/Music/nowplaying.js b/commands/Music/nowplaying.js index c43223cd..84e42798 100644 --- a/commands/Music/nowplaying.js +++ b/commands/Music/nowplaying.js @@ -31,6 +31,9 @@ class Nowplaying extends BaseCommand { if (!interaction.isButton()) return; if (interaction.customId.startsWith("nowp_")) { + interaction.data = []; + interaction.data.guild = await client.findOrCreateGuild(interaction.guildId); + const voice = interaction.member.voice.channel; if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL"); @@ -119,19 +122,22 @@ class Nowplaying extends BaseCommand { ephemeral: true, }); - // TODO Fix error in collected if user doesnt send anything const filter = m => m.author.id === interaction.user.id && m.content.startsWith("http"), - collected = (await interaction.channel.awaitMessages({ filter, time: 10 * 1000, max: 1 })).first(), + collect = await interaction.channel.awaitMessages({ filter, time: 10 * 1000, max: 1 }); + if (collect.size < 1) return; + + + const collected = collect.first(), query = collected.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g)[0], searchResult = await client.player.search(query, { requestedBy: interaction.user, }); + if (collected.deletable) collected.delete(); + if (!searchResult.hasTracks()) return interaction.error("music/play:NO_RESULT", { query: query }, { edit: true }); else queue.addTrack(searchResult); - if (collected.deletable) collected.delete(); - await interaction.followUp({ content: interaction.translate("music/play:ADDED_QUEUE", { songName: searchResult.hasPlaylist() ? searchResult.playlist.title : searchResult.tracks[0].title, @@ -221,7 +227,7 @@ class Nowplaying extends BaseCommand { components: [row1, row2], }); } else clearInterval(i); - }, 1 * 60 * 1000); + }, 60 * 1000); } } @@ -234,7 +240,6 @@ class Nowplaying extends BaseCommand { async function updateEmbed(interaction, queue) { const progressBar = queue.node.createProgressBar(), track = queue.currentTrack, - data = await interaction.client.guildsData.findOne({ id: interaction.guildId }), mode = queue.repeatMode === QueueRepeatMode.AUTOPLAY ? "3" : queue.repeatMode === QueueRepeatMode.QUEUE ? "2" : queue.repeatMode === QueueRepeatMode.TRACK ? "1" : "0", translated = { "3": interaction.translate("music/loop:AUTOPLAY"), @@ -260,7 +265,7 @@ async function updateEmbed(interaction, queue) { { name: "\u200B", value: "\u200B", inline: true }, { name: interaction.translate("common:VIEWS"), - value: track.raw.live ? "Live" : new Intl.NumberFormat(interaction.client.languages.find(language => language.name === data.language).moment, { notation: "standard" }).format(track.raw.views), + value: track.raw.live ? "Live" : new Intl.NumberFormat(interaction.client.defaultLanguage.moment, { notation: "standard" }).format(track.raw.views), inline: true, }, { diff --git a/commands/Music/play.c.js b/commands/Music/play.c.js index 4869abae..7c57fa97 100644 --- a/commands/Music/play.c.js +++ b/commands/Music/play.c.js @@ -21,7 +21,6 @@ class PlayContext extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").MessageContextMenuCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Music/play.js b/commands/Music/play.js index 6d29d9ab..94c387da 100644 --- a/commands/Music/play.js +++ b/commands/Music/play.js @@ -37,7 +37,6 @@ class Play extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Music/queue.js b/commands/Music/queue.js index d49529a8..f39b9aba 100644 --- a/commands/Music/queue.js +++ b/commands/Music/queue.js @@ -30,6 +30,9 @@ class Queue extends BaseCommand { if (!interaction.isButton()) return; if (interaction.customId.startsWith("queue_")) { + interaction.data = []; + interaction.data.guld = await client.findOrCreateGuild(interaction.guildId); + const queue = client.player.nodes.get(interaction.guildId); if (!queue) return interaction.error("music/play:NOT_PLAYING"); @@ -119,7 +122,6 @@ class Queue extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const queue = client.player.nodes.get(interaction.guildId); diff --git a/commands/Music/seek.js b/commands/Music/seek.js index 84e3d0b6..86b560aa 100644 --- a/commands/Music/seek.js +++ b/commands/Music/seek.js @@ -34,7 +34,6 @@ class Seek extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const time = interaction.options.getInteger("time"), diff --git a/commands/Music/shuffle.js b/commands/Music/shuffle.js index 5b1118c2..8d5890c1 100644 --- a/commands/Music/shuffle.js +++ b/commands/Music/shuffle.js @@ -25,7 +25,6 @@ class Shuffle extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/Music/skip.js b/commands/Music/skip.js index 461abae8..340d5b17 100644 --- a/commands/Music/skip.js +++ b/commands/Music/skip.js @@ -25,7 +25,6 @@ class Skip extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/Music/skipto.js b/commands/Music/skipto.js index b4393a28..f906b69c 100644 --- a/commands/Music/skipto.js +++ b/commands/Music/skipto.js @@ -35,7 +35,6 @@ class Skipto extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/Music/stop.js b/commands/Music/stop.js index 32e88605..a5e34364 100644 --- a/commands/Music/stop.js +++ b/commands/Music/stop.js @@ -25,7 +25,6 @@ class Stop extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/Music/volume.js b/commands/Music/volume.js index 6013740b..00a72d7d 100644 --- a/commands/Music/volume.js +++ b/commands/Music/volume.js @@ -36,7 +36,6 @@ class Volume extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/NSFW/nsfw.js b/commands/NSFW/nsfw.js index 9f986ac4..dd179499 100644 --- a/commands/NSFW/nsfw.js +++ b/commands/NSFW/nsfw.js @@ -33,6 +33,9 @@ class NSFW extends BaseCommand { if (interaction.customId === "nsfw_select") { await interaction.deferUpdate(); + interaction.data = []; + interaction.data.guild = await client.findOrCreateGuild(interaction.guildId); + const tag = interaction?.values[0], splitted = tag.split("_"), res = await fetch(`https://nsfw-api-p302.onrender.com/media/${splitted[0].charAt(0).toLowerCase()}/${splitted[1].toLowerCase()}`).then(async r => await r.buffer()), @@ -55,12 +58,11 @@ class NSFW extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); - if (interaction.guildId && !interaction.channel.nsfw) return interaction.error("misc:NSFW_COMMAND", null, { edit: true, ephemeral: true }); + if (interaction.guild && !interaction.channel.nsfw) return interaction.error("misc:NSFW_COMMAND", null, { edit: true, ephemeral: true }); const tags = ["Hentai_Vanila", "Hentai_Yaoi", "Hentai_Yuri", "Hentai_BDSM", "Hentai_Trap", "Real_Ass", "Real_Boobs", "Real_Pussy"] .map(tag => diff --git a/commands/Owner/debug.js b/commands/Owner/debug.js index 21170d2a..f21042ab 100644 --- a/commands/Owner/debug.js +++ b/commands/Owner/debug.js @@ -117,7 +117,6 @@ class Debug extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data */ async execute(client, interaction) { const command = interaction.options.getSubcommand(); diff --git a/commands/Owner/eval.js b/commands/Owner/eval.js index ecd66b20..eb09ad63 100644 --- a/commands/Owner/eval.js +++ b/commands/Owner/eval.js @@ -35,10 +35,8 @@ class Eval extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - // eslint-disable-next-line no-unused-vars - async execute(client, interaction, data) { + async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); const code = interaction.options.getString("code"); diff --git a/commands/Owner/reload.js b/commands/Owner/reload.js index a96bc80b..4cfaae44 100644 --- a/commands/Owner/reload.js +++ b/commands/Owner/reload.js @@ -38,7 +38,6 @@ class Reload extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { const command = interaction.options.getString("command"), diff --git a/commands/Owner/say.js b/commands/Owner/say.js index 13e9b41a..6c99d7f7 100644 --- a/commands/Owner/say.js +++ b/commands/Owner/say.js @@ -53,7 +53,6 @@ class Say extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); diff --git a/commands/Owner/servers.js b/commands/Owner/servers.js index 4d14cc80..bfb5986a 100644 --- a/commands/Owner/servers.js +++ b/commands/Owner/servers.js @@ -25,7 +25,6 @@ class Servers extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); diff --git a/commands/Tickets/adduser.js b/commands/Tickets/adduser.js index 3184cdf8..9620c34e 100644 --- a/commands/Tickets/adduser.js +++ b/commands/Tickets/adduser.js @@ -36,7 +36,6 @@ class AddUser extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Tickets/closeticket.js b/commands/Tickets/closeticket.js index 3bae89b1..9213c97f 100644 --- a/commands/Tickets/closeticket.js +++ b/commands/Tickets/closeticket.js @@ -26,11 +26,12 @@ class CloseTicket extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { + async execute(client, interaction) { await interaction.deferReply(); + const guildData = interaction.data.guild; + if (!interaction.channel.name.includes("support")) return interaction.error("tickets/adduser:NOT_TICKET", null, { ephemeral: true, edit: true }); const embed = client.embed({ @@ -66,8 +67,8 @@ class CloseTicket extends BaseCommand { collector.on("end", async (_, reason) => { if (reason !== "canceled") { - const transcriptionLogs = data.guildData.plugins.tickets.transcriptionLogs, - ticketLogs = data.guildData.plugins.tickets.ticketLogs; + const transcriptionLogs = guildData.plugins.tickets.transcriptionLogs, + ticketLogs = guildData.plugins.tickets.ticketLogs; const reversedMessages = (await interaction.channel.messages.fetch()).filter(m => !m.author.bot); const messages = Array.from(reversedMessages.values()).reverse(); @@ -106,7 +107,7 @@ class CloseTicket extends BaseCommand { } }); - const ticketLogs = data.guildData.plugins.tickets.ticketLogs; + const ticketLogs = guildData.plugins.tickets.ticketLogs; const logEmbed = client.embed({ title: interaction.translate("tickets/closeticket:CLOSED_TITLE"), fields: [ diff --git a/commands/Tickets/createticketembed.js b/commands/Tickets/createticketembed.js index 6fe3dfbc..4f9d0ed1 100644 --- a/commands/Tickets/createticketembed.js +++ b/commands/Tickets/createticketembed.js @@ -30,13 +30,15 @@ class CreateTicketEmbed extends BaseCommand { client.on("interactionCreate", async interaction => { if (!interaction.isButton()) return; - const guildData = await client.findOrCreateGuild(interaction.guildId); - - const ticketsCategory = guildData.plugins.tickets.ticketsCategory, - ticketLogs = guildData.plugins.tickets.ticketLogs, - transcriptionLogs = guildData.plugins.tickets.transcriptionLogs; - if (interaction.isButton()) { + interaction.data = []; + interaction.data.guild = await client.findOrCreateGuild(interaction.guildId); + + const guildData = interaction.guild.data, + ticketsCategory = guildData.plugins.tickets.ticketsCategory, + ticketLogs = guildData.plugins.tickets.ticketLogs, + transcriptionLogs = guildData.plugins.tickets.transcriptionLogs; + const button = interaction.component; if (button.customId === "support_ticket") { @@ -206,10 +208,11 @@ class CreateTicketEmbed extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ - async execute(client, interaction, data) { - if (!data.guildData.plugins.tickets.ticketsCategory) return interaction.error("tickets/createticketembed:NO_CATEGORY"); + async execute(client, interaction) { + const guildData = interaction.data.guild; + + if (!guildData.plugins.tickets.ticketsCategory) return interaction.error("tickets/createticketembed:NO_CATEGORY"); await interaction.deferReply({ ephemeral: true }); diff --git a/commands/Tickets/removeuser.js b/commands/Tickets/removeuser.js index ddb31c7b..066f8151 100644 --- a/commands/Tickets/removeuser.js +++ b/commands/Tickets/removeuser.js @@ -36,7 +36,6 @@ class RemoveUser extends BaseCommand { * * @param {import("../../base/Client")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/events/CommandHandler.js b/events/CommandHandler.js index be382fdc..d3ff6ad3 100644 --- a/events/CommandHandler.js +++ b/events/CommandHandler.js @@ -16,27 +16,27 @@ class CommandHandler extends BaseEvent { */ async execute(client, interaction) { const command = client.commands.get(interaction.commandName); + const data = []; - const userData = await client.findOrCreateUser(interaction.user.id); - data.userData = userData; + data.user = await client.findOrCreateUser(interaction.user.id); if (interaction.inGuild()) { - const guildData = await client.findOrCreateGuild(interaction.guildId); - const memberData = await client.findOrCreateMember({ id: interaction.member.id, guildId: interaction.guildId }); - - interaction.guild.data = data.guildData = guildData; - data.memberData = memberData; + data.guild = await client.findOrCreateGuild(interaction.guildId); + data.member = await client.findOrCreateMember({ id: interaction.member.id, guildId: interaction.guildId }); } - if (command?.dirname.includes("IAT") && interaction.guildId !== "1039187019957555252") return interaction.reply({ content: "IAT Only", ephemeral: true }); - if (interaction.isAutocomplete()) return await command.autocompleteRun(client, interaction); + interaction.data = data; + if (interaction.isButton() && interaction.customId === "quote_delete" && interaction.message.deletable) return interaction.message.delete(); + if (interaction.isAutocomplete()) return await command.autocompleteRun(client, interaction); + if (interaction.type !== InteractionType.ApplicationCommand && !interaction.isCommand()) return; + if (command?.dirname.includes("IAT") && interaction.guildId !== "1039187019957555252") return interaction.reply({ content: "IAT Only", ephemeral: true }); if (command.ownerOnly && interaction.user.id !== client.config.owner.id) return interaction.error("misc:OWNER_ONLY", null, { ephemeral: true }); - if (!userData.achievements.firstCommand.achieved) { + if (!interaction.data.user.achievements.firstCommand.achieved) { const args = { content: interaction.user.toString(), files: [ @@ -47,20 +47,29 @@ class CommandHandler extends BaseEvent { ], }; - userData.achievements.firstCommand.progress.now = 1; - userData.achievements.firstCommand.achieved = true; + interaction.data.user.achievements.firstCommand.progress.now = 1; + interaction.data.user.achievements.firstCommand.achieved = true; - userData.markModified("achievements"); - await userData.save(); + interaction.data.user.markModified("achievements"); + await interaction.data.user.save(); try { interaction.user.send(args); } catch (e) { /**/ } } - client.logger.cmd(`User ${interaction.user.getUsername()} used ${command.command.name} in ${interaction.guild ? interaction.guild.name : "DM"} with arguments: ${interaction.options.data.length > 0 ? interaction.options.data.map(arg => { return `${arg.name}: ${arg.value}`; }).join(", ") : "no args" }`); + client.logger.cmd( + `User ${interaction.user.getUsername()} used ${command.command.name} in ${interaction.guild ? interaction.guild.name : "DM"} with arguments: ${ + interaction.options.data.length > 0 + ? interaction.options.data + .map(arg => { + return `${arg.name}: ${arg.value}`; + }).join(", ") + : "no args" + }`, + ); - return command.execute(client, interaction, data); + return command.execute(client, interaction); } } diff --git a/events/MessageHandler.js b/events/MessageHandler.js index 44b29ae1..36f8e2c4 100644 --- a/events/MessageHandler.js +++ b/events/MessageHandler.js @@ -19,25 +19,24 @@ class MessageCreate extends BaseEvent { async execute(client, message) { if (message.guild && message.guild.id === "568120814776614924") return; - const data = {}; + const data = []; if (message.author.bot) return; if (message.content.match(new RegExp(`^<@!?${client.user.id}>( |)$`))) return message.replyT("misc:HELLO_SERVER", null, { mention: true }); - const userData = await client.findOrCreateUser(message.author.id); - data.userData = userData; + data.user = await client.findOrCreateUser(message.author.id); - if (message.guild && !message.member) await message.guild.members.fetch(message.author.id); if (message.guild) { - const guildData = await client.findOrCreateGuild(message.guildId); - const memberData = await client.findOrCreateMember({ id: message.author.id, guildId: message.guildId }); + if (!message.member) await message.guild.members.fetch(message.author.id); - message.guild.data = data.guildData = guildData; - data.memberData = memberData; + data.guild = await client.findOrCreateGuild(message.guildId); + data.member = await client.findOrCreateMember({ id: message.author.id, guildId: message.guildId }); } + message.data = data; + if (message.guild) { - await updateXp(client, message, data.memberData); + await updateXp(message); if (message.content.match(/(https|http):\/\/(ptb\.|canary\.)?(discord.com)\/(channels)\/\d+\/\d+\/\d+/g)) { const link = message.content.match(/(https|http):\/\/(ptb\.|canary\.)?(discord.com)\/(channels)\/\d+\/\d+\/\d+/g)[0], @@ -89,18 +88,18 @@ class MessageCreate extends BaseEvent { }); } - if (data.guildData.plugins.automod.enabled && !data.guildData.plugins.automod.ignored.includes(message.channelId)) + if (message.data.guild.plugins.automod.enabled && !message.data.guild.plugins.automod.ignored.includes(message.channelId)) if (/(discord\.(gg|io|me|li)\/.+|discordapp\.com\/invite\/.+)/i.test(message.content)) if (!message.channel.permissionsFor(message.member).has(PermissionsBitField.Flags.ManageMessages)) { await message.error("administration/automod:DELETED", null, { mention: true }); message.delete(); } - if (data.userData.afk) { - data.userData.afk = null; + if (message.data.user.afk) { + message.data.user.afk = null; - data.userData.markModified("afk"); - await data.userData.save(); + message.data.user.markModified("afk"); + await message.data.user.save(); message.replyT("general/afk:DELETED", { user: message.author.username, @@ -121,28 +120,28 @@ class MessageCreate extends BaseEvent { /** * * @param {import("../base/Client")} client - * @param {import("discord.js").Message} msg - * @param {import("../base/Member")} memberData + * @param {import("discord.js").Message} message * @returns */ -async function updateXp(client, msg, memberData) { - const points = parseInt(memberData.exp), +async function updateXp(message) { + const memberData = message.data.member, + points = parseInt(memberData.exp), level = parseInt(memberData.level), - isInCooldown = xpCooldown[msg.author.id]; + isInCooldown = xpCooldown[message.author.id]; if (isInCooldown) if (isInCooldown > Date.now()) return; const toWait = Date.now() + 60 * 1000; // 1 min - xpCooldown[msg.author.id] = toWait; + xpCooldown[message.author.id] = toWait; - const won = client.functions.randomNum(1, 2); + const won = message.client.functions.randomNum(1, 2); const newXp = parseInt(points + won, 10); const neededXp = 5 * (level * level) + 80 * level + 100; if (newXp > neededXp) { memberData.level = parseInt(level + 1, 10); memberData.exp = 0; - msg.replyT("misc:LEVEL_UP", { + message.replyT("misc:LEVEL_UP", { level: memberData.level, }, { mention: false }); } else memberData.exp = parseInt(newXp, 10); diff --git a/events/Monitoring/messageDelete.js b/events/Monitoring/messageDelete.js index 445e7904..b9c4c2d8 100644 --- a/events/Monitoring/messageDelete.js +++ b/events/Monitoring/messageDelete.js @@ -17,7 +17,7 @@ class messageDelete extends BaseEvent { if (message.guild && message.guildId === "568120814776614924") return; if (message.author.bot) return; - const guildData = await client.findOrCreateGuild(message.guildId); + const guildData = message.data.guild; if (guildData.plugins?.monitoring?.messageDelete) { const embed = client.embed({ diff --git a/events/Monitoring/messageUpdate.js b/events/Monitoring/messageUpdate.js index e4bc058d..73cc09b7 100644 --- a/events/Monitoring/messageUpdate.js +++ b/events/Monitoring/messageUpdate.js @@ -20,7 +20,7 @@ class messageUpdate extends BaseEvent { if (oldMessage.content === newMessage.content) return; - const guildData = await client.findOrCreateGuild(oldMessage.guildId); + const guildData = newMessage.data.guild; if (guildData.plugins?.monitoring?.messageUpdate) { const embed = client.embed({ diff --git a/helpers/checkReminds.js b/helpers/checkReminds.js index 0a4d5962..7fd0792a 100644 --- a/helpers/checkReminds.js +++ b/helpers/checkReminds.js @@ -1,5 +1,3 @@ -const moment = require("moment"); - /** * * @param {import("../base/Client")} client @@ -29,12 +27,12 @@ module.exports.init = function (client) { fields: [ { name: client.translate("general/remindme:EMBED_CREATED"), - value: moment(r.createdAt).locale(client.defaultLanguage).format("Do MMMM YYYY, HH:mm:ss"), + value: ``, inline: true, }, { name: client.translate("general/remindme:EMBED_TIME"), - value: moment(r.sendAt).locale(client.defaultLanguage).format("Do MMMM YYYY, HH:mm:ss"), + value: ``, inline: true, }, { diff --git a/helpers/extenders.js b/helpers/extenders.js index 19d23bab..dfc70e07 100644 --- a/helpers/extenders.js +++ b/helpers/extenders.js @@ -5,7 +5,7 @@ User.prototype.getUsername = function () { }; BaseInteraction.prototype.getLocale = function () { - return this.guild ? this.guild.data.language : "en-US"; + return this.guild ? this.data?.guild?.language : "en-US"; }; BaseInteraction.prototype.translate = function (key, args) { @@ -35,15 +35,19 @@ BaseInteraction.prototype.error = async function (key, args, options = {}) { return await this.replyT(key, args, options); }; +Message.prototype.getLocale = function () { + return this.guild ? this.data?.guild?.language : "en-US"; +}; + Message.prototype.translate = function (key, args) { - const language = this.client.translations.get(this.guild ? this.guild.data.language : "en-US"); + const language = this.client.translations.get(this.getLocale()); if (!language) throw "Message: Invalid language set in data."; return language(key, args); }; Message.prototype.replyT = async function (key, args, options = {}) { - const translated = this.translate(key, args, this.guild.data.language ?? "en-US"); + const translated = this.translate(key, args, this.getLocale()); const string = options.prefixEmoji ? `${this.client.customEmojis[options.prefixEmoji]} | ${translated}` : translated; if (options.edit) return await this.edit({ content: string, allowedMentions: { repliedUser: options.mention ? true : false } }); diff --git a/helpers/functions.js b/helpers/functions.js index c8e0596c..123ad04d 100644 --- a/helpers/functions.js +++ b/helpers/functions.js @@ -83,7 +83,7 @@ module.exports = { * @param {String} locale Language * @returns {String} Beautified Date */ - printDate(client, date, format = null, locale = client.defaultLanguage) { + printDate(client, date, format = null, locale = client.defaultLanguage.name) { const languageData = client.languages.find(language => language.name === locale); if (format === "" || format === null) format = languageData.defaultMomentFormat; @@ -99,7 +99,7 @@ module.exports = { * @param {String} locale Language * @returns {String} Time */ - convertTime(client, time, type = false, prefix = true, locale = client.defaultLanguage) { + convertTime(client, time, type = false, prefix = true, locale = client.defaultLanguage.name) { const languageData = client.languages.find(language => language.name === locale); const m = moment(time).locale(languageData.moment); diff --git a/package.json b/package.json index 5a9be60c..ad75cc1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jaba", - "version": "4.4.2", + "version": "4.4.3", "description": "My Discord Bot", "main": "index.js", "scripts": {