From 5a2fa09101d96b75261884d281f5bf326a02e4a5 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 7 Aug 2024 12:17:20 +0200 Subject: [PATCH 01/78] fixed comman structure checking test --- unit-tests/command-schema.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unit-tests/command-schema.test.js b/unit-tests/command-schema.test.js index b8d2425..245fc8a 100644 --- a/unit-tests/command-schema.test.js +++ b/unit-tests/command-schema.test.js @@ -12,7 +12,7 @@ jest.mock('../helpers/db', () => ({ })); -describe("Command structure test", () => { +describe("Command structure base test", () => { test("All commands should have \"data\" and \"execute\" properties", () => { const foldersPath = path.join(__dirname, "..", "commands"); const commandFolders = fs.readdirSync(foldersPath); @@ -26,6 +26,7 @@ describe("Command structure test", () => { const command = require(filePath); expect(command).toHaveProperty("data"); + expect(command).toHaveProperty("execute"); }) }) }); From 8d7c6dd5629a886002400fa4569ee9aa4fbf2e5a Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 7 Aug 2024 12:23:52 +0200 Subject: [PATCH 02/78] added /pay command (documentation only for now) --- commands/economy/pay.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 commands/economy/pay.js diff --git a/commands/economy/pay.js b/commands/economy/pay.js new file mode 100644 index 0000000..b37b943 --- /dev/null +++ b/commands/economy/pay.js @@ -0,0 +1,28 @@ +const { EmbedBuilder, SlashCommandBuilder, Embed } = require("discord.js"); +const { logToFileAndDatabase } = require("../../helpers/logger"); +const db = require("../../helpers/db"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("pay") + .setDescription("Pay someone a specified amount of money.") + .addUserOption(option => + option + .setName("target") + .setDescription("The user who will receive the payment.") + .setRequired(true)) + .addIntegerOption(otpion => + option + .setName("amount") + .setDescription("The amount of money the target user will receive.") + .setRequired(true)) + .setDMPermission(false), + async execute(interaction) { + + const embedReply = new EmbedBuilder({ + + }); + + interaction.reply(); + } +} \ No newline at end of file From 52b782006508e29230050eda52df9d74f5b5a426 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 7 Aug 2024 13:23:09 +0200 Subject: [PATCH 03/78] updated / pay --- commands/economy/pay.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/commands/economy/pay.js b/commands/economy/pay.js index b37b943..23247b2 100644 --- a/commands/economy/pay.js +++ b/commands/economy/pay.js @@ -18,11 +18,35 @@ module.exports = { .setRequired(true)) .setDMPermission(false), async execute(interaction) { + if (!interaction.inGuild) { + var replyContent = "You can only pay out a member in a server."; + } + else { + const amount = interaction.options.getInteger("amount"); + const targetUser = interaction.option.getUser("target"); + const interactionUserId = interaction.user.id; - const embedReply = new EmbedBuilder({ + const query = await db.query("SELECT balance FROM economy WHERE userId = ?", []); + const userBalance = query[0]?.balance || null; + + if (amount < userBalance) { + var replyContent = `You can't pay that much money to ${targetUser}!\nYour balance is only \`$${userBalance}\`.`; + } + } + const embedReply = new EmbedBuilder({ + color: 0x5F0FD6, + title: "Paying to a member.", + description: replyContent, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}` , + icon_url: interaction.user.displayAvatarURL({ dynamic: true }), + }, }); - interaction.reply(); + interaction.reply({ embeds: embedReply}); + + } } \ No newline at end of file From b1190b849036927c9d7d28177384efaaf3aaf132 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 7 Aug 2024 14:08:59 +0200 Subject: [PATCH 04/78] updated /pay's execution methods and response designs --- commands/economy/pay.js | 29 ++++++++++++++++++++++++----- commands/economy/rob.js | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/commands/economy/pay.js b/commands/economy/pay.js index 23247b2..d4d0c3d 100644 --- a/commands/economy/pay.js +++ b/commands/economy/pay.js @@ -23,14 +23,31 @@ module.exports = { } else { const amount = interaction.options.getInteger("amount"); - const targetUser = interaction.option.getUser("target"); + const targetUserId = interaction.option.getUser("target").id; const interactionUserId = interaction.user.id; - const query = await db.query("SELECT balance FROM economy WHERE userId = ?", []); + const query = await db.query("SELECT balance FROM economy WHERE userId = ?", [interactionUserId]); const userBalance = query[0]?.balance || null; if (amount < userBalance) { - var replyContent = `You can't pay that much money to ${targetUser}!\nYour balance is only \`$${userBalance}\`.`; + var replyContent = `:x: You can't pay that much money to <@${targetUserId}>!\nYour balance is only \`$${userBalance}\`.`; + } + else { + await db.query("UPDATE economy SET balance = balance - ? WHERE userId = ?", + [ + amount, + interactionUserId + ] + ); + + await db.query("UPDATE economy SET balance = balance + ? WHERE userId = ?", + [ + amount, + targetUserId + ] + ); + + var replyContent = `:white_check_mark: <@${interactionUserId}> has successfully paid \`$${amount}\` to <@${targetUserId}>.`; } } @@ -40,13 +57,15 @@ module.exports = { description: replyContent, timestamp: new Date().toISOString(), footer: { - text: `Requested by: ${interaction.user.username}` , + text: `Requested by: ${interaction.user.username}`, icon_url: interaction.user.displayAvatarURL({ dynamic: true }), }, }); interaction.reply({ embeds: embedReply}); - + //logging + const response = JSON.stringify(embedReply.toJSON()); + await logToFileAndDatabase(interaction, response); } } \ No newline at end of file diff --git a/commands/economy/rob.js b/commands/economy/rob.js index e4cd083..1767fc9 100644 --- a/commands/economy/rob.js +++ b/commands/economy/rob.js @@ -88,7 +88,7 @@ module.exports = { description: replyContent, timestamp: new Date().toISOString(), footer: { - text: `Requested by: ${interaction.user.username}` , + text: `Requested by: ${interaction.user.username}`, icon_url: interaction.user.displayAvatarURL({ dynamic: true }), }, }); From 80b033c92b6e44dcff9137f4c972a8b96cddf035 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 8 Aug 2024 12:05:25 +0200 Subject: [PATCH 05/78] added command options for /deposit, updated economy table with relevant column --- commands/economy/deposit.js | 19 +++++++++++++++++++ sql/economy/table.sql | 1 + 2 files changed, 20 insertions(+) create mode 100644 commands/economy/deposit.js diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js new file mode 100644 index 0000000..1fbca3a --- /dev/null +++ b/commands/economy/deposit.js @@ -0,0 +1,19 @@ +const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { logToFileAndDatabase } = require("../../helpers/logger"); +const db = require("../../helpers/db"); +const { execute } = require("./work"); + +module.ecports = { + data: new SlashCommandBuilder() + .setName("deposit") + .setDescription("Desposits a specified amount of money to your bank account.") + .addIntegerOption(option => + option + .setName("amount") + .setDescription("The amount of money you want to deposit.") + .setRequired(true)) + .setDMPermission(false), + async execute(interaction) { + + } +} \ No newline at end of file diff --git a/sql/economy/table.sql b/sql/economy/table.sql index 7e40c36..4be81c1 100644 --- a/sql/economy/table.sql +++ b/sql/economy/table.sql @@ -5,6 +5,7 @@ CREATE TABLE IF NOT EXISTS `economy` ( `userName` text DEFAULT NULL, `userId` bigint(20) NOT NULL, `balance` bigint(20) DEFAULT 0, + `balanceInBank` bigint(20) DEFAULT 0, `firstTransactionDate` datetime NOT NULL DEFAULT current_timestamp(), `lastWorkTime` datetime DEFAULT NULL, `lastRobTime` datetime DEFAULT NULL, From 90fc18903146d6dcaacaf3f79b58223cea45fdeb Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 8 Aug 2024 15:09:16 +0200 Subject: [PATCH 06/78] added first function part for /deposit --- commands/economy/deposit.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 1fbca3a..535fa59 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -14,6 +14,26 @@ module.ecports = { .setRequired(true)) .setDMPermission(false), async execute(interaction) { + const amount = interaction.options.getInteger("amount"); + const interactionUserId = interaction.user.id; + const query = await db.query("SELECT balance FROM economy WHERE userId = ?", [interactionUserId]); + const balance = query[0]?.balance || null; + + if (balance < amount) { + var replyContent = `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\``; + } + else { + await db.query("UPDATE economy SET balance = balance - ?, balanceInBank = balanceInBank + ? WHERE userId = ?", + [ + amount, + amount, + interactionUserId + ] + ) + + var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\``; + } + } } \ No newline at end of file From 2fbbed319e60fa33a28df53c1fb4c60bc2639685 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 8 Aug 2024 15:10:30 +0200 Subject: [PATCH 07/78] added reply and logging to /deposit --- commands/economy/deposit.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 535fa59..205da2e 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -34,6 +34,21 @@ module.ecports = { var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\``; } - + var embedReply = new EmbedBuilder({ + color: 0x5F0FD6, + title: "Depositing.", + description: replyContent, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + await interaction.reply({ embeds: [embedReply] }); + + //logging + const response = JSON.stringify(embedReply.toJSON()); + await logToFileAndDatabase(interaction, response); } } \ No newline at end of file From dd7f45aaa95ffdbb6d5bb42f78ec90f4580be408 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Fri, 9 Aug 2024 13:07:53 +0200 Subject: [PATCH 08/78] added base idea and schema for /withdraw --- commands/economy/deposit.js | 3 +-- commands/economy/withdraw.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 commands/economy/withdraw.js diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 205da2e..450dfb9 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -1,7 +1,6 @@ const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); -const { execute } = require("./work"); module.ecports = { data: new SlashCommandBuilder() @@ -20,7 +19,7 @@ module.ecports = { const balance = query[0]?.balance || null; if (balance < amount) { - var replyContent = `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\``; + var replyContent = `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\`.`; } else { await db.query("UPDATE economy SET balance = balance - ?, balanceInBank = balanceInBank + ? WHERE userId = ?", diff --git a/commands/economy/withdraw.js b/commands/economy/withdraw.js new file mode 100644 index 0000000..d7cbd72 --- /dev/null +++ b/commands/economy/withdraw.js @@ -0,0 +1,29 @@ +const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { logToFileAndDatabase } = require("../../helpers/logger"); +const db = require("../../helpers/db"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("withdraw") + .setDescription("Withdraws a specified amount of money from your bank account.") + .addIntegerOption(option => + option + .setName("amount") + .setDescription("The amount of money you want to withdraw.") + .setRequired(true)) + .setDMPermission(false), + async execute(interaction) { + const amount = interaction.options.getInteger("amount"); + const interactionUserId = interaction.user.id; + const query = await db.query("SELECT balance, balanceInBank FROM economy WHERE userId = ?", [interactionUserId]); + const balance = query[0]?.balance || null; + const balanceInBank = query[0]?.balanceInBank || null; + + if (balanceInBank < amount) { + var replyContent = `You can't withdraw that much money from your bank account.\nYour current bank balance is only \`$${balanceInBank}\`.`; + } + else { + + } + } +} \ No newline at end of file From 41b0f1ed68dc68de8534fb4adcb864017f2905a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20V=C3=A1gv=C3=B6lgyi?= Date: Fri, 9 Aug 2024 13:17:38 +0200 Subject: [PATCH 09/78] added base withdraw mechanism to /withdraw --- commands/economy/deposit.js | 2 +- commands/economy/withdraw.js | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 450dfb9..4c8e1ed 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -30,7 +30,7 @@ module.ecports = { ] ) - var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\``; + var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\`.`; } var embedReply = new EmbedBuilder({ diff --git a/commands/economy/withdraw.js b/commands/economy/withdraw.js index d7cbd72..cdf435d 100644 --- a/commands/economy/withdraw.js +++ b/commands/economy/withdraw.js @@ -23,7 +23,32 @@ module.exports = { var replyContent = `You can't withdraw that much money from your bank account.\nYour current bank balance is only \`$${balanceInBank}\`.`; } else { - + await db.query("UPDATE economy SET balance = balance + ?, balanceInBank = balanceInBank - ? WHERE userId = ?" + [ + amount, + amount, + interactionUserId + ] + ); + + var replyContent = ``; } + + var embedReply = new EmbedBuilder({ + color: 0x5F0FD6, + title: "Withdrawing.", + description: replyContent, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + await interaction.reply({ embeds: [embedReply] }); + + //logging + const response = JSON.stringify(embedReply.toJSON()); + await logToFileAndDatabase(interaction, response); } } \ No newline at end of file From f420f739581e5ff31ae3d24d71e595ab2a86770a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20V=C3=A1gv=C3=B6lgyi?= Date: Fri, 9 Aug 2024 13:20:06 +0200 Subject: [PATCH 10/78] added reply text to /withdraw --- commands/economy/withdraw.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/economy/withdraw.js b/commands/economy/withdraw.js index cdf435d..615f0cc 100644 --- a/commands/economy/withdraw.js +++ b/commands/economy/withdraw.js @@ -31,7 +31,7 @@ module.exports = { ] ); - var replyContent = ``; + var replyContent = `You've successfully withdrawn \`$${amount}\` from your bank account.\nYour current balance in the bank is \`$${balanceInBank - amount}\`.\nYour current balance is \`$${balance + amount}\`.`; } var embedReply = new EmbedBuilder({ From 79640504f95784ea389277e110a87aee7fe08a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20V=C3=A1gv=C3=B6lgyi?= Date: Fri, 9 Aug 2024 13:21:14 +0200 Subject: [PATCH 11/78] added displaying balance in bank to /deposit --- commands/economy/deposit.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 4c8e1ed..569ab00 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -15,7 +15,8 @@ module.ecports = { async execute(interaction) { const amount = interaction.options.getInteger("amount"); const interactionUserId = interaction.user.id; - const query = await db.query("SELECT balance FROM economy WHERE userId = ?", [interactionUserId]); + const query = await db.query("SELECT balance, balanceInBank FROM economy WHERE userId = ?", [interactionUserId]); + const balanceInBank = query[0]?.balanceInBank || null; const balance = query[0]?.balance || null; if (balance < amount) { @@ -30,7 +31,7 @@ module.ecports = { ] ) - var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\`.`; + var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\`.\nYour current balance in the bank is \`$${balanceInBank + amount}\`.`; } var embedReply = new EmbedBuilder({ From cb326dc1be17f1e38db10b1d49e35677cfd09508 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 11 Aug 2024 22:31:10 +0200 Subject: [PATCH 12/78] fixed typos in /pay --- commands/economy/pay.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/economy/pay.js b/commands/economy/pay.js index d4d0c3d..1bacab9 100644 --- a/commands/economy/pay.js +++ b/commands/economy/pay.js @@ -11,7 +11,7 @@ module.exports = { .setName("target") .setDescription("The user who will receive the payment.") .setRequired(true)) - .addIntegerOption(otpion => + .addIntegerOption(option => option .setName("amount") .setDescription("The amount of money the target user will receive.") @@ -23,13 +23,13 @@ module.exports = { } else { const amount = interaction.options.getInteger("amount"); - const targetUserId = interaction.option.getUser("target").id; + const targetUserId = interaction.options.getUser("target").id; const interactionUserId = interaction.user.id; const query = await db.query("SELECT balance FROM economy WHERE userId = ?", [interactionUserId]); const userBalance = query[0]?.balance || null; - if (amount < userBalance) { + if (amount > userBalance) { var replyContent = `:x: You can't pay that much money to <@${targetUserId}>!\nYour balance is only \`$${userBalance}\`.`; } else { @@ -62,7 +62,7 @@ module.exports = { }, }); - interaction.reply({ embeds: embedReply}); + await interaction.reply({ embeds: [embedReply] }); //logging const response = JSON.stringify(embedReply.toJSON()); From c0438a67e55209f20f90d02dd28a0e8e1fd24db9 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 11 Aug 2024 22:43:41 +0200 Subject: [PATCH 13/78] made /pay handle paying money to new (to db) users --- commands/economy/pay.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/commands/economy/pay.js b/commands/economy/pay.js index 1bacab9..b9449d6 100644 --- a/commands/economy/pay.js +++ b/commands/economy/pay.js @@ -26,8 +26,11 @@ module.exports = { const targetUserId = interaction.options.getUser("target").id; const interactionUserId = interaction.user.id; - const query = await db.query("SELECT balance FROM economy WHERE userId = ?", [interactionUserId]); - const userBalance = query[0]?.balance || null; + const interactionUserBalanceQuery = await db.query("SELECT balance FROM economy WHERE userId = ?", [interactionUserId]); + const userBalance = interactionUserBalanceQuery[0]?.balance || null; + + const targetUserBalanceQuery = await db.query("SELECT balance FROM economy WHERE userId = ?", [targetUserId]); + const targetUserBalance = targetUserBalanceQuery[0]?.balance || null; if (amount > userBalance) { var replyContent = `:x: You can't pay that much money to <@${targetUserId}>!\nYour balance is only \`$${userBalance}\`.`; @@ -40,12 +43,22 @@ module.exports = { ] ); - await db.query("UPDATE economy SET balance = balance + ? WHERE userId = ?", - [ - amount, - targetUserId - ] - ); + if (!targetUserBalance) { + await db.query("INSERT INTO economy (userId, balance) VALUES (?, ?)", + [ + targetUserId, + amount + ] + ); + } + else { + await db.query("UPDATE economy SET balance = balance + ? WHERE userId = ?", + [ + amount, + targetUserId + ] + ); + } var replyContent = `:white_check_mark: <@${interactionUserId}> has successfully paid \`$${amount}\` to <@${targetUserId}>.`; } From 257230d0e8ff4befc01dc382f061ba0d98fda299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20V=C3=A1gv=C3=B6lgyi?= Date: Mon, 12 Aug 2024 12:44:41 +0200 Subject: [PATCH 14/78] added negative balance check to /pay --- commands/economy/pay.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/commands/economy/pay.js b/commands/economy/pay.js index b9449d6..dfc17f2 100644 --- a/commands/economy/pay.js +++ b/commands/economy/pay.js @@ -35,6 +35,9 @@ module.exports = { if (amount > userBalance) { var replyContent = `:x: You can't pay that much money to <@${targetUserId}>!\nYour balance is only \`$${userBalance}\`.`; } + else if (amount <= 0) { + var replyContent = ":x: You can't pay a negative or zero amount of money!\nTry again with a positive amount."; + } else { await db.query("UPDATE economy SET balance = balance - ? WHERE userId = ?", [ From 393a7e96f8517cfc02dc6518689b8df4601d1b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20V=C3=A1gv=C3=B6lgyi?= Date: Mon, 12 Aug 2024 12:48:03 +0200 Subject: [PATCH 15/78] added user "mention" to negative balance "error" response --- commands/economy/pay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/economy/pay.js b/commands/economy/pay.js index dfc17f2..e81ca0c 100644 --- a/commands/economy/pay.js +++ b/commands/economy/pay.js @@ -36,7 +36,7 @@ module.exports = { var replyContent = `:x: You can't pay that much money to <@${targetUserId}>!\nYour balance is only \`$${userBalance}\`.`; } else if (amount <= 0) { - var replyContent = ":x: You can't pay a negative or zero amount of money!\nTry again with a positive amount."; + var replyContent = `:x: You can't pay a negative or zero amount of money to <@${targetUserId}>!\nTry again with a positive amount.`; } else { await db.query("UPDATE economy SET balance = balance - ? WHERE userId = ?", From e94f8b578c7182e7b49c4d5189bb971016747d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20V=C3=A1gv=C3=B6lgyi?= Date: Mon, 12 Aug 2024 12:48:34 +0200 Subject: [PATCH 16/78] removed unused import --- commands/economy/pay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/economy/pay.js b/commands/economy/pay.js index e81ca0c..0cfd3a9 100644 --- a/commands/economy/pay.js +++ b/commands/economy/pay.js @@ -1,4 +1,4 @@ -const { EmbedBuilder, SlashCommandBuilder, Embed } = require("discord.js"); +const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); From 9f948c07d1860f2ef28f83508f7dc5740b3240db Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 12 Aug 2024 14:03:06 +0200 Subject: [PATCH 17/78] added ajv package for validating the config.json file --- package-lock.json | 58 +++++++++++++++++++++++++++++++++++++---------- package.json | 1 + 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 504ea0e..5789a52 100755 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "packages": { "": { "dependencies": { + "ajv": "^8.17.1", "cheerio": "^1.0.0-rc.12", "discord.js": "^14.14.1", "fetch": "^1.1.0", @@ -1248,15 +1249,14 @@ } }, "node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "peer": true, + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" }, "funding": { "type": "github", @@ -2170,6 +2170,11 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" }, + "node_modules/fast-uri": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.1.tgz", + "integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw==" + }, "node_modules/fb-watchman": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", @@ -2405,6 +2410,28 @@ "node": ">=6" } }, + "node_modules/har-validator/node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "peer": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/har-validator/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "peer": true + }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -3561,10 +3588,9 @@ "peer": true }, "node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "peer": true + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, "node_modules/json-stringify-safe": { "version": "5.0.1", @@ -4302,6 +4328,14 @@ "node": ">=0.10.0" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/resolve": { "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", diff --git a/package.json b/package.json index 24b56e1..a6f1428 100755 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "dependencies": { + "ajv": "^8.17.1", "cheerio": "^1.0.0-rc.12", "discord.js": "^14.14.1", "fetch": "^1.1.0", From a296faf966b9dd6226f9ff99584f3dd6dbdefc91 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 12 Aug 2024 14:07:01 +0200 Subject: [PATCH 18/78] added documentation for specific project folders --- helpers/README.md | 3 +++ scripts/README.md | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 helpers/README.md create mode 100644 scripts/README.md diff --git a/helpers/README.md b/helpers/README.md new file mode 100644 index 0000000..8ee3376 --- /dev/null +++ b/helpers/README.md @@ -0,0 +1,3 @@ +# Helpers + +Helpers are used across all scripts in the whole project to avoid code duplication. \ No newline at end of file diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..d687471 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,3 @@ +# Scripts + +Scripts are usually used only once in the project. They're in this folder to avoid spamming the project's root directory with files. \ No newline at end of file From c8d807dbe37e258afc5a9722fa6094f22840b2d7 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 12 Aug 2024 14:09:49 +0200 Subject: [PATCH 19/78] added config schema, updated scripts documentation --- scripts/README.md | 4 +++- scripts/configSchema.json | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 scripts/configSchema.json diff --git a/scripts/README.md b/scripts/README.md index d687471..c365bd9 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -1,3 +1,5 @@ # Scripts -Scripts are usually used only once in the project. They're in this folder to avoid spamming the project's root directory with files. \ No newline at end of file +Scripts are usually used only once in the project. They're in this folder to avoid spamming the project's root directory with files. + +This folder might contain assets like config schemas and other files used by the scripts. \ No newline at end of file diff --git a/scripts/configSchema.json b/scripts/configSchema.json new file mode 100644 index 0000000..f72cc63 --- /dev/null +++ b/scripts/configSchema.json @@ -0,0 +1,23 @@ +{ + "type": "object", + "properties": { + "token": { "type": "string" }, + "clientId": { "type": "string" }, + "databaseHostAddress": { "type": "string" }, + "databaseName": { "type": "string" }, + "databaseUser": { "type": "string" }, + "databasePassword": { "type": "string" }, + "logToFile": { "type": "string" }, + "logToDatabase": { "type": "string" } + }, + "required": [ + "token", + "clientId", + "databaseHostAddress", + "databaseName", + "databaseUser", + "databasePassword", + "logToFile", + "logToDatabase" + ] +} \ No newline at end of file From 6e142e2ee0546d45f5aea11221f90ba0cd4857b9 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 12 Aug 2024 14:17:29 +0200 Subject: [PATCH 20/78] added config schema validation --- scripts/verify-config-schema.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 scripts/verify-config-schema.js diff --git a/scripts/verify-config-schema.js b/scripts/verify-config-schema.js new file mode 100644 index 0000000..4cd4487 --- /dev/null +++ b/scripts/verify-config-schema.js @@ -0,0 +1,18 @@ +const fs = require("fs"); +const path = require("path"); +const Ajv = require("ajv"); + +const configPath = path.join(__dirname, "..", "config.json"); +const schemaPath = path.join(__dirname, "config-schema.json"); + +const config = JSON.parse(fs.readFileSync(configPath, "utf-8")); +const configSchema = JSON.parse(fs.readFileSync(configSchemaPath, "utf-8")); + +const ajv = new Ajv(); +const validate = ajv.compile(configSchema); +const valid = validate(config); + +if (!valid) { + console.error($`The config.json file contains syntax errors: ${validate.errors}\nPlease follow the schema that's present on the project's GitHub page: https://github.com/vb2007/discordbot/tree/dev-bank?tab=readme-ov-file#setting-up-the-bot`); + process.exit(1); +} \ No newline at end of file From 79f464eee221bbd76bcdf91c86bf14f889c569c2 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 12 Aug 2024 14:19:59 +0200 Subject: [PATCH 21/78] added validation to a function, exported the function --- scripts/verify-config-schema.js | 37 ++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/scripts/verify-config-schema.js b/scripts/verify-config-schema.js index 4cd4487..2f39dfe 100644 --- a/scripts/verify-config-schema.js +++ b/scripts/verify-config-schema.js @@ -1,18 +1,27 @@ -const fs = require("fs"); -const path = require("path"); -const Ajv = require("ajv"); +function validateConfig() { + const fs = require("fs"); + const path = require("path"); + const Ajv = require("ajv"); -const configPath = path.join(__dirname, "..", "config.json"); -const schemaPath = path.join(__dirname, "config-schema.json"); + const configPath = path.join(__dirname, "..", "config.json"); + const configSchemaPath = path.join(__dirname, "config-schema.json"); -const config = JSON.parse(fs.readFileSync(configPath, "utf-8")); -const configSchema = JSON.parse(fs.readFileSync(configSchemaPath, "utf-8")); + const config = JSON.parse(fs.readFileSync(configPath, "utf-8")); + const configSchema = JSON.parse(fs.readFileSync(configSchemaPath, "utf-8")); -const ajv = new Ajv(); -const validate = ajv.compile(configSchema); -const valid = validate(config); + const ajv = new Ajv(); + const validate = ajv.compile(configSchema); + const valid = validate(config); -if (!valid) { - console.error($`The config.json file contains syntax errors: ${validate.errors}\nPlease follow the schema that's present on the project's GitHub page: https://github.com/vb2007/discordbot/tree/dev-bank?tab=readme-ov-file#setting-up-the-bot`); - process.exit(1); -} \ No newline at end of file + if (!valid) { + console.error($`The config.json file contains syntax errors: ${validate.errors}\nPlease follow the schema that's present on the project's GitHub page: https://github.com/vb2007/discordbot/tree/dev-bank?tab=readme-ov-file#setting-up-the-bot`); + process.exit(1); + } + else { + console.log("The config.json file's syntax is correct."); + } +} + +module.exports = [ + validateConfig +]; \ No newline at end of file From c36c5388811f76a5164bd4f130db46c2a4cc03fd Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 12 Aug 2024 14:20:24 +0200 Subject: [PATCH 22/78] renamed validation script --- scripts/{verify-config-schema.js => verify-config-syntax.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{verify-config-schema.js => verify-config-syntax.js} (100%) diff --git a/scripts/verify-config-schema.js b/scripts/verify-config-syntax.js similarity index 100% rename from scripts/verify-config-schema.js rename to scripts/verify-config-syntax.js From c727d68a6e96a4872cef33ac570b2c64d1bb6047 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 12 Aug 2024 14:25:05 +0200 Subject: [PATCH 23/78] added exact validation to 2 config schema variables --- scripts/{configSchema.json => config-schema.json} | 4 ++-- scripts/verify-config-syntax.js | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) rename scripts/{configSchema.json => config-schema.json} (79%) diff --git a/scripts/configSchema.json b/scripts/config-schema.json similarity index 79% rename from scripts/configSchema.json rename to scripts/config-schema.json index f72cc63..d054c8f 100644 --- a/scripts/configSchema.json +++ b/scripts/config-schema.json @@ -7,8 +7,8 @@ "databaseName": { "type": "string" }, "databaseUser": { "type": "string" }, "databasePassword": { "type": "string" }, - "logToFile": { "type": "string" }, - "logToDatabase": { "type": "string" } + "logToFile": { "type": "string", "enum": ["True", "False"] }, + "logToDatabase": { "type": "string", "enum": ["True", "False"] } }, "required": [ "token", diff --git a/scripts/verify-config-syntax.js b/scripts/verify-config-syntax.js index 2f39dfe..a161c78 100644 --- a/scripts/verify-config-syntax.js +++ b/scripts/verify-config-syntax.js @@ -22,6 +22,8 @@ function validateConfig() { } } +validateConfig(); + module.exports = [ validateConfig ]; \ No newline at end of file From 98f4d7e5f31c119c19e8174565aaa788fd6011ef Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 12 Aug 2024 14:27:50 +0200 Subject: [PATCH 24/78] fixed config schema error logging --- scripts/verify-config-syntax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/verify-config-syntax.js b/scripts/verify-config-syntax.js index a161c78..b9c60ec 100644 --- a/scripts/verify-config-syntax.js +++ b/scripts/verify-config-syntax.js @@ -14,7 +14,7 @@ function validateConfig() { const valid = validate(config); if (!valid) { - console.error($`The config.json file contains syntax errors: ${validate.errors}\nPlease follow the schema that's present on the project's GitHub page: https://github.com/vb2007/discordbot/tree/dev-bank?tab=readme-ov-file#setting-up-the-bot`); + console.error(`The config.json file contains syntax errors:\n${JSON.stringify(validate.errors, null, 2)}\nPlease follow the schema that's present on the project's GitHub page: https://github.com/vb2007/discordbot/tree/dev-bank?tab=readme-ov-file#setting-up-the-bot`); process.exit(1); } else { From c3bdc87de864993e66e5c155d913d45654e09178 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 12 Aug 2024 15:13:31 +0200 Subject: [PATCH 25/78] mde config syntax validation check executeable with npm run, updated test calls --- index.js | 14 ++++++++---- package.json | 1 + scripts/verify-config-syntax.js | 40 +++++++++++++-------------------- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/index.js b/index.js index 90c1c7e..c2192c2 100755 --- a/index.js +++ b/index.js @@ -1,8 +1,17 @@ const fs = require("node:fs"); const path = require("node:path"); + +//checks database connection +const db = require("./helpers/db"); +db.getConnection(); + +//verifies the config.json file's syntax +require("./scripts/verify-config-syntax"); + +// validateConfig(); + const { Client, Collection, Events, GatewayIntentBits, ActivityType } = require("discord.js"); const { token } = require("./config.json"); -const db = require("./helpers/db"); const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers] }); @@ -13,9 +22,6 @@ client.once(Events.ClientReady, readyClient => { client.commands = new Collection(); -//checks database connection -db.getConnection(); - //gets command from the "/commands" folder's subfolders const foldersPath = path.join(__dirname, "commands"); const commandFolders = fs.readdirSync(foldersPath); diff --git a/package.json b/package.json index a6f1428..860368b 100755 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "dev": "nodemon index.js", "deploy": "node deploy-commands.js", "create-tables": "node create-tables.js", + "verify-config": "node ./scripts/verify-config-syntax.js", "test": "jest" } } diff --git a/scripts/verify-config-syntax.js b/scripts/verify-config-syntax.js index b9c60ec..e313bec 100644 --- a/scripts/verify-config-syntax.js +++ b/scripts/verify-config-syntax.js @@ -1,29 +1,21 @@ -function validateConfig() { - const fs = require("fs"); - const path = require("path"); - const Ajv = require("ajv"); +const fs = require("fs"); +const path = require("path"); +const Ajv = require("ajv"); - const configPath = path.join(__dirname, "..", "config.json"); - const configSchemaPath = path.join(__dirname, "config-schema.json"); +const configPath = path.join(__dirname, "..", "config.json"); +const configSchemaPath = path.join(__dirname, "config-schema.json"); - const config = JSON.parse(fs.readFileSync(configPath, "utf-8")); - const configSchema = JSON.parse(fs.readFileSync(configSchemaPath, "utf-8")); +const config = JSON.parse(fs.readFileSync(configPath, "utf-8")); +const configSchema = JSON.parse(fs.readFileSync(configSchemaPath, "utf-8")); - const ajv = new Ajv(); - const validate = ajv.compile(configSchema); - const valid = validate(config); +const ajv = new Ajv(); +const validate = ajv.compile(configSchema); +const valid = validate(config); - if (!valid) { - console.error(`The config.json file contains syntax errors:\n${JSON.stringify(validate.errors, null, 2)}\nPlease follow the schema that's present on the project's GitHub page: https://github.com/vb2007/discordbot/tree/dev-bank?tab=readme-ov-file#setting-up-the-bot`); - process.exit(1); - } - else { - console.log("The config.json file's syntax is correct."); - } +if (!valid) { + console.error(`The config.json file contains syntax errors:\n${JSON.stringify(validate.errors, null, 2)}\nPlease follow the schema that's present on the project's GitHub page: https://github.com/vb2007/discordbot/tree/dev-bank?tab=readme-ov-file#setting-up-the-bot`); + process.exit(1); } - -validateConfig(); - -module.exports = [ - validateConfig -]; \ No newline at end of file +else { + console.log("The config.json file's syntax is correct."); +} \ No newline at end of file From a988bc70e23d0e718d2005f3b9b6bf605239f53d Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 15 Aug 2024 22:29:18 +0200 Subject: [PATCH 26/78] fixed biging and nullable db record problem with /deposit --- commands/economy/balance.js | 2 +- commands/economy/deposit.js | 11 +++++++---- sql/economy/table.sql | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/commands/economy/balance.js b/commands/economy/balance.js index aee2629..45cce39 100644 --- a/commands/economy/balance.js +++ b/commands/economy/balance.js @@ -1,6 +1,6 @@ const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); -const db = require("../../helpers/db"); const { logToFileAndDatabase } = require("../../helpers/logger"); +const db = require("../../helpers/db"); module.exports = { data: new SlashCommandBuilder() diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 569ab00..78e3e64 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -2,7 +2,7 @@ const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); -module.ecports = { +module.exports = { data: new SlashCommandBuilder() .setName("deposit") .setDescription("Desposits a specified amount of money to your bank account.") @@ -16,8 +16,8 @@ module.ecports = { const amount = interaction.options.getInteger("amount"); const interactionUserId = interaction.user.id; const query = await db.query("SELECT balance, balanceInBank FROM economy WHERE userId = ?", [interactionUserId]); - const balanceInBank = query[0]?.balanceInBank || null; - const balance = query[0]?.balance || null; + const balanceInBank = Number(query[0]?.balanceInBank) || null; + const balance = Number(query[0]?.balance) || null; if (balance < amount) { var replyContent = `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\`.`; @@ -29,8 +29,11 @@ module.ecports = { amount, interactionUserId ] - ) + ); + console.log(balance); + console.log(amount); + console.log(balanceInBank); var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\`.\nYour current balance in the bank is \`$${balanceInBank + amount}\`.`; } diff --git a/sql/economy/table.sql b/sql/economy/table.sql index 4be81c1..642eda9 100644 --- a/sql/economy/table.sql +++ b/sql/economy/table.sql @@ -4,8 +4,8 @@ CREATE TABLE IF NOT EXISTS `economy` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `userName` text DEFAULT NULL, `userId` bigint(20) NOT NULL, - `balance` bigint(20) DEFAULT 0, - `balanceInBank` bigint(20) DEFAULT 0, + `balance` bigint(20) DEFAULT 0 NOT NULL, + `balanceInBank` bigint(20) DEFAULT 0 NOT NULL, `firstTransactionDate` datetime NOT NULL DEFAULT current_timestamp(), `lastWorkTime` datetime DEFAULT NULL, `lastRobTime` datetime DEFAULT NULL, From 7997be6a545c317cc487619444b4a713a778fa72 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 15 Aug 2024 22:29:53 +0200 Subject: [PATCH 27/78] removed logging --- commands/economy/deposit.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 78e3e64..32031af 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -31,9 +31,6 @@ module.exports = { ] ); - console.log(balance); - console.log(amount); - console.log(balanceInBank); var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\`.\nYour current balance in the bank is \`$${balanceInBank + amount}\`.`; } From 087bf4f0e42b3f73ccefbbaadf84d9d0b3a95da8 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 22 Aug 2024 13:58:31 +0200 Subject: [PATCH 28/78] added dotenv package, updated packages --- package-lock.json | 948 +++++++++++++++++++++++----------------------- package.json | 1 + 2 files changed, 481 insertions(+), 468 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5789a52..705ad06 100755 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "ajv": "^8.17.1", "cheerio": "^1.0.0-rc.12", "discord.js": "^14.14.1", + "dotenv": "^16.4.5", "fetch": "^1.1.0", "jest": "^29.7.0", "mariadb": "^3.3.0", @@ -47,30 +48,30 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.0.tgz", - "integrity": "sha512-P4fwKI2mjEb3ZU5cnMJzvRsRKGBUcs8jvxIoRmr6ufAY9Xk2Bz7JubRTTivkw55c7WQJfTECeqYVa+HZ0FzREg==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.4.tgz", + "integrity": "sha512-+LGRog6RAsCJrrrg/IO6LGmpphNe5DiK30dGjCoxxeGv49B10/3XYGxPsAwrDlMFcFEvdAUavDT8r9k/hSyQqQ==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.24.9", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.9.tgz", - "integrity": "sha512-5e3FI4Q3M3Pbr21+5xJwCv6ZT6KmGkI0vw3Tozy5ODAQFTIWe37iT8Cr7Ice2Ntb+M3iSKCEWMB1MBgKrW3whg==", + "version": "7.25.2", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.2.tgz", + "integrity": "sha512-BBt3opiCOxUr9euZ5/ro/Xv8/V7yJ5bjYMqG/C1YAo8MIKAnumZalCN+msbci3Pigy4lIQfPUpfMM27HMGaYEA==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.24.9", - "@babel/helper-compilation-targets": "^7.24.8", - "@babel/helper-module-transforms": "^7.24.9", - "@babel/helpers": "^7.24.8", - "@babel/parser": "^7.24.8", - "@babel/template": "^7.24.7", - "@babel/traverse": "^7.24.8", - "@babel/types": "^7.24.9", + "@babel/generator": "^7.25.0", + "@babel/helper-compilation-targets": "^7.25.2", + "@babel/helper-module-transforms": "^7.25.2", + "@babel/helpers": "^7.25.0", + "@babel/parser": "^7.25.0", + "@babel/template": "^7.25.0", + "@babel/traverse": "^7.25.2", + "@babel/types": "^7.25.2", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -85,22 +86,13 @@ "url": "https://opencollective.com/babel" } }, - "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/@babel/generator": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.0.tgz", - "integrity": "sha512-3LEEcj3PVW8pW2R1SR1M89g/qrYk/m/mB/tLqn7dn4sbBUQyTqnlod+II2U4dqiGtUmkcnAmkMDralTFZttRiw==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.4.tgz", + "integrity": "sha512-NFtZmZsyzDPJnk9Zg3BbTfKKc9UlHYzD0E//p2Z3B9nCwwtJW9T0gVbCz8+fBngnn4zf1Dr3IK8PHQQHq0lDQw==", "dev": true, "dependencies": { - "@babel/types": "^7.25.0", + "@babel/types": "^7.25.4", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^2.5.1" @@ -110,12 +102,12 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.24.8.tgz", - "integrity": "sha512-oU+UoqCHdp+nWVDkpldqIQL/i/bvAv53tRqLG/s+cOXxe66zOYLU7ar/Xs3LdmBihrUMEUhwu6dMZwbNOYDwvw==", + "version": "7.25.2", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.2.tgz", + "integrity": "sha512-U2U5LsSaZ7TAt3cfaymQ8WHh0pxvdHoEk6HVpaexxixjyEquMh0L0YNJNM6CTGKMXV1iksi0iZkGw4AcFkPaaw==", "dev": true, "dependencies": { - "@babel/compat-data": "^7.24.8", + "@babel/compat-data": "^7.25.2", "@babel/helper-validator-option": "^7.24.8", "browserslist": "^4.23.1", "lru-cache": "^5.1.1", @@ -125,15 +117,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-compilation-targets/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/@babel/helper-module-imports": { "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.24.7.tgz", @@ -148,15 +131,15 @@ } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.0.tgz", - "integrity": "sha512-bIkOa2ZJYn7FHnepzr5iX9Kmz8FjIz4UKzJ9zhX3dnYuVW0xul9RuR3skBfoLu+FPTQw90EHW9rJsSZhyLQ3fQ==", + "version": "7.25.2", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.2.tgz", + "integrity": "sha512-BjyRAbix6j/wv83ftcVJmBt72QtHI56C7JXZoG2xATiLpmoC7dpd8WnkikExHDVPpi/3qCmO6WY1EaXOluiecQ==", "dev": true, "dependencies": { "@babel/helper-module-imports": "^7.24.7", "@babel/helper-simple-access": "^7.24.7", "@babel/helper-validator-identifier": "^7.24.7", - "@babel/traverse": "^7.25.0" + "@babel/traverse": "^7.25.2" }, "engines": { "node": ">=6.9.0" @@ -314,10 +297,13 @@ } }, "node_modules/@babel/parser": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.0.tgz", - "integrity": "sha512-CzdIU9jdP0dg7HdyB+bHvDJGagUv+qtzZt5rYCWwW6tITNqV9odjp6Qu41gkG0ca5UfdDUWrKkiAnHHdGRnOrA==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.4.tgz", + "integrity": "sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA==", "dev": true, + "dependencies": { + "@babel/types": "^7.25.4" + }, "bin": { "parser": "bin/babel-parser.js" }, @@ -361,6 +347,36 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-syntax-class-static-block": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", + "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-attributes": { + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.24.7.tgz", + "integrity": "sha512-hbX+lKKeUMGihnK8nvKqmXBInriT3GVjzXKFriV3YC6APGxMbP8RZNFwy91+hocLXq90Mta+HshoB31802bb8A==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.24.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-import-meta": { "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", @@ -472,6 +488,21 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-syntax-private-property-in-object": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", + "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-top-level-await": { "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", @@ -488,12 +519,12 @@ } }, "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.24.7.tgz", - "integrity": "sha512-c/+fVeJBB0FeKsFvwytYiUD+LBvhHjGSI0g446PRGdSVGZLRNArBUno2PETbAly3tpiNAQR5XaZ+JslxkotsbA==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.4.tgz", + "integrity": "sha512-uMOCoHVU52BsSWxPOMVv5qKRdeSlPuImUCB2dlPuBSU+W2/ROE7/Zg8F2Kepbk+8yBa68LlRKxO+xgEVWorsDg==", "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" + "@babel/helper-plugin-utils": "^7.24.8" }, "engines": { "node": ">=6.9.0" @@ -517,16 +548,16 @@ } }, "node_modules/@babel/traverse": { - "version": "7.25.1", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.1.tgz", - "integrity": "sha512-LrHHoWq08ZpmmFqBAzN+hUdWwy5zt7FGa/hVwMcOqW6OVtwqaoD5utfuGYU87JYxdZgLUvktAsn37j/sYR9siA==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.4.tgz", + "integrity": "sha512-VJ4XsrD+nOvlXyLzmLzUs/0qjFS4sK30te5yEFlvbbUNEgKaVb2BHZUpAL+ttLPQAHNrsI3zZisbfha5Cvr8vg==", "dev": true, "dependencies": { "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.25.0", - "@babel/parser": "^7.25.0", + "@babel/generator": "^7.25.4", + "@babel/parser": "^7.25.4", "@babel/template": "^7.25.0", - "@babel/types": "^7.25.0", + "@babel/types": "^7.25.4", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -535,9 +566,9 @@ } }, "node_modules/@babel/types": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.0.tgz", - "integrity": "sha512-LcnxQSsd9aXOIgmmSpvZ/1yo46ra2ESYyqLcryaBZOghxy5qqOBjvCWP5JfkI8yl9rlxRgdLTTMCQQRcN2hdCg==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.4.tgz", + "integrity": "sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.24.8", @@ -629,6 +660,14 @@ "url": "https://github.com/discordjs/discord.js?sponsor" } }, + "node_modules/@discordjs/rest/node_modules/undici": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.13.0.tgz", + "integrity": "sha512-Q2rtqmZWrbP8nePMq7mOJIN98M0fYvSgV89vwl/BQRT4mDOeY2GXZngfGpcBBhtky3woM7G24wZV3Q304Bv6cw==", + "engines": { + "node": ">=18.0" + } + }, "node_modules/@discordjs/util": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.0.tgz", @@ -715,15 +754,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/console/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/@jest/core": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.7.0.tgz", @@ -771,15 +801,6 @@ } } }, - "node_modules/@jest/core/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/@jest/environment": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.7.0.tgz", @@ -895,15 +916,6 @@ } } }, - "node_modules/@jest/reporters/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/@jest/schemas": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", @@ -960,15 +972,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/test-sequencer/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/@jest/transform": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", @@ -995,15 +998,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/@jest/transform/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/@jest/types": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", @@ -1203,11 +1197,11 @@ } }, "node_modules/@types/node": { - "version": "22.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.0.tgz", - "integrity": "sha512-VT7KSYudcPOzP5Q0wfbowyNLaVR8QWUdw+088uFWwfvpY6uCWaXpqV6ieLAu9WBcnTa7H4Z5RLK8I5t2FuOcqw==", + "version": "22.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz", + "integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==", "dependencies": { - "undici-types": "~6.11.1" + "undici-types": "~6.19.2" } }, "node_modules/@types/stack-utils": { @@ -1225,9 +1219,9 @@ } }, "node_modules/@types/yargs": { - "version": "17.0.32", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.32.tgz", - "integrity": "sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==", + "version": "17.0.33", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", + "integrity": "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==", "dev": true, "dependencies": { "@types/yargs-parser": "*" @@ -1240,9 +1234,9 @@ "dev": true }, "node_modules/@vladfrangu/async_event_emitter": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.4.tgz", - "integrity": "sha512-ZL62PFXEIeGUI8btfJ5S8Flc286eU1ZUSjwyFQtIGXfRUDPZKO+CDJMYb1R71LjGWRZ4n202O+a6FGjsgTw58g==", + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.6.tgz", + "integrity": "sha512-RaI5qZo6D2CVS6sTHFKg1v5Ohq/+Bo2LZ5gzUEwZ/WkHhwtGTCB/sVLw8ijOkAUxasZ+WshN/Rzj4ywsABJ5ZA==", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" @@ -1278,6 +1272,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -1349,9 +1352,9 @@ } }, "node_modules/aws4": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.0.tgz", - "integrity": "sha512-3AungXC4I8kKsS9PuS4JH2nc+0bVY/mjgrephHTIi8fpEeGsTHBUJeosp0Wc1myYMElmD0B3Oc4XL/HVJ4PV2g==", + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.1.tgz", + "integrity": "sha512-u5w79Rd7SU4JaIlA/zFqG+gOiuq25q5VLyZ8E+ijJeILuTxVzZgp2CaGw/UTw6pXYN9XMO9yiqj/nEHmhTG5CA==", "peer": true }, "node_modules/babel-jest": { @@ -1375,15 +1378,6 @@ "@babel/core": "^7.8.0" } }, - "node_modules/babel-jest/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/babel-plugin-istanbul": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", @@ -1416,15 +1410,6 @@ "node": ">=8" } }, - "node_modules/babel-plugin-istanbul/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/babel-plugin-jest-hoist": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz", @@ -1441,23 +1426,26 @@ } }, "node_modules/babel-preset-current-node-syntax": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", - "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.1.0.tgz", + "integrity": "sha512-ldYss8SbBlWva1bs28q78Ju5Zq1F+8BrqBZZ0VFhLBvhh6lCpC2o3gDJi/5DRLs9FgYZCnmPYIVFU4lRXCkyUw==", "dev": true, "dependencies": { "@babel/plugin-syntax-async-generators": "^7.8.4", "@babel/plugin-syntax-bigint": "^7.8.3", - "@babel/plugin-syntax-class-properties": "^7.8.3", - "@babel/plugin-syntax-import-meta": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.12.13", + "@babel/plugin-syntax-class-static-block": "^7.14.5", + "@babel/plugin-syntax-import-attributes": "^7.24.7", + "@babel/plugin-syntax-import-meta": "^7.10.4", "@babel/plugin-syntax-json-strings": "^7.8.3", - "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", - "@babel/plugin-syntax-numeric-separator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.10.4", "@babel/plugin-syntax-object-rest-spread": "^7.8.3", "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", "@babel/plugin-syntax-optional-chaining": "^7.8.3", - "@babel/plugin-syntax-top-level-await": "^7.8.3" + "@babel/plugin-syntax-private-property-in-object": "^7.14.5", + "@babel/plugin-syntax-top-level-await": "^7.14.5" }, "peerDependencies": { "@babel/core": "^7.0.0" @@ -1550,9 +1538,9 @@ } }, "node_modules/browserslist": { - "version": "4.23.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.2.tgz", - "integrity": "sha512-qkqSyistMYdxAcw+CzbZwlBy8AGmS/eEWs+sEV5TnLRGDOL+C5M2EnH6tlZyg0YoAxGJAFKh61En9BR941GnHA==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.3.tgz", + "integrity": "sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA==", "dev": true, "funding": [ { @@ -1569,9 +1557,9 @@ } ], "dependencies": { - "caniuse-lite": "^1.0.30001640", - "electron-to-chromium": "^1.4.820", - "node-releases": "^2.0.14", + "caniuse-lite": "^1.0.30001646", + "electron-to-chromium": "^1.5.4", + "node-releases": "^2.0.18", "update-browserslist-db": "^1.1.0" }, "bin": { @@ -1615,9 +1603,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001643", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001643.tgz", - "integrity": "sha512-ERgWGNleEilSrHM6iUz/zJNSQTP8Mr21wDWpdgvRwcTXGAq6jMtOUPP4dqFPTdKqZ2wKTdtB+uucZ3MRpAUSmg==", + "version": "1.0.30001651", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz", + "integrity": "sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==", "dev": true, "funding": [ { @@ -1666,20 +1654,24 @@ } }, "node_modules/cheerio": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", - "integrity": "sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0.tgz", + "integrity": "sha512-quS9HgjQpdaXOvsZz82Oz7uxtXiy6UIsIQcpBj7HRw2M63Skasm9qlDocAM7jNuaxdhpPU7c4kJN+gA5MCu4ww==", "dependencies": { "cheerio-select": "^2.1.0", "dom-serializer": "^2.0.0", "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "htmlparser2": "^8.0.1", - "parse5": "^7.0.0", - "parse5-htmlparser2-tree-adapter": "^7.0.0" + "domutils": "^3.1.0", + "encoding-sniffer": "^0.2.0", + "htmlparser2": "^9.1.0", + "parse5": "^7.1.2", + "parse5-htmlparser2-tree-adapter": "^7.0.0", + "parse5-parser-stream": "^7.1.2", + "undici": "^6.19.5", + "whatwg-mimetype": "^4.0.0" }, "engines": { - "node": ">= 6" + "node": ">=18.17" }, "funding": { "url": "https://github.com/cheeriojs/cheerio?sponsor=1" @@ -1746,6 +1738,20 @@ "integrity": "sha512-a3KdPAANPbNE4ZUv9h6LckSl9zLsYOP4MBmhIPkRaeyybt+r4UghLvq+xw/YwUcC1gqylCkL4rdVs3Lwupjm4Q==", "dev": true }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -1804,6 +1810,12 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, + "node_modules/core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", + "peer": true + }, "node_modules/create-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", @@ -1825,6 +1837,20 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/css-select": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", @@ -1976,6 +2002,14 @@ "url": "https://github.com/discordjs/discord.js?sponsor" } }, + "node_modules/discord.js/node_modules/undici": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.13.0.tgz", + "integrity": "sha512-Q2rtqmZWrbP8nePMq7mOJIN98M0fYvSgV89vwl/BQRT4mDOeY2GXZngfGpcBBhtky3woM7G24wZV3Q304Bv6cw==", + "engines": { + "node": ">=18.0" + } + }, "node_modules/dom-serializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", @@ -2027,6 +2061,17 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -2038,9 +2083,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.2.tgz", - "integrity": "sha512-kc4r3U3V3WLaaZqThjYz/Y6z8tJe+7K0bbjUVo3i+LWIypVdMx5nXCkwRe6SWbY6ILqLdc1rKcKmr3HoH7wjSQ==", + "version": "1.5.13", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.13.tgz", + "integrity": "sha512-lbBcvtIJ4J6sS4tb5TLp1b4LyfCdMkwStzXPyAgVgTRAsep4bvrAGaBOP7ZJtQMNJpSQ9SqG4brWOroNaQtm7Q==", "dev": true }, "node_modules/emittery": { @@ -2069,6 +2114,29 @@ "iconv-lite": "~0.4.13" } }, + "node_modules/encoding-sniffer": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/encoding-sniffer/-/encoding-sniffer-0.2.0.tgz", + "integrity": "sha512-ju7Wq1kg04I3HtiYIOrUrdfdDvkyO9s5XM8QAj/bN61Yo/Vb4vgJxy5vi4Yxk01gWHbrofpPtpxM8bKger9jhg==", + "dependencies": { + "iconv-lite": "^0.6.3", + "whatwg-encoding": "^3.1.1" + }, + "funding": { + "url": "https://github.com/fb55/encoding-sniffer?sponsor=1" + } + }, + "node_modules/encoding/node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", @@ -2120,6 +2188,29 @@ "node": ">=4" } }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, "node_modules/exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", @@ -2330,6 +2421,18 @@ "node": ">=8.0.0" } }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -2460,9 +2563,9 @@ "dev": true }, "node_modules/htmlparser2": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", - "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-9.1.0.tgz", + "integrity": "sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==", "funding": [ "https://github.com/fb55/htmlparser2?sponsor=1", { @@ -2473,8 +2576,8 @@ "dependencies": { "domelementtype": "^2.3.0", "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "entities": "^4.4.0" + "domutils": "^3.1.0", + "entities": "^4.5.0" } }, "node_modules/http-signature": { @@ -2502,11 +2605,11 @@ } }, "node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" + "safer-buffer": ">= 2.1.2 < 3.0.0" }, "engines": { "node": ">=0.10.0" @@ -2582,9 +2685,9 @@ } }, "node_modules/is-core-module": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", - "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", + "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", "dev": true, "dependencies": { "hasown": "^2.0.2" @@ -2644,16 +2747,28 @@ "node": ">=0.12.0" } }, - "node_modules/is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", - "peer": true - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", + "peer": true + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "node_modules/isstream": { @@ -2713,33 +2828,6 @@ "node": ">=10" } }, - "node_modules/istanbul-lib-report/node_modules/make-dir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", - "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", - "dev": true, - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/istanbul-lib-report/node_modules/semver": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", - "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/istanbul-lib-source-maps": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", @@ -2807,124 +2895,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-changed-files/node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/jest-changed-files/node_modules/execa": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, - "node_modules/jest-changed-files/node_modules/get-stream": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/jest-changed-files/node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/jest-changed-files/node_modules/npm-run-path": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "dev": true, - "dependencies": { - "path-key": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-changed-files/node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-changed-files/node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-changed-files/node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/jest-changed-files/node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/jest-circus": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.7.0.tgz", @@ -2956,15 +2926,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-circus/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/jest-cli": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.7.0.tgz", @@ -2998,47 +2959,6 @@ } } }, - "node_modules/jest-cli/node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/jest-cli/node_modules/yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "dev": true, - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/jest-cli/node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "dev": true, - "engines": { - "node": ">=12" - } - }, "node_modules/jest-config": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.7.0.tgz", @@ -3084,15 +3004,6 @@ } } }, - "node_modules/jest-config/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/jest-diff": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz", @@ -3235,15 +3146,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-message-util/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/jest-mock": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.7.0.tgz", @@ -3317,15 +3219,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-resolve/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/jest-runner": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.7.0.tgz", @@ -3391,15 +3284,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/jest-runtime/node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/jest-snapshot": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.7.0.tgz", @@ -3685,6 +3569,33 @@ "resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.10.0.tgz", "integrity": "sha512-/k20Lg2q8LE5xiaaSkMXk4sfvI+9EGEykFS4b0CHHGWqDYU0bGUFSwchNOMA56D7TCs9GwVTkqe9als1/ns8UQ==" }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/makeerror": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", @@ -3710,22 +3621,11 @@ } }, "node_modules/mariadb/node_modules/@types/node": { - "version": "20.14.13", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.13.tgz", - "integrity": "sha512-+bHoGiZb8UiQ0+WEtmph2IWQCjIqg8MDZMAV+ppRRhUZnquF5mQkP/9vpSwJClEiSM/C7fZZExPzfU0vJTyp8w==", - "dependencies": { - "undici-types": "~5.26.4" - } - }, - "node_modules/mariadb/node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "version": "20.16.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.1.tgz", + "integrity": "sha512-zJDo7wEadFtSyNz5QITDfRcrhqDvQI1xQNQ0VoizPjM/dVAODqqIUWbJPkvsxmTI0MYRGRikcdjMPhOssnPejQ==", "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" + "undici-types": "~6.19.2" } }, "node_modules/mariadb/node_modules/lru-cache": { @@ -3733,11 +3633,6 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==" }, - "node_modules/mariadb/node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" - }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -3757,6 +3652,15 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "peer": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/mime-types": { "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", @@ -3769,15 +3673,6 @@ "node": ">= 0.6" } }, - "node_modules/mime-types/node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "peer": true, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -3939,6 +3834,18 @@ "node": ">=0.10.0" } }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/nth-check": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", @@ -4075,6 +3982,17 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, + "node_modules/parse5-parser-stream": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-7.1.2.tgz", + "integrity": "sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==", + "dependencies": { + "parse5": "^7.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -4093,6 +4011,15 @@ "node": ">=0.10.0" } }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", @@ -4408,6 +4335,36 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -4444,6 +4401,15 @@ "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", "dev": true }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -4553,15 +4519,6 @@ "node": ">=8" } }, - "node_modules/strip-ansi/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/strip-bom": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", @@ -4734,17 +4691,17 @@ "dev": true }, "node_modules/undici": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.13.0.tgz", - "integrity": "sha512-Q2rtqmZWrbP8nePMq7mOJIN98M0fYvSgV89vwl/BQRT4mDOeY2GXZngfGpcBBhtky3woM7G24wZV3Q304Bv6cw==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.8.tgz", + "integrity": "sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g==", "engines": { - "node": ">=18.0" + "node": ">=18.17" } }, "node_modules/undici-types": { - "version": "6.11.1", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.11.1.tgz", - "integrity": "sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==" + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" }, "node_modules/update-browserslist-db": { "version": "1.1.0", @@ -4821,12 +4778,6 @@ "extsprintf": "^1.2.0" } }, - "node_modules/verror/node_modules/core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", - "peer": true - }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", @@ -4844,6 +4795,40 @@ "node": ">= 8" } }, + "node_modules/whatwg-encoding": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz", + "integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==", + "dependencies": { + "iconv-lite": "0.6.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-mimetype": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", + "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", + "engines": { + "node": ">=18" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -4915,6 +4900,33 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 860368b..5452ff0 100755 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "ajv": "^8.17.1", "cheerio": "^1.0.0-rc.12", "discord.js": "^14.14.1", + "dotenv": "^16.4.5", "fetch": "^1.1.0", "jest": "^29.7.0", "mariadb": "^3.3.0", From 1e599d67efeb519cbd2480c62db923e14b4125c8 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 22 Aug 2024 21:54:46 +0200 Subject: [PATCH 29/78] added .env example, added config.json example, updated .gitignore --- .env.example | 7 +++++++ .gitignore | 1 + config.json.example | 13 +++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 .env.example create mode 100644 config.json.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..614e020 --- /dev/null +++ b/.env.example @@ -0,0 +1,7 @@ +TOKEN=BOT-TOKE-GOES-HERE +CLIENT_ID=CLIENT-ID-GOES-HERE + +DATABASE_HOST_ADDRESS=192.168.0.3 +DATABASE_NAME=discordbotTest +DATABASE_USER=vb2007 +DATABASE_PASSWORD=securepassword \ No newline at end of file diff --git a/.gitignore b/.gitignore index 895518a..128c3a5 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.env config.json /node_modules /test diff --git a/config.json.example b/config.json.example new file mode 100644 index 0000000..6e7dcd8 --- /dev/null +++ b/config.json.example @@ -0,0 +1,13 @@ +{ + "//" : "Logging settings", + + "logToFile" : "True", + "logToDatabase" : "True", + + + "//": "Appearance settings", + + "mainEmbedColor" : "0x123456", + "successEmbedColor" : "0x123456", + "failureEmbedColor" : "0x123456" +} \ No newline at end of file From 6b300c3fca661cf2c1aadbe26970dfc2de5d624d Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 22 Aug 2024 22:51:15 +0200 Subject: [PATCH 30/78] updated index.js and deploy-commands.js, implemented using the new .env file --- deploy-commands.js | 18 +++++++++++------- index.js | 12 +++--------- scripts/config-schema.json | 12 ------------ 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/deploy-commands.js b/deploy-commands.js index 8e188ff..68f2263 100755 --- a/deploy-commands.js +++ b/deploy-commands.js @@ -1,20 +1,24 @@ +const token = process.env.TOKEN; +const clientId = process.env.CLIENT_ID; +console.log(token); + const { REST, Routes } = require('discord.js'); -const { clientId, token } = require('./config.json'); const fs = require('node:fs'); const path = require('node:path'); const commands = []; -//fő (commands) mappa megadása + +//specifying the path to the commands const foldersPath = path.join(__dirname, 'commands'); const commandFolders = fs.readdirSync(foldersPath); for (const folder of commandFolders) { - //almappákból .js végződésű fájlok kiszedése + //getting .js files from the commands folder const commandsPath = path.join(foldersPath, folder); const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); - //commandok json-ba töltése + //checking and storing the commands for (const file of commandFiles) { const filePath = path.join(commandsPath, file); @@ -33,15 +37,15 @@ const rest = new REST().setToken(token); (async () => { try { - console.log(`Started refreshing ${commands.length} application (/) commands.`); + console.log(`Started registering ${commands.length} slash (/) commands at Discord.`); - //commandok regisztrálása + //registering / re-registering the commands await rest.put( Routes.applicationCommands(clientId), { body: commands }, ); - console.log(`Successfully reloaded ${commands.length} application (/) commands.`); + console.log(`Successfully registered ${commands.length} slash (/) commands at Discord.`); } catch (error) { console.error(error); diff --git a/index.js b/index.js index c2192c2..18fd3ed 100755 --- a/index.js +++ b/index.js @@ -1,17 +1,18 @@ const fs = require("node:fs"); const path = require("node:path"); +require('dotenv').config() +const token = process.env.TOKEN; + //checks database connection const db = require("./helpers/db"); db.getConnection(); //verifies the config.json file's syntax require("./scripts/verify-config-syntax"); - // validateConfig(); const { Client, Collection, Events, GatewayIntentBits, ActivityType } = require("discord.js"); -const { token } = require("./config.json"); const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers] }); @@ -118,12 +119,5 @@ client.on("ready", () => { //re-announces the bot's activity in every 20 minutes (in case of an internet outage or something) setInterval(setActivity, 20 * 60 * 1000); -//closes connection to the database when closing the application -// process.on("SIGINT", () => { -// console.log("Closing MariaDB database pool connection(s)..."); -// db.end(); -// process.exit(0); -// }); - //logs in with given token client.login(token); \ No newline at end of file diff --git a/scripts/config-schema.json b/scripts/config-schema.json index d054c8f..e1b9f21 100644 --- a/scripts/config-schema.json +++ b/scripts/config-schema.json @@ -1,22 +1,10 @@ { "type": "object", "properties": { - "token": { "type": "string" }, - "clientId": { "type": "string" }, - "databaseHostAddress": { "type": "string" }, - "databaseName": { "type": "string" }, - "databaseUser": { "type": "string" }, - "databasePassword": { "type": "string" }, "logToFile": { "type": "string", "enum": ["True", "False"] }, "logToDatabase": { "type": "string", "enum": ["True", "False"] } }, "required": [ - "token", - "clientId", - "databaseHostAddress", - "databaseName", - "databaseUser", - "databasePassword", "logToFile", "logToDatabase" ] From 2656269ba1d4becdb332f41a8e5c2ddec787f52a Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 24 Aug 2024 23:13:30 +0200 Subject: [PATCH 31/78] changed config.json references to .env references in db.js --- helpers/db.js | 7 ++++++- index.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/helpers/db.js b/helpers/db.js index 47f3d4d..3803855 100755 --- a/helpers/db.js +++ b/helpers/db.js @@ -1,5 +1,10 @@ +require('dotenv').config() +const databaseHostAddress = process.env.DATABASE_HOST_ADDRESS; +const databaseName = process.env.DATABASE_NAME; +const databaseUser = process.env.DATABASE_USER; +const databasePassword = process.env.DATABASE_PASSWORD; + const mariadb = require("mariadb"); -const { databaseHostAddress, databaseName, databaseUser, databasePassword } = require("../config.json"); let pool; diff --git a/index.js b/index.js index 18fd3ed..5ee4bde 100755 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ const fs = require("node:fs"); const path = require("node:path"); -require('dotenv').config() +require('dotenv').config(); const token = process.env.TOKEN; //checks database connection From 207660dc8887fbf3cde90ff1482513d88f5bc09b Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 24 Aug 2024 23:31:47 +0200 Subject: [PATCH 32/78] updated readme.md and example config.json file --- README.md | 33 ++++++++------------------------- config.json.example | 10 +++++----- 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index f095e31..b8d2591 100755 --- a/README.md +++ b/README.md @@ -1,14 +1,12 @@ # Discord bot -A simple discord bot of mine developed with discord.js (Node.js). - -I mainly use it to get the active developer badge on Discord. +A simple discord bot of mine developed with **Node.js**'s [discord.js](https://www.npmjs.com/package/discord.js?activeTab=readme) package. ## Invite the bot **You can invite the bot to your server using [THIS](https://discord.com/oauth2/authorize?client_id=1163073430309044234&scope=bot&permissions=8) link.** -The bot requires administartor permissions. +The bot requires administartor permissions (*&permissions=8*). I'm hosting it, should be online 24/7. @@ -18,31 +16,16 @@ I'm hosting it, should be online 24/7. Do the following for setting up the application from sratch: -1. Clone the repo. -2. Create a `config.json` file in the repo's folder and paste the content above, then fill it out with the correct details: -```json -{ - "token" : "[your token]", - "clientId" : "[your client id]", - - "databaseHostAddress" : "[database host ip]:[database host port]", - "databaseName" : "[database name]", - "databaseUser" : "[database username]", - "databasePassword" : "[database user's password]", - - "logToFile" : "[True/False]", - "logToDatabase" : "[True/False]" -} -``` -3. Like you would with any other node.js app, install dependencies with with the `npm i` command. +1. Clone the repository. +2. Create a `.env` file, or rename the existing [.env.example](./.env.example) file, and fill it out with the required data. +3. Create a `config.json` file, or rename the existing [config.json.example](./config.json.example) file, and fill it out with the required configuration settings. +4. Like you would with any other node.js app, install dependencies with with the `npm i` command. ### Setting up a database for the bot -Some of the bot's features require a MariaDB database. - -If you already have a working database, and filled up the details in the `config.json` file for the connection, you can run `npm run create-tables`. +Some of the bot's features **require a MariaDB database**. -This will automatically create the tables based on the SQL queries that can be found in the [sql folder](sql/). +If you already have a working database, and have filled up the connection details in the `.env` file for the connection, you can just run `npm run create-tables`. This will automatically create the tables based on the SQL queries that can be found in the [sql folder](sql/). Otherwise, please refer to [THIS](documentation/mariadb-setup.md) documentation for addittional help about setting up a database. diff --git a/config.json.example b/config.json.example index 6e7dcd8..758b128 100644 --- a/config.json.example +++ b/config.json.example @@ -1,13 +1,13 @@ { "//" : "Logging settings", - "logToFile" : "True", - "logToDatabase" : "True", + "logToFile" : "[True/False]", + "logToDatabase" : "[True/False]", "//": "Appearance settings", - "mainEmbedColor" : "0x123456", - "successEmbedColor" : "0x123456", - "failureEmbedColor" : "0x123456" + "mainEmbedColor" : "[HEX Color, like: '0x123456']", + "successEmbedColor" : "[HEX Color, like: '0x123456']", + "failureEmbedColor" : "[HEX Color, like: '0x123456']" } \ No newline at end of file From 66ce843e0880f8ca793a965a9c56248572855f23 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 24 Aug 2024 23:33:43 +0200 Subject: [PATCH 33/78] updated example .env --- .env.example | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 614e020..5121a41 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ TOKEN=BOT-TOKE-GOES-HERE -CLIENT_ID=CLIENT-ID-GOES-HERE +CLIENT_ID=-BOT-CLIENT-ID-GOES-HERE -DATABASE_HOST_ADDRESS=192.168.0.3 -DATABASE_NAME=discordbotTest -DATABASE_USER=vb2007 -DATABASE_PASSWORD=securepassword \ No newline at end of file +DATABASE_HOST_ADDRESS=AN-IP-ADDRESS-OR-DOMAIN-TO-YOUR-DATABASE +DATABASE_NAME=YOUR-DATABASE-NAME +DATABASE_USER=YOUR-DATABASES-USERNAME +DATABASE_PASSWORD=YOUR-DATABASES-PASSWORD \ No newline at end of file From bd2ab3bf176f0792d4dfac960d9bb9ddd7f52603 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 24 Aug 2024 23:37:06 +0200 Subject: [PATCH 34/78] updated /help --- commands/utility/help.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands/utility/help.js b/commands/utility/help.js index 6ee111c..049c26a 100755 --- a/commands/utility/help.js +++ b/commands/utility/help.js @@ -29,7 +29,8 @@ module.exports = { "`/balance` - Displays the user's balance.\n" + // "`/deposit` - Deposits money into the user's bank account.\n" + // "`/withdraw` - Withdraws money from the user's bank account.\n" + - // "`/transfer` - Transfers money from one user to another.\n" + + // "`/pay` - Transfers money from one user to another.\n" + + "`/roulette` - Lets you pick a color, then gives you a great price if you guess the color right.\n" + "`/leaderboard` - Displays users with the most money on the server." }, { name: "Moderation", value: From 26a4f07889f14b4889f72538b91ca8954a34a6de Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 24 Aug 2024 23:49:10 +0200 Subject: [PATCH 35/78] added embed reply helper --- helpers/embed-reply.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 helpers/embed-reply.js diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js new file mode 100644 index 0000000..f6a0624 --- /dev/null +++ b/helpers/embed-reply.js @@ -0,0 +1,36 @@ +const { EmbedBuilder } = require("discord.js"); + +function embedReply(color, title, description) { + const embedReply = new EmbedBuilder({ + color: color, + title: title, + description: description, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + return embedReply; +} + +function moderationDmEmbedReply(color, title, description) { + const embedDmReply = new EmbedBuilder({ + color: color, + title: title, + description: description, + timestamp: new Date().toISOString(), + footer: { + text: `Moderator: ${interaction.user.username}` , + icon_url: interaction.user.displayAvatarURL({ dynamic: true }), + }, + }); + + return embedDmReply; +} + +module.exports = { + embedReply, + moderationDmEmbedReply, +} \ No newline at end of file From ad0b9f844dc3118c2e6616e2597991b0841e3693 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 24 Aug 2024 23:49:46 +0200 Subject: [PATCH 36/78] updated /deposit --- commands/economy/deposit.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 32031af..d58fc40 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -2,6 +2,10 @@ const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); +//should be configureable in the future with the config.json file +const dailyDepositLimit = 10; +const feePercentage = 0.5; + module.exports = { data: new SlashCommandBuilder() .setName("deposit") @@ -16,12 +20,33 @@ module.exports = { const amount = interaction.options.getInteger("amount"); const interactionUserId = interaction.user.id; const query = await db.query("SELECT balance, balanceInBank FROM economy WHERE userId = ?", [interactionUserId]); - const balanceInBank = Number(query[0]?.balanceInBank) || null; - const balance = Number(query[0]?.balance) || null; + const balanceInBank = Number(query[0]?.balanceInBank) || 0; + const balance = Number(query[0]?.balance) || 0; + const dailyDeposits = Number(query[0]?.dailyDeposits) || 0; if (balance < amount) { var replyContent = `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\`.`; } + else if (dailyDeposits >= dailyDepositLimit) { + const fee = amount * feePercentage; + const totalAmount = amount + fee; + + if (balance < totalAmount) { + var replyContent = `You can't deposit that much money into your bank account.\nYour balance is \`$${balance}\`,\nbut you currently can't pay the deposit fee: \`$${fee}\`.`; + } + else { + var embedReply = new EmbedBuilder({ + color: 0x5F0FD6, + title: "Depositing.", + description: replyContent, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + } + } else { await db.query("UPDATE economy SET balance = balance - ?, balanceInBank = balanceInBank + ? WHERE userId = ?", [ From 8cf0276a031231d6254e2c356889ea57b8c50abf Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 25 Aug 2024 00:51:39 +0200 Subject: [PATCH 37/78] updated import, embed-reply, implemented function calls in autorole configure --- archived-commands/index2.js | 112 ------------------ commands/administration/autorole-configure.js | 55 ++++++--- helpers/embed-reply.js | 4 +- 3 files changed, 38 insertions(+), 133 deletions(-) delete mode 100755 archived-commands/index2.js diff --git a/archived-commands/index2.js b/archived-commands/index2.js deleted file mode 100755 index 917a835..0000000 --- a/archived-commands/index2.js +++ /dev/null @@ -1,112 +0,0 @@ -// Import modules -const { Client, GatewayIntentBits, ActivityType } = require('discord.js'); -const { Routes } = require('discord-api-types/v9'); -const { REST } = require('@discordjs/rest'); -const { token, clientId } = require('../config.json'); -const { SlashCommandBuilder } = require('@discordjs/builders'); - -const client = new Client({ intents: [GatewayIntentBits.Guilds] }); -console.log("client created"); - -client.once('ready', () => { - console.log('Ready!'); -}); - -console.log("token processed"); -client.login(token); -console.log("logged in"); - -console.log("clientid set") - -client.on('ready', (c) => { - client.user.setActivity({ - name: 'Femboys are attractive as fuck.', - type: ActivityType.Playing, - url: 'https://vb2007.hu/ref/D0ld', - }); -}); - - -const pingCommand = new SlashCommandBuilder() -.setName('ping') -.setDescription('Replies with Pong!'); - -const feetCommand = new SlashCommandBuilder() -.setName('skellylaba') -.setDescription('Küld egy képet Skelly lábáról.'); - -const pyCommand = new SlashCommandBuilder() -.setName('py') -.setDescription('facts.'); - -client.on('interactionCreate', async interaction => { - if (!interaction.isCommand()) return; - - const { commandName } = interaction; - - if (commandName === 'ping') { - await interaction.reply('Pong!\nJust for the fucking active developer badge.\nI hate slash commands.'); - } - - if (commandName === 'skellylaba') { - await interaction.reply('Skelly szőrös lába :hot_face: :https://cdn.discordapp.com/attachments/1177710851344564234/1177710869371687035/image.png'); - } - - if (commandName === 'py') { - await interaction.reply('.py egy autista geci (és nem küld képet a lábáról)'); - } -}); - -// Create a rest instance -const rest = new REST({ version: '9' }).setToken(token); - -module.exports = { - data: new SlashCommandBuilder() - .setName('kick') - .setDescription('Kicks a user from the server.') - .addUserOption(option => - option.setName('target') - .setDescription('The user to kick') - .setRequired(true) - ), - async execute(interaction) { - const user = interaction.options.getUser('target'); - const member = interaction.guild.members.resolve(user); - - if (!interaction.member.permissions.has(Permissions.FLAGS.KICK_MEMBERS)) { - return interaction.reply({ content: 'You do not have permission to use this command.', ephemeral: true }); - } - - if (!member) { - return interaction.reply({ content: 'User is not a member of this server.', ephemeral: true }); - } - - if (!member.kickable) { - return interaction.reply({ content: 'I cannot kick this user.', ephemeral: true }); - } - - await member.kick(); - return interaction.reply({ content: `Successfully kicked ${user.tag}` }); - }, -}; - -// Register the ping command as a global command -(async () => { - try { - console.log('Started refreshing application (/) commands.'); - - await rest.put( - Routes.applicationCommands(clientId), - {body: [ - pingCommand.toJSON(), - feetCommand.toJSON(), - pyCommand.toJSON() - ]}, - ); - - console.log('Successfully reloaded application (/) commands.'); - } - catch (error) { - console.error(error); - } -})(); diff --git a/commands/administration/autorole-configure.js b/commands/administration/autorole-configure.js index ae1515e..46d13c0 100755 --- a/commands/administration/autorole-configure.js +++ b/commands/administration/autorole-configure.js @@ -1,4 +1,6 @@ -const { EmbedBuilder, SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const { embedReply } = require("../../helpers/embed-reply"); +const { embedColors } = require("../../config.json"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -15,10 +17,20 @@ module.exports = { .setDMPermission(false), async execute(interaction) { if (!interaction.inGuild()) { - var replyContent = "You can only set autorole in a server."; + var localEmbedResponse = embedReply( + embedColors.error, + "Error", + "You can only set autorole in a server.", + interaction + ); } else if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.Administrator)) { - var replyContent = "This feature requires **administrator** *(8)* privileges witch the bot currently lacks.\nIf you want this feature to work, please re-invite the bot with accurate privileges." + var localEmbedResponse = embedReply( + embedColors.error, + "Error", + "This feature requires **administrator** *(8)* privileges witch the bot currently lacks.\nIf you want this feature to work, please re-invite the bot with accurate privileges.", + interaction + ); } else { try { @@ -33,16 +45,32 @@ module.exports = { //if autorole has already been configured at this server... if (autoRoleRoleId == targetRole) { - replyContent = "Autorole has been already configured for this server with this role. :x:\nRun the command with another role to overwrite the current role.\nRun `/autorole-disable` to disable this feature."; + var localEmbedResponse = embedReply( + embedColors.error, + "Error", + "Autorole has been already configured for this server with this role. :x:\nRun the command with another role to overwrite the current role.\nRun `/autorole-disable` to disable this feature.", + interaction + ); } else { if (autoRoleGuildId == guildId) { //if the target role is already the role that's in the database, then we don't need to insert data - replyContent = `The role that will get assigned to new members has been **modified** to \`@<${targetRole}>\` :white_check_mark:\nRun this command again to modify the role.\nRun \`/autorole-disable\` to disable this feature.`; + var localEmbedResponse = embedReply( + embedColors.successSecondary, + "Autorole Configuration Modified", + `The role that will get assigned to new members has been **modified** to \`@<${targetRole}>\` :white_check_mark:\nRun this command again to modify the role.\nRun \`/autorole-disable\` to disable this feature.`, + interaction + ); } else { - var replyContent = `The role that will get assigned to new members has been **set** to \`@<${targetRole}>\` :white_check_mark:\nRun this command again to modify the role.\nRun \`/autorole-disable\` to disable this feature."` + var localEmbedResponse = embedReply( + embedColors.success, + "Autorole Configuration Set", + `The role that will get assigned to new members has been **set** to \`@<${targetRole}>\` :white_check_mark:\nRun this command again to modify the role.\nRun \`/autorole-disable\` to disable this feature.`, + interaction + ); } + await db.query("INSERT INTO autorole (guildId, roleId, adderId, adderUsername) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE roleId = ?, adderId = ?, adderUsername = ?", [guildId, targetRole, adderId, adderUsername, targetRole, adderId, adderUsername]); } } @@ -51,21 +79,10 @@ module.exports = { } } - var embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Configuring autorole.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); - - await interaction.reply({ embeds: [embedReply] }); + await interaction.reply({ embeds: [localEmbedResponse] }); //logging - const response = JSON.stringify(embedReply.toJSON()); + const response = JSON.stringify(localEmbedResponse.toJSON()); await logToFileAndDatabase(interaction, response); } } \ No newline at end of file diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index f6a0624..b12a8da 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -1,6 +1,6 @@ const { EmbedBuilder } = require("discord.js"); -function embedReply(color, title, description) { +function embedReply(color, title, description, interaction) { const embedReply = new EmbedBuilder({ color: color, title: title, @@ -15,7 +15,7 @@ function embedReply(color, title, description) { return embedReply; } -function moderationDmEmbedReply(color, title, description) { +function moderationDmEmbedReply(color, title, description, interaction) { const embedDmReply = new EmbedBuilder({ color: color, title: title, From c16d1ff8748e6c59422c4e4d0e129533c824b0bf Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 25 Aug 2024 00:57:49 +0200 Subject: [PATCH 38/78] fixed embed reply helper parsing, updated example config json --- commands/administration/autorole-configure.js | 6 +++--- config.json.example | 10 +++++++--- helpers/embed-reply.js | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/commands/administration/autorole-configure.js b/commands/administration/autorole-configure.js index 46d13c0..677ad6c 100755 --- a/commands/administration/autorole-configure.js +++ b/commands/administration/autorole-configure.js @@ -18,7 +18,7 @@ module.exports = { async execute(interaction) { if (!interaction.inGuild()) { var localEmbedResponse = embedReply( - embedColors.error, + embedColors.failure, "Error", "You can only set autorole in a server.", interaction @@ -26,7 +26,7 @@ module.exports = { } else if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.Administrator)) { var localEmbedResponse = embedReply( - embedColors.error, + embedColors.failure, "Error", "This feature requires **administrator** *(8)* privileges witch the bot currently lacks.\nIf you want this feature to work, please re-invite the bot with accurate privileges.", interaction @@ -46,7 +46,7 @@ module.exports = { //if autorole has already been configured at this server... if (autoRoleRoleId == targetRole) { var localEmbedResponse = embedReply( - embedColors.error, + embedColors.failure, "Error", "Autorole has been already configured for this server with this role. :x:\nRun the command with another role to overwrite the current role.\nRun `/autorole-disable` to disable this feature.", interaction diff --git a/config.json.example b/config.json.example index 758b128..2261bc3 100644 --- a/config.json.example +++ b/config.json.example @@ -7,7 +7,11 @@ "//": "Appearance settings", - "mainEmbedColor" : "[HEX Color, like: '0x123456']", - "successEmbedColor" : "[HEX Color, like: '0x123456']", - "failureEmbedColor" : "[HEX Color, like: '0x123456']" + "embedColors": { + "primary" : "[HEX Color, like: '0x5F0FD6']", + "success" : "[HEX Color, like: '0x0DFF00']", + "successSecondary" : "[HEX Color, like: '0x87FF9D']", + "failure" : "[HEX Color, like: '0xFF0D0D']", + "warning" : "[HEX Color, like: '0xE3F51B']" + } } \ No newline at end of file diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index b12a8da..9a645b3 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -2,7 +2,7 @@ const { EmbedBuilder } = require("discord.js"); function embedReply(color, title, description, interaction) { const embedReply = new EmbedBuilder({ - color: color, + color: parseInt(color), title: title, description: description, timestamp: new Date().toISOString(), @@ -17,7 +17,7 @@ function embedReply(color, title, description, interaction) { function moderationDmEmbedReply(color, title, description, interaction) { const embedDmReply = new EmbedBuilder({ - color: color, + color: parseInt(color), title: title, description: description, timestamp: new Date().toISOString(), From 1118a53b0319468626a0478d5fb464ee7af44c7c Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 25 Aug 2024 01:26:46 +0200 Subject: [PATCH 39/78] updated embed reply hlper, added function calls to autorole disable --- commands/administration/autorole-configure.js | 10 ++-- commands/administration/autorole-disable.js | 47 ++++++++++++------- helpers/embed-reply.js | 8 ++++ 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/commands/administration/autorole-configure.js b/commands/administration/autorole-configure.js index 677ad6c..790c614 100755 --- a/commands/administration/autorole-configure.js +++ b/commands/administration/autorole-configure.js @@ -19,7 +19,7 @@ module.exports = { if (!interaction.inGuild()) { var localEmbedResponse = embedReply( embedColors.failure, - "Error", + "AutoRole Configure: Error", "You can only set autorole in a server.", interaction ); @@ -27,7 +27,7 @@ module.exports = { else if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.Administrator)) { var localEmbedResponse = embedReply( embedColors.failure, - "Error", + "AutoRole Configure: Error", "This feature requires **administrator** *(8)* privileges witch the bot currently lacks.\nIf you want this feature to work, please re-invite the bot with accurate privileges.", interaction ); @@ -47,7 +47,7 @@ module.exports = { if (autoRoleRoleId == targetRole) { var localEmbedResponse = embedReply( embedColors.failure, - "Error", + "AutoRole Configure: Error", "Autorole has been already configured for this server with this role. :x:\nRun the command with another role to overwrite the current role.\nRun `/autorole-disable` to disable this feature.", interaction ); @@ -57,7 +57,7 @@ module.exports = { //if the target role is already the role that's in the database, then we don't need to insert data var localEmbedResponse = embedReply( embedColors.successSecondary, - "Autorole Configuration Modified", + "AutoRole Configure: Configuration Modified", `The role that will get assigned to new members has been **modified** to \`@<${targetRole}>\` :white_check_mark:\nRun this command again to modify the role.\nRun \`/autorole-disable\` to disable this feature.`, interaction ); @@ -65,7 +65,7 @@ module.exports = { else { var localEmbedResponse = embedReply( embedColors.success, - "Autorole Configuration Set", + "AutoRole Configure: Configuration Set", `The role that will get assigned to new members has been **set** to \`@<${targetRole}>\` :white_check_mark:\nRun this command again to modify the role.\nRun \`/autorole-disable\` to disable this feature.`, interaction ); diff --git a/commands/administration/autorole-disable.js b/commands/administration/autorole-disable.js index 41aef88..e40bfbb 100755 --- a/commands/administration/autorole-disable.js +++ b/commands/administration/autorole-disable.js @@ -1,4 +1,6 @@ -const { EmbedBuilder, SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const { embedReply } = require("../../helpers/embed-reply"); +const { embedColors } = require("../../config.json"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -10,10 +12,20 @@ module.exports = { .setDMPermission(false), async execute(interaction) { if (!interaction.inGuild()) { - var replyContent = "You can only disable autorole in a server." + var localEmbedResponse = embedReply( + embedColors.failure, + "AutoRole Disable: Error", + "You can only disable autorole in a server.", + interaction + ); } else if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.Administartor)) { - var replyContent = "This feature requires **administrator** *(8)* privileges witch the bot currently lacks.\nIf you want this feature to work, please re-invite the bot with accurate privileges." + var localEmbedResponse = embedReply( + embedColors.failure, + "AutoRole Disable: Error", + "This feature requires **administrator** *(8)* privileges witch the bot currently lacks.\nIf you want this feature to work, please re-invite the bot with accurate privileges.", + interaction + ); } else { try { @@ -25,10 +37,20 @@ module.exports = { if (autoroleGuildId) { await db.query("DELETE FROM autorole WHERE guildId = ?", [autoroleGuildId]); - var replyContent = "The autorole feature has been disabled succesfully.\nYou can re-enable it with `/autorole-configure`."; + var localEmbedResponse = embedReply( + embedColors.success, + "AutoRole Disable: Success", + "The autorole feature has been disabled succesfully.\nYou can re-enable it with `/autorole-configure`.", + interaction + ); } else { - var replyContent = "Autorole has not been configured for this server.\nTherefore, you can't disable it.\nYou can enable this feature with `/autorole-configure`"; + var localEmbedResponse = embedReply( + embedColors.warning, + "AutoRole Disable: Warning", + "Autorole has not been configured for this server.\nTherefore, you can't disable it.\nYou can enable this feature with `/autorole-configure`", + interaction + ); } } catch (error) { @@ -36,21 +58,10 @@ module.exports = { } } - var embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Disabling autorole.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); - - await interaction.reply({ embeds: [embedReply] }); + await interaction.reply({ embeds: [localEmbedResponse] }); //logging - const response = JSON.stringify(embedReply.toJSON()); + const response = JSON.stringify(localEmbedResponse.toJSON()); await logToFileAndDatabase(interaction, response); }, }; \ No newline at end of file diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index 9a645b3..0b1d8ca 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -1,5 +1,13 @@ const { EmbedBuilder } = require("discord.js"); +/** + * + * @param {color} color - Embed's sidebar HEX Color + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ function embedReply(color, title, description, interaction) { const embedReply = new EmbedBuilder({ color: parseInt(color), From e1b4374d7319b4e6f7d319a754b7f9737f8d1024 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 25 Aug 2024 13:52:55 +0200 Subject: [PATCH 40/78] used embed reply helper in /balance --- commands/economy/balance.js | 40 +++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/commands/economy/balance.js b/commands/economy/balance.js index aee2629..432096a 100644 --- a/commands/economy/balance.js +++ b/commands/economy/balance.js @@ -1,4 +1,6 @@ -const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("discord.js"); +const { embedReply } = require("../../helpers/embed-reply"); +const { embedColors } = require("../../config.json"); const db = require("../../helpers/db"); const { logToFileAndDatabase } = require("../../helpers/logger"); @@ -14,7 +16,12 @@ module.exports = { .setDMPermission(false), async execute(interaction) { if(!interaction.inGuild()) { - var replyContent = "You can only check a member's balance in a server."; + var localEmbedResponse = embedReply( + embedColors.failure, + "Balance: Error", + "You can only check a member's balance in a server.", + interaction + ); } else { const interactionUserId = interaction.user.id; @@ -23,30 +30,29 @@ module.exports = { if(!targetUserId) { var query = await db.query("SELECT balance FROM economy WHERE userId = ?", [interactionUserId]); - var replyContent = `<@${interactionUserId}>'s balance is **${query[0]?.balance}**. :moneybag:`; + var localEmbedResponse = embedReply( + embedColors.primary, + "Balance", + `<@${interactionUserId}>'s balance is **${query[0]?.balance}**. :moneybag:`, + interaction + ); } else { var query = await db.query("SELECT balance FROM economy WHERE userId = ?", [targetUserId]); - var replyContent = `<@${targetUserId}>'s balance is **${query[0]?.balance}**. :moneybag:`; + var localEmbedResponse = embedReply( + embedColors.primary, + "Balance", + `<@${targetUserId}>'s balance is **${query[0]?.balance}**. :moneybag:`, + interaction + ); } } - var embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Checking user balance.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}`, - icon_url: interaction.user.displayAvatarURL({ dynamic: true }) - } - }); - - await interaction.reply({ embeds: [embedReply] }); + await interaction.reply({ embeds: [localEmbedResponse] }); //logging - const response = JSON.stringify(embedReply.toJSON()); + const response = JSON.stringify(localEmbedResponse.toJSON()); await logToFileAndDatabase(interaction, response); } } \ No newline at end of file From 1a28beaaf8fd00e7a0641e42ab94bee32e1f04a3 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 25 Aug 2024 18:46:22 +0200 Subject: [PATCH 41/78] added info to package.json --- package.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/package.json b/package.json index 5452ff0..c2cea7b 100755 --- a/package.json +++ b/package.json @@ -1,4 +1,12 @@ { + "name": "discordbot", + "version": "2.2", + "description": "A simple discord bot of mine developed with discord.js (Node.js).", + "main": "index.js", + "keywords": ["discordbot", "discord", "bot", "sql", "mariadb"], + "author": "vb2007 (https://vb2007.hu)", + "license": "AGPL-3.0-only", + "dependencies": { "ajv": "^8.17.1", "cheerio": "^1.0.0-rc.12", @@ -11,10 +19,12 @@ "node-fetch": "^3.3.2", "request-promise": "^4.2.6" }, + "devDependencies": { "jest": "^29.7.0", "nodemon": "^3.0.2" }, + "scripts": { "app": "node index.js", "dev": "nodemon index.js", From 4c55f68ca77bcd4f5b83779d21ada4dca428299d Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 25 Aug 2024 22:45:37 +0200 Subject: [PATCH 42/78] removed node-cron package, updated package and package-lock json files --- package-lock.json | 24 ++++-------------------- package.json | 12 +++++++----- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 705ad06..cd83f7c 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,13 @@ { "name": "discordbot", + "version": "2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { + "name": "discordbot", + "version": "2.2", + "license": "AGPL-3.0-only", "dependencies": { "ajv": "^8.17.1", "cheerio": "^1.0.0-rc.12", @@ -12,7 +16,6 @@ "fetch": "^1.1.0", "jest": "^29.7.0", "mariadb": "^3.3.0", - "node-cron": "^3.0.3", "node-fetch": "^3.3.2", "request-promise": "^4.2.6" }, @@ -3706,17 +3709,6 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, - "node_modules/node-cron": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.3.tgz", - "integrity": "sha512-dOal67//nohNgYWb+nWmg5dkFdIwDm8EpeGYMekPMrngV3637lqnX0lbUcCtgibHTz6SEz7DAIjKvKDFYCnO1A==", - "dependencies": { - "uuid": "8.3.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/node-domexception": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", @@ -4742,14 +4734,6 @@ "punycode": "^2.1.0" } }, - "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/v8-to-istanbul": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", diff --git a/package.json b/package.json index c2cea7b..1fd767c 100755 --- a/package.json +++ b/package.json @@ -3,10 +3,15 @@ "version": "2.2", "description": "A simple discord bot of mine developed with discord.js (Node.js).", "main": "index.js", - "keywords": ["discordbot", "discord", "bot", "sql", "mariadb"], + "keywords": [ + "discordbot", + "discord", + "bot", + "sql", + "mariadb" + ], "author": "vb2007 (https://vb2007.hu)", "license": "AGPL-3.0-only", - "dependencies": { "ajv": "^8.17.1", "cheerio": "^1.0.0-rc.12", @@ -15,16 +20,13 @@ "fetch": "^1.1.0", "jest": "^29.7.0", "mariadb": "^3.3.0", - "node-cron": "^3.0.3", "node-fetch": "^3.3.2", "request-promise": "^4.2.6" }, - "devDependencies": { "jest": "^29.7.0", "nodemon": "^3.0.2" }, - "scripts": { "app": "node index.js", "dev": "nodemon index.js", From e530e591faf3e8d4be194d7e078738bff2f277b1 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 25 Aug 2024 22:51:02 +0200 Subject: [PATCH 43/78] package fix --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index cd83f7c..38ec080 100755 --- a/package-lock.json +++ b/package-lock.json @@ -3643,9 +3643,9 @@ "dev": true }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "dependencies": { "braces": "^3.0.3", From cfd6148832565e71486527a6acec2e1b0e790227 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 25 Aug 2024 23:06:12 +0200 Subject: [PATCH 44/78] added command helper --- helpers/command-helper.js | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 helpers/command-helper.js diff --git a/helpers/command-helper.js b/helpers/command-helper.js new file mode 100644 index 0000000..c278026 --- /dev/null +++ b/helpers/command-helper.js @@ -0,0 +1,60 @@ +const { Collection } = require('discord.js'); +const fs = require('fs'); +const path = require('path'); + +class CommandHandler { + constructor(client) { + this.client = client; + this.client.commands = new Collection(); + this.loadCommands(); + } + + loadCommands() { + const foldersPath = path.join(__dirname, "../commands"); + const commandFolders = fs.readdirSync(foldersPath); + + for (const folder of commandFolders) { + const commandsPath = path.join(foldersPath, folder); + const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); + + for (const file of commandFiles) { + const filePath = path.join(commandsPath, file); + const command = require(filePath); + + if ("data" in command && "execute" in command) { + this.client.commands.set(command.data.name, command); + } + else { + console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`); + } + } + } + } + + async handleInteraction(interaction) { + if (!interaction.isChatInputCommand()) return; + + const command = this.client.commands.get(interaction.commandName); + + if (!command) { + console.error(`No command matching ${interaction.commandName} was found.`); + return; + } + + try { + await command.execute(interaction); + } + catch (error) { + console.error(error); + + if (interaction.replied || interaction.deferred) { + await interaction.followUp({ content: "There was an error while executing this command!", ephemeral: true }); + } + else { + await interaction.reply({ content: "There was an error while executing this command!", ephemeral: true }); + } + } + } +} + +module.exports = CommandHandler; \ No newline at end of file From 57b18a001c122b3c4d04eefa7df6f50ff372353b Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 28 Aug 2024 08:13:17 +0200 Subject: [PATCH 45/78] added daily deposit limit and limit resetting --- commands/economy/deposit.js | 12 ++++++++++-- sql/economy/table.sql | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index d58fc40..6da29e1 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -22,7 +22,14 @@ module.exports = { const query = await db.query("SELECT balance, balanceInBank FROM economy WHERE userId = ?", [interactionUserId]); const balanceInBank = Number(query[0]?.balanceInBank) || 0; const balance = Number(query[0]?.balance) || 0; - const dailyDeposits = Number(query[0]?.dailyDeposits) || 0; + let dailyDeposits = Number(query[0]?.dailyDeposits) || 0; + const lastDepositDate = query[0]?.lastDepositDate; + const now = new Date(); + + //resets daily deposits if the last deposit was not today + if (lastDepositDate && lastDepositDate.toDateString() !== now.toDateString()) { + dailyDeposits = 0; + } if (balance < amount) { var replyContent = `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\`.`; @@ -48,10 +55,11 @@ module.exports = { } } else { - await db.query("UPDATE economy SET balance = balance - ?, balanceInBank = balanceInBank + ? WHERE userId = ?", + await db.query("UPDATE economy SET balance = balance - ?, balanceInBank = balanceInBank + ?, dailyDeposits = dailyDeposits + 1, lastDepositTime = ? WHERE userId = ?", [ amount, amount, + now, interactionUserId ] ); diff --git a/sql/economy/table.sql b/sql/economy/table.sql index 642eda9..eeb43e8 100644 --- a/sql/economy/table.sql +++ b/sql/economy/table.sql @@ -10,6 +10,7 @@ CREATE TABLE IF NOT EXISTS `economy` ( `lastWorkTime` datetime DEFAULT NULL, `lastRobTime` datetime DEFAULT NULL, `lastRouletteTime` datetime DEFAULT NULL, + `lastDepositTime` datetime DEFAULT NULL, `robSuccessChance` float DEFAULT 1, PRIMARY KEY (`id`) ); \ No newline at end of file From 80e57119ea3d281edb7432b325334620102998c9 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 28 Aug 2024 09:16:29 +0200 Subject: [PATCH 46/78] updated /deposit's deposit limit logic, updated stuffs --- commands/economy/balance.js | 1 - commands/economy/deposit.js | 8 ++++---- commands/economy/withdraw.js | 6 +++--- helpers/db.js | 2 +- sql/economy/table.sql | 1 + 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/commands/economy/balance.js b/commands/economy/balance.js index 368843f..432096a 100644 --- a/commands/economy/balance.js +++ b/commands/economy/balance.js @@ -3,7 +3,6 @@ const { embedReply } = require("../../helpers/embed-reply"); const { embedColors } = require("../../config.json"); const db = require("../../helpers/db"); const { logToFileAndDatabase } = require("../../helpers/logger"); -const db = require("../../helpers/db"); module.exports = { data: new SlashCommandBuilder() diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 6da29e1..dfa440e 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -19,18 +19,18 @@ module.exports = { async execute(interaction) { const amount = interaction.options.getInteger("amount"); const interactionUserId = interaction.user.id; - const query = await db.query("SELECT balance, balanceInBank FROM economy WHERE userId = ?", [interactionUserId]); + const query = await db.query("SELECT balance, balanceInBank, dailyDeposits, lastDepositTime FROM economy WHERE userId = ?", [interactionUserId]); const balanceInBank = Number(query[0]?.balanceInBank) || 0; const balance = Number(query[0]?.balance) || 0; let dailyDeposits = Number(query[0]?.dailyDeposits) || 0; - const lastDepositDate = query[0]?.lastDepositDate; + const lastDepositTime = query[0]?.lastDepositTime; const now = new Date(); //resets daily deposits if the last deposit was not today - if (lastDepositDate && lastDepositDate.toDateString() !== now.toDateString()) { + if (lastDepositTime && lastDepositTime.toDateString() !== now.toDateString()) { dailyDeposits = 0; } - + console.log(dailyDeposits); if (balance < amount) { var replyContent = `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\`.`; } diff --git a/commands/economy/withdraw.js b/commands/economy/withdraw.js index 615f0cc..7538403 100644 --- a/commands/economy/withdraw.js +++ b/commands/economy/withdraw.js @@ -16,14 +16,14 @@ module.exports = { const amount = interaction.options.getInteger("amount"); const interactionUserId = interaction.user.id; const query = await db.query("SELECT balance, balanceInBank FROM economy WHERE userId = ?", [interactionUserId]); - const balance = query[0]?.balance || null; - const balanceInBank = query[0]?.balanceInBank || null; + const balance = Number(query[0]?.balance) || 0; + const balanceInBank = Number(query[0]?.balanceInBank) || 0; if (balanceInBank < amount) { var replyContent = `You can't withdraw that much money from your bank account.\nYour current bank balance is only \`$${balanceInBank}\`.`; } else { - await db.query("UPDATE economy SET balance = balance + ?, balanceInBank = balanceInBank - ? WHERE userId = ?" + await db.query("UPDATE economy SET balance = balance + ?, balanceInBank = balanceInBank - ? WHERE userId = ?", [ amount, amount, diff --git a/helpers/db.js b/helpers/db.js index 3803855..9b1133b 100755 --- a/helpers/db.js +++ b/helpers/db.js @@ -38,7 +38,7 @@ function getConnection() { }); } -function handleError(error){ +function handleError(error) { console.error("Error while trying to connect to the database: ", error); process.exit(1); } diff --git a/sql/economy/table.sql b/sql/economy/table.sql index eeb43e8..877ac6c 100644 --- a/sql/economy/table.sql +++ b/sql/economy/table.sql @@ -11,6 +11,7 @@ CREATE TABLE IF NOT EXISTS `economy` ( `lastRobTime` datetime DEFAULT NULL, `lastRouletteTime` datetime DEFAULT NULL, `lastDepositTime` datetime DEFAULT NULL, + `dailyDeposits` int DEFAULT 0 NOT NULL, `robSuccessChance` float DEFAULT 1, PRIMARY KEY (`id`) ); \ No newline at end of file From c8559855cca8664849b0c407172e732a639ebda9 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 28 Aug 2024 14:08:19 +0200 Subject: [PATCH 47/78] updated /deposit with payment confirmation methods --- commands/economy/deposit.js | 47 +++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index dfa440e..3c9da2f 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -1,4 +1,4 @@ -const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder } = require("discord.js"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -30,7 +30,7 @@ module.exports = { if (lastDepositTime && lastDepositTime.toDateString() !== now.toDateString()) { dailyDeposits = 0; } - console.log(dailyDeposits); + if (balance < amount) { var replyContent = `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\`.`; } @@ -42,16 +42,43 @@ module.exports = { var replyContent = `You can't deposit that much money into your bank account.\nYour balance is \`$${balance}\`,\nbut you currently can't pay the deposit fee: \`$${fee}\`.`; } else { - var embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Depositing.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}`, - icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + const embedWarning = new MessageEmbed() + .seTitle("Deposit Fee") + .setDescription(`You've reached your daily free deposit limit, but you can still deposit money for a fee of \`$${fee}\`.\nDo you want to deposit the money?`) + .setColor("#FF0000"); + + const row = new ActionRowBuilder() + .addComponents( + new ButtonBuilder() + .setCustomId("confirm") + .setLabel("Confirm") + .setStyle(ButtonStyle.Success), + new ButtonBuilder() + .setCustomId("cancel") + .setLabel("Cancel") + .setStyle(ButtonStyle.Danger) + ); + + const message = await interaction.reply({embeds: [embedWarning], components: [row], fetchReply: true}); + + const filter = i => i.user.id === interaction.user.id; + const collector = message.createMessageComponentCollector({ filter, time: 15000 }); + + collector.on("collect", async i => { + if (i.customId === "confirm") { + await db.query("UPDATE economy SET balance = balance - ?, balanceInBank = balanceInBank + ?, dailyDeposits = dailyDeposits + 1, lastDepositTime = ? WHERE userId = ?", [totalAmount, amount, now, userId]); + await i.update({ content: 'Deposit successful!', embeds: [], components: [] }); + } + else if (i.customId === "cancel") { + await i.update({ content: 'Deposit canceled.', embeds: [], components: [] }); } }); + + collector.on("end", collected => { + if (collected.size === 0) { + interaction.editReply({ content: "No response received. Deposit canceled.", embeds: [], components: [] }); + } + }) } } else { From 986e4bf439d7d290a1cc8f82a53e79f72d103f48 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 29 Aug 2024 10:22:54 +0200 Subject: [PATCH 48/78] updated /deposit --- .github/workflows/unit-tests.yml | 2 +- commands/economy/deposit.js | 49 ++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index a1e5b6b..5a2326d 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -12,7 +12,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Use Node.js + - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: '18' diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 3c9da2f..3b39e7c 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -42,10 +42,16 @@ module.exports = { var replyContent = `You can't deposit that much money into your bank account.\nYour balance is \`$${balance}\`,\nbut you currently can't pay the deposit fee: \`$${fee}\`.`; } else { - const embedWarning = new MessageEmbed() - .seTitle("Deposit Fee") - .setDescription(`You've reached your daily free deposit limit, but you can still deposit money for a fee of \`$${fee}\`.\nDo you want to deposit the money?`) - .setColor("#FF0000"); + var embedWarning = new EmbedBuilder({ + color: 0xFF0000, + title: "Deposit Fee", + description: `You've reached your daily free deposit limit, but you can still deposit money for a fee of \`$${fee}\`.\nDo you want to deposit the money?`, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); const row = new ActionRowBuilder() .addComponents( @@ -66,7 +72,14 @@ module.exports = { collector.on("collect", async i => { if (i.customId === "confirm") { - await db.query("UPDATE economy SET balance = balance - ?, balanceInBank = balanceInBank + ?, dailyDeposits = dailyDeposits + 1, lastDepositTime = ? WHERE userId = ?", [totalAmount, amount, now, userId]); + await db.query("UPDATE economy SET balance = balance - ?, balanceInBank = balanceInBank + ?, dailyDeposits = dailyDeposits + 1, lastDepositTime = ? WHERE userId = ?", + [ + totalAmount, + amount, + now, + interactionUserId + ] + ); await i.update({ content: 'Deposit successful!', embeds: [], components: [] }); } else if (i.customId === "cancel") { @@ -94,21 +107,21 @@ module.exports = { var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\`.\nYour current balance in the bank is \`$${balanceInBank + amount}\`.`; } - var embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Depositing.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}`, - icon_url: interaction.user.displayAvatarURL({ dynamic: true }) - } - }); + // var embedReply = new EmbedBuilder({ + // color: 0x5F0FD6, + // title: "Depositing.", + // description: replyContent, + // timestamp: new Date().toISOString(), + // footer: { + // text: `Requested by: ${interaction.user.username}`, + // icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + // } + // }); - await interaction.reply({ embeds: [embedReply] }); + // await interaction.reply({ embeds: [embedReply] }); //logging - const response = JSON.stringify(embedReply.toJSON()); - await logToFileAndDatabase(interaction, response); + // const response = JSON.stringify(embedReply.toJSON()); + // await logToFileAndDatabase(interaction, response); } } \ No newline at end of file From ef2427e295bcf74758ac774eb2fe2b3234f491f0 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Fri, 30 Aug 2024 12:42:36 +0200 Subject: [PATCH 49/78] added stuffs, updated packages --- commands/economy/deposit.js | 34 ++++++----- helpers/embed-reply.js | 110 +++++++++++++++++++++++++++++++++++- package-lock.json | 106 +++++++++++++++++----------------- 3 files changed, 181 insertions(+), 69 deletions(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 3b39e7c..65ef645 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -17,6 +17,8 @@ module.exports = { .setRequired(true)) .setDMPermission(false), async execute(interaction) { + let isCommandReplied = false; + const amount = interaction.options.getInteger("amount"); const interactionUserId = interaction.user.id; const query = await db.query("SELECT balance, balanceInBank, dailyDeposits, lastDepositTime FROM economy WHERE userId = ?", [interactionUserId]); @@ -42,7 +44,7 @@ module.exports = { var replyContent = `You can't deposit that much money into your bank account.\nYour balance is \`$${balance}\`,\nbut you currently can't pay the deposit fee: \`$${fee}\`.`; } else { - var embedWarning = new EmbedBuilder({ + var embedReply = new EmbedBuilder({ color: 0xFF0000, title: "Deposit Fee", description: `You've reached your daily free deposit limit, but you can still deposit money for a fee of \`$${fee}\`.\nDo you want to deposit the money?`, @@ -65,7 +67,7 @@ module.exports = { .setStyle(ButtonStyle.Danger) ); - const message = await interaction.reply({embeds: [embedWarning], components: [row], fetchReply: true}); + const message = await interaction.reply({embeds: [embedReply], components: [row], fetchReply: true}); const filter = i => i.user.id === interaction.user.id; const collector = message.createMessageComponentCollector({ filter, time: 15000 }); @@ -107,21 +109,23 @@ module.exports = { var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\`.\nYour current balance in the bank is \`$${balanceInBank + amount}\`.`; } - // var embedReply = new EmbedBuilder({ - // color: 0x5F0FD6, - // title: "Depositing.", - // description: replyContent, - // timestamp: new Date().toISOString(), - // footer: { - // text: `Requested by: ${interaction.user.username}`, - // icon_url: interaction.user.displayAvatarURL({ dynamic: true }) - // } - // }); + if (!isCommandReplied) { + var embedReply = new EmbedBuilder({ + color: 0x5F0FD6, + title: "Depositing.", + description: replyContent, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); - // await interaction.reply({ embeds: [embedReply] }); + await interaction.reply({ embeds: [embedReply] }); + } //logging - // const response = JSON.stringify(embedReply.toJSON()); - // await logToFileAndDatabase(interaction, response); + const response = JSON.stringify(embedReply.toJSON()); + await logToFileAndDatabase(interaction, response); } } \ No newline at end of file diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index 0b1d8ca..c878b10 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -1,7 +1,7 @@ const { EmbedBuilder } = require("discord.js"); +const { embedColors } = require("../../config.json"); /** - * * @param {color} color - Embed's sidebar HEX Color * @param {title} title - Embed's title * @param {description} description - Embed's description @@ -23,6 +23,111 @@ function embedReply(color, title, description, interaction) { return embedReply; } +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ +function embedReplyPrimaryColor(title, description, interaction) { + const embedReply = new EmbedBuilder({ + color: embedColors.primary, + title: title, + description: description, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ +function embedReplySuccessColor(title, description, interaction) { + const embedReply = new EmbedBuilder({ + color: embedColors.success, + title: title, + description: description, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ +function embedReplySuccessSecondaryColor(title, description, interaction) { + const embedReply = new EmbedBuilder({ + color: embedColors.successSecondary, + title: title, + description: description, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ +function embedReplyFailureColor(title, description, interaction) { + const embedReply = new EmbedBuilder({ + color: embedColors.failure, + title: title, + description: description, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ +function embedReplyWarningColor(title, description, interaction) { + const embedReply = new EmbedBuilder({ + color: embedColors.warning, + title: title, + description: description, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + return embedReply; +} + function moderationDmEmbedReply(color, title, description, interaction) { const embedDmReply = new EmbedBuilder({ color: parseInt(color), @@ -40,5 +145,8 @@ function moderationDmEmbedReply(color, title, description, interaction) { module.exports = { embedReply, + embedReplyPrimaryColor, + embedReplySuccessColor, + embedReplySuccessSecondaryColor, moderationDmEmbedReply, } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 38ec080..b2db809 100755 --- a/package-lock.json +++ b/package-lock.json @@ -90,12 +90,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.4.tgz", - "integrity": "sha512-NFtZmZsyzDPJnk9Zg3BbTfKKc9UlHYzD0E//p2Z3B9nCwwtJW9T0gVbCz8+fBngnn4zf1Dr3IK8PHQQHq0lDQw==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.6.tgz", + "integrity": "sha512-VPC82gr1seXOpkjAAKoLhP50vx4vGNlF4msF64dSFq1P8RfB+QAuJWGHPXXPc8QyfVWwwB/TNNU4+ayZmHNbZw==", "dev": true, "dependencies": { - "@babel/types": "^7.25.4", + "@babel/types": "^7.25.6", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^2.5.1" @@ -201,13 +201,13 @@ } }, "node_modules/@babel/helpers": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.0.tgz", - "integrity": "sha512-MjgLZ42aCm0oGjJj8CtSM3DB8NOOf8h2l7DCTePJs29u+v7yO/RBX9nShlKMgFnRks/Q4tBAe7Hxnov9VkGwLw==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.6.tgz", + "integrity": "sha512-Xg0tn4HcfTijTwfDwYlvVCl43V6h4KyVVX2aEm4qdO/PC6L2YvzLHFdmxhoeSA3eslcE6+ZVXHgWwopXYLNq4Q==", "dev": true, "dependencies": { "@babel/template": "^7.25.0", - "@babel/types": "^7.25.0" + "@babel/types": "^7.25.6" }, "engines": { "node": ">=6.9.0" @@ -300,12 +300,12 @@ } }, "node_modules/@babel/parser": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.4.tgz", - "integrity": "sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.6.tgz", + "integrity": "sha512-trGdfBdbD0l1ZPmcJ83eNxB9rbEax4ALFTF7fN386TMYbeCQbyme5cOEXQhbGXKebwGaB/J52w1mrklMcbgy6Q==", "dev": true, "dependencies": { - "@babel/types": "^7.25.4" + "@babel/types": "^7.25.6" }, "bin": { "parser": "bin/babel-parser.js" @@ -366,12 +366,12 @@ } }, "node_modules/@babel/plugin-syntax-import-attributes": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.24.7.tgz", - "integrity": "sha512-hbX+lKKeUMGihnK8nvKqmXBInriT3GVjzXKFriV3YC6APGxMbP8RZNFwy91+hocLXq90Mta+HshoB31802bb8A==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.25.6.tgz", + "integrity": "sha512-sXaDXaJN9SNLymBdlWFA+bjzBhFD617ZaFiY13dGt7TVslVvVgA6fkZOP7Ki3IGElC45lwHdOTrCtKZGVAWeLQ==", "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" + "@babel/helper-plugin-utils": "^7.24.8" }, "engines": { "node": ">=6.9.0" @@ -551,16 +551,16 @@ } }, "node_modules/@babel/traverse": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.4.tgz", - "integrity": "sha512-VJ4XsrD+nOvlXyLzmLzUs/0qjFS4sK30te5yEFlvbbUNEgKaVb2BHZUpAL+ttLPQAHNrsI3zZisbfha5Cvr8vg==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.6.tgz", + "integrity": "sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==", "dev": true, "dependencies": { "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.25.4", - "@babel/parser": "^7.25.4", + "@babel/generator": "^7.25.6", + "@babel/parser": "^7.25.6", "@babel/template": "^7.25.0", - "@babel/types": "^7.25.4", + "@babel/types": "^7.25.6", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -569,9 +569,9 @@ } }, "node_modules/@babel/types": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.4.tgz", - "integrity": "sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.6.tgz", + "integrity": "sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.24.8", @@ -1200,9 +1200,9 @@ } }, "node_modules/@types/node": { - "version": "22.5.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz", - "integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==", + "version": "22.5.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.1.tgz", + "integrity": "sha512-KkHsxej0j9IW1KKOOAA/XBA0z08UFSrRQHErzEfA3Vgq57eXIMYboIlHJuYIfd+lwCQjtKqUu3UnmKbtUc9yRw==", "dependencies": { "undici-types": "~6.19.2" } @@ -1355,9 +1355,9 @@ } }, "node_modules/aws4": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.1.tgz", - "integrity": "sha512-u5w79Rd7SU4JaIlA/zFqG+gOiuq25q5VLyZ8E+ijJeILuTxVzZgp2CaGw/UTw6pXYN9XMO9yiqj/nEHmhTG5CA==", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz", + "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==", "peer": true }, "node_modules/babel-jest": { @@ -1606,9 +1606,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001651", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz", - "integrity": "sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==", + "version": "1.0.30001655", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001655.tgz", + "integrity": "sha512-jRGVy3iSGO5Uutn2owlb5gR6qsGngTw9ZTb4ali9f3glshcNmJ2noam4Mo9zia5P9Dk3jNNydy7vQjuE5dQmfg==", "dev": true, "funding": [ { @@ -1736,9 +1736,9 @@ } }, "node_modules/cjs-module-lexer": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.3.1.tgz", - "integrity": "sha512-a3KdPAANPbNE4ZUv9h6LckSl9zLsYOP4MBmhIPkRaeyybt+r4UghLvq+xw/YwUcC1gqylCkL4rdVs3Lwupjm4Q==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.0.tgz", + "integrity": "sha512-N1NGmowPlGBLsOZLPvm48StN04V4YvQRL0i6b7ctrVY3epjP/ct7hFLOItz6pDIvRjwpfPxi52a2UWV2ziir8g==", "dev": true }, "node_modules/cliui": { @@ -2161,9 +2161,9 @@ } }, "node_modules/escalade": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", - "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "dev": true, "engines": { "node": ">=6" @@ -3624,9 +3624,9 @@ } }, "node_modules/mariadb/node_modules/@types/node": { - "version": "20.16.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.1.tgz", - "integrity": "sha512-zJDo7wEadFtSyNz5QITDfRcrhqDvQI1xQNQ0VoizPjM/dVAODqqIUWbJPkvsxmTI0MYRGRikcdjMPhOssnPejQ==", + "version": "20.16.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.2.tgz", + "integrity": "sha512-91s/n4qUPV/wg8eE9KHYW1kouTfDk2FPGjXbBMfRWP/2vg1rCXNQL1OCabwGs0XSdukuK+MwCDXE30QpSeMUhQ==", "dependencies": { "undici-types": "~6.19.2" } @@ -4228,16 +4228,6 @@ "request": "^2.34" } }, - "node_modules/request/node_modules/uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", - "peer": true, - "bin": { - "uuid": "bin/uuid" - } - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -4734,6 +4724,16 @@ "punycode": "^2.1.0" } }, + "node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "peer": true, + "bin": { + "uuid": "bin/uuid" + } + }, "node_modules/v8-to-istanbul": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", From 0d3e041fecf0011ea769fdb8b6520e75f4bcdf72 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Fri, 30 Aug 2024 15:28:08 +0200 Subject: [PATCH 50/78] updated keyword --- package.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 1fd767c..c812e3c 100755 --- a/package.json +++ b/package.json @@ -4,9 +4,15 @@ "description": "A simple discord bot of mine developed with discord.js (Node.js).", "main": "index.js", "keywords": [ - "discordbot", "discord", + "discordjs", + "discordbot", "bot", + "economy", + "gambling", + "moderation", + "administration", + "utility", "sql", "mariadb" ], From 901807cb117cad2609bc09ecda57144a65ef9a3f Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 1 Sep 2024 23:51:49 +0200 Subject: [PATCH 51/78] updated packages, fixed require paths --- commands/economy/deposit.js | 3 ++- helpers/embed-reply.js | 2 +- package-lock.json | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 65ef645..c488ab3 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -31,6 +31,7 @@ module.exports = { //resets daily deposits if the last deposit was not today if (lastDepositTime && lastDepositTime.toDateString() !== now.toDateString()) { dailyDeposits = 0; + await db.query("UPDATE economy SET dailyDeposits = 0 WHERE userId = ?", [interactionUserId]); } if (balance < amount) { @@ -120,7 +121,7 @@ module.exports = { icon_url: interaction.user.displayAvatarURL({ dynamic: true }) } }); - +0 await interaction.reply({ embeds: [embedReply] }); } diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index c878b10..f07b372 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -1,5 +1,5 @@ const { EmbedBuilder } = require("discord.js"); -const { embedColors } = require("../../config.json"); +const { embedColors } = require("../config.json"); /** * @param {color} color - Embed's sidebar HEX Color diff --git a/package-lock.json b/package-lock.json index b2db809..e7f60d3 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1200,9 +1200,9 @@ } }, "node_modules/@types/node": { - "version": "22.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.1.tgz", - "integrity": "sha512-KkHsxej0j9IW1KKOOAA/XBA0z08UFSrRQHErzEfA3Vgq57eXIMYboIlHJuYIfd+lwCQjtKqUu3UnmKbtUc9yRw==", + "version": "22.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.2.tgz", + "integrity": "sha512-acJsPTEqYqulZS/Yp/S3GgeE6GZ0qYODUR8aVr/DkhHQ8l9nd4j5x1/ZJy9/gHrRlFMqkO6i0I3E27Alu4jjPg==", "dependencies": { "undici-types": "~6.19.2" } @@ -3624,9 +3624,9 @@ } }, "node_modules/mariadb/node_modules/@types/node": { - "version": "20.16.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.2.tgz", - "integrity": "sha512-91s/n4qUPV/wg8eE9KHYW1kouTfDk2FPGjXbBMfRWP/2vg1rCXNQL1OCabwGs0XSdukuK+MwCDXE30QpSeMUhQ==", + "version": "20.16.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.3.tgz", + "integrity": "sha512-/wdGiWRkMOm53gAsSyFMXFZHbVg7C6CbkrzHNpaHoYfsUWPg7m6ZRKtvQjgvQ9i8WT540a3ydRlRQbxjY30XxQ==", "dependencies": { "undici-types": "~6.19.2" } From a7b8c1e1fd6ffc3c446877a506bde4bdb05d487d Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 2 Sep 2024 00:52:27 +0200 Subject: [PATCH 52/78] updated /deposit logic, exported new embed reply functions --- commands/economy/deposit.js | 5 +++-- helpers/embed-reply.js | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index c488ab3..d93a950 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -4,7 +4,7 @@ const db = require("../../helpers/db"); //should be configureable in the future with the config.json file const dailyDepositLimit = 10; -const feePercentage = 0.5; +const feePercentage = 0.3; module.exports = { data: new SlashCommandBuilder() @@ -69,6 +69,7 @@ module.exports = { ); const message = await interaction.reply({embeds: [embedReply], components: [row], fetchReply: true}); + isCommandReplied = true; const filter = i => i.user.id === interaction.user.id; const collector = message.createMessageComponentCollector({ filter, time: 15000 }); @@ -121,7 +122,7 @@ module.exports = { icon_url: interaction.user.displayAvatarURL({ dynamic: true }) } }); -0 + await interaction.reply({ embeds: [embedReply] }); } diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index f07b372..ae72257 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -148,5 +148,7 @@ module.exports = { embedReplyPrimaryColor, embedReplySuccessColor, embedReplySuccessSecondaryColor, + embedReplyFailureColor, + embedReplyWarningColor, moderationDmEmbedReply, } \ No newline at end of file From 15b5af2717212dbc6a9f56340e22850cf1ac1d82 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 2 Sep 2024 20:17:50 +0200 Subject: [PATCH 53/78] added displaying the bank balance to the /balance command --- commands/economy/balance.js | 8 ++++---- commands/economy/deposit.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/commands/economy/balance.js b/commands/economy/balance.js index 432096a..d82ea88 100644 --- a/commands/economy/balance.js +++ b/commands/economy/balance.js @@ -28,22 +28,22 @@ module.exports = { const targetUserId = interaction.options.getUser("user")?.id || null; if(!targetUserId) { - var query = await db.query("SELECT balance FROM economy WHERE userId = ?", [interactionUserId]); + var query = await db.query("SELECT balance, balanceInBank FROM economy WHERE userId = ?", [interactionUserId]); var localEmbedResponse = embedReply( embedColors.primary, "Balance", - `<@${interactionUserId}>'s balance is **${query[0]?.balance}**. :moneybag:`, + `<@${interactionUserId}>'s balance is \`$${query[0]?.balance}\`. :moneybag:\nTheir bank balance is \`$${query[0]?.balanceInBank}\`. :bank:`, interaction ); } else { - var query = await db.query("SELECT balance FROM economy WHERE userId = ?", [targetUserId]); + var query = await db.query("SELECT balance, balanceInBank FROM economy WHERE userId = ?", [targetUserId]); var localEmbedResponse = embedReply( embedColors.primary, "Balance", - `<@${targetUserId}>'s balance is **${query[0]?.balance}**. :moneybag:`, + `<@${targetUserId}>'s balance is **${query[0]?.balance}**. :moneybag:\nTheir bank balance is **${query[0]?.balanceInBank}**. :bank:`, interaction ); } diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index d93a950..54bfaad 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -72,7 +72,7 @@ module.exports = { isCommandReplied = true; const filter = i => i.user.id === interaction.user.id; - const collector = message.createMessageComponentCollector({ filter, time: 15000 }); + const collector = message.createMessageComponentCollector({ filter, time: 30000 }); collector.on("collect", async i => { if (i.customId === "confirm") { From a8babe8475e8f04001d73d88b905f920eec6aca4 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 2 Sep 2024 20:32:58 +0200 Subject: [PATCH 54/78] made /deposit and /withdraw design better --- commands/economy/deposit.js | 6 +++--- commands/economy/withdraw.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 54bfaad..87efd87 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -35,7 +35,7 @@ module.exports = { } if (balance < amount) { - var replyContent = `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\`.`; + var replyContent = `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\`. :moneybag:`; } else if (dailyDeposits >= dailyDepositLimit) { const fee = amount * feePercentage; @@ -66,7 +66,7 @@ module.exports = { .setCustomId("cancel") .setLabel("Cancel") .setStyle(ButtonStyle.Danger) - ); + ); const message = await interaction.reply({embeds: [embedReply], components: [row], fetchReply: true}); isCommandReplied = true; @@ -108,7 +108,7 @@ module.exports = { ] ); - var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\`.\nYour current balance in the bank is \`$${balanceInBank + amount}\`.`; + var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\`. :moneybag:\nYour current balance in the bank is \`$${balanceInBank + amount}\`. :bank:`; } if (!isCommandReplied) { diff --git a/commands/economy/withdraw.js b/commands/economy/withdraw.js index 7538403..8a132fe 100644 --- a/commands/economy/withdraw.js +++ b/commands/economy/withdraw.js @@ -20,7 +20,7 @@ module.exports = { const balanceInBank = Number(query[0]?.balanceInBank) || 0; if (balanceInBank < amount) { - var replyContent = `You can't withdraw that much money from your bank account.\nYour current bank balance is only \`$${balanceInBank}\`.`; + var replyContent = `You can't withdraw that much money from your bank account.\nYour current bank balance is only \`$${balanceInBank}\`. :bank:`; } else { await db.query("UPDATE economy SET balance = balance + ?, balanceInBank = balanceInBank - ? WHERE userId = ?", @@ -31,7 +31,7 @@ module.exports = { ] ); - var replyContent = `You've successfully withdrawn \`$${amount}\` from your bank account.\nYour current balance in the bank is \`$${balanceInBank - amount}\`.\nYour current balance is \`$${balance + amount}\`.`; + var replyContent = `You've successfully withdrawn \`$${amount}\` from your bank account.\nYour current balance in the bank is \`$${balanceInBank - amount}\`. :bank:\nYour current balance is \`$${balance + amount}\`. :moneybag:`; } var embedReply = new EmbedBuilder({ From 0b71bed31907f8c640bebec7ddbe22a3eebe4a63 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 15 Sep 2024 23:59:55 +0200 Subject: [PATCH 55/78] used the embed builder helper --- commands/economy/deposit.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 87efd87..16208f1 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -45,16 +45,11 @@ module.exports = { var replyContent = `You can't deposit that much money into your bank account.\nYour balance is \`$${balance}\`,\nbut you currently can't pay the deposit fee: \`$${fee}\`.`; } else { - var embedReply = new EmbedBuilder({ - color: 0xFF0000, - title: "Deposit Fee", - description: `You've reached your daily free deposit limit, but you can still deposit money for a fee of \`$${fee}\`.\nDo you want to deposit the money?`, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}`, - icon_url: interaction.user.displayAvatarURL({ dynamic: true }) - } - }); + const embedReply = embedReplyWarningColor( + "Deposit Fee", + `You've reached your daily free deposit limit, but you can still deposit money for a fee of \`$${fee}\`.\nDo you want to deposit the money?`, + interaction + ); const row = new ActionRowBuilder() .addComponents( From 524aada67d25a59ae2cd68bddb0f77c2cf844f38 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 16 Sep 2024 01:06:06 +0200 Subject: [PATCH 56/78] used embed helpers in /balance and /deposit, fixed some import and other issues, added embed replies --- commands/economy/balance.js | 12 +++----- commands/economy/deposit.js | 57 +++++++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/commands/economy/balance.js b/commands/economy/balance.js index d82ea88..e941529 100644 --- a/commands/economy/balance.js +++ b/commands/economy/balance.js @@ -1,6 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReply } = require("../../helpers/embed-reply"); -const { embedColors } = require("../../config.json"); +const { embedReplyPrimaryColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); const db = require("../../helpers/db"); const { logToFileAndDatabase } = require("../../helpers/logger"); @@ -16,8 +15,7 @@ module.exports = { .setDMPermission(false), async execute(interaction) { if(!interaction.inGuild()) { - var localEmbedResponse = embedReply( - embedColors.failure, + var localEmbedResponse = embedReplyFailureColor( "Balance: Error", "You can only check a member's balance in a server.", interaction @@ -30,8 +28,7 @@ module.exports = { if(!targetUserId) { var query = await db.query("SELECT balance, balanceInBank FROM economy WHERE userId = ?", [interactionUserId]); - var localEmbedResponse = embedReply( - embedColors.primary, + var localEmbedResponse = embedReplyPrimaryColor( "Balance", `<@${interactionUserId}>'s balance is \`$${query[0]?.balance}\`. :moneybag:\nTheir bank balance is \`$${query[0]?.balanceInBank}\`. :bank:`, interaction @@ -40,8 +37,7 @@ module.exports = { else { var query = await db.query("SELECT balance, balanceInBank FROM economy WHERE userId = ?", [targetUserId]); - var localEmbedResponse = embedReply( - embedColors.primary, + var localEmbedResponse = embedReplyPrimaryColor( "Balance", `<@${targetUserId}>'s balance is **${query[0]?.balance}**. :moneybag:\nTheir bank balance is **${query[0]?.balanceInBank}**. :bank:`, interaction diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 16208f1..6deb157 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder } = require("discord.js"); +const { ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder } = require("discord.js"); +const { embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -35,14 +36,22 @@ module.exports = { } if (balance < amount) { - var replyContent = `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\`. :moneybag:`; + var embedReply = embedReplyFailureColor( + "Failed to deposit.", + `You can't deposit that much money into your bank account.\nYour current balance is only \`$${balance}\`. :moneybag:`, + interaction + ); } else if (dailyDeposits >= dailyDepositLimit) { const fee = amount * feePercentage; const totalAmount = amount + fee; if (balance < totalAmount) { - var replyContent = `You can't deposit that much money into your bank account.\nYour balance is \`$${balance}\`,\nbut you currently can't pay the deposit fee: \`$${fee}\`.`; + var embedReply = embedReplyFailureColor( + "Deposit fee.", + `You can't deposit that much money into your bank account.\nYou've reached your daily free deposit limit, and your balance is \`$${balance}\`,\so you currently can't pay the deposit fee: \`$${fee}\`.\n`, + interaction + ); } else { const embedReply = embedReplyWarningColor( @@ -79,16 +88,35 @@ module.exports = { interactionUserId ] ); - await i.update({ content: 'Deposit successful!', embeds: [], components: [] }); + + var embedReply = embedReplySuccessColor( + "Deposit successful.", + `You've successfully deposited \`$${amount}\` for a fee of \`$${fee}\`.\Your balance decreased by total of \`$${totalAmount}\`.`, + interaction + ); + + await i.update({ embeds: [embedReply], components: [] }); } else if (i.customId === "cancel") { - await i.update({ content: 'Deposit canceled.', embeds: [], components: [] }); + var embedReply = embedReplyFailureColor( + "Deposit cancelled.", + `You've cancelled the deposit of \`$${amount}\`.`, + interaction + ); + + await i.update({ embeds: [embedReply], components: [] }); } }); collector.on("end", collected => { if (collected.size === 0) { - interaction.editReply({ content: "No response received. Deposit canceled.", embeds: [], components: [] }); + var embedReply = embedReplyFailureColor( + "Deposit cancelled", + "No response received. Deposit canceled.", + interaction + ); + + interaction.editReply({ embeds: [embedReply], components: [] }); } }) } @@ -103,21 +131,14 @@ module.exports = { ] ); - var replyContent = `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\`. :moneybag:\nYour current balance in the bank is \`$${balanceInBank + amount}\`. :bank:`; + var embedReply = embedReplySuccessColor( + "Deposit successful.", + `You've successfully deposited \`$${amount}\` into your bank account.\nYour current balance is \`$${balance - amount}\`. :moneybag:\nYour current balance in the bank is \`$${balanceInBank + amount}\`. :bank:`, + interaction + ); } if (!isCommandReplied) { - var embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Depositing.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}`, - icon_url: interaction.user.displayAvatarURL({ dynamic: true }) - } - }); - await interaction.reply({ embeds: [embedReply] }); } From 5e61f661e5bdc76e44d56a52686f3042cc0151ad Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 16 Sep 2024 14:54:49 +0200 Subject: [PATCH 57/78] used the helper functions in the /leaderboard command --- commands/economy/leaderboard.js | 39 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/commands/economy/leaderboard.js b/commands/economy/leaderboard.js index 008cb66..edfb7f4 100644 --- a/commands/economy/leaderboard.js +++ b/commands/economy/leaderboard.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("discord.js"); +const { embedReplyPrimaryColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); const db = require("../../helpers/db"); const { logToFileAndDatabase } = require("../../helpers/logger"); @@ -17,10 +18,18 @@ module.exports = { var amount = interaction.options.getInteger("amount") || 10; if(!interaction.inGuild()) { - var replyContent = "You can only check a member's balance in a server."; + var embedReply = embedReplyFailureColor( + "Leaderboard - Error", + "You can only check a member's balance in a server.", + interaction + ); } else if (amount > 100){ - var replyContent = "Cannot display more than 100 users.\nPlease try again with a smaller amount."; + var embedReply = embedReplyFailureColor( + "Leaderboard - Error", + "Cannot display more than 100 users.\nPlease try again with a smaller amount.", + interaction + ); } else { var query = await db.query("SELECT userId, balance FROM economy ORDER BY balance DESC LIMIT ?", [amount]); @@ -37,25 +46,21 @@ module.exports = { var replyContent = replyContent + `\n\nEnd of the leaderboard. :eyes:\nThis server has **${totalUserAmount}** user${totalUserAmount !== 1 ? 's' : ''} with a balance.`; if (actualUserAmount == 0) { - var replyTitle = "Empty leaderboard."; - var replyContent = "There are no users with a balance on this server.\nUse the `/work` command to be the first one on this list! :grin:" + var embedReply = embedReplyFailureColor( + "Empty leaderboard.", + "There are no users with a balance on this server.\nUse the `/work` command to be the first one on this list! :grin:", + interaction + ); } else { - var replyTitle = `Server leaderboard: TOP ${actualUserAmount} user${actualUserAmount !== 1 ? 's' : ''}.`; + var embedReply = embedReplyPrimaryColor( + `Server leaderboard: TOP ${actualUserAmount} user${actualUserAmount !== 1 ? 's' : ''}.`, + replyContent, + interaction + ); } } - var embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: replyTitle, - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}`, - icon_url: interaction.user.displayAvatarURL({ dynamic: true }) - } - }); - await interaction.reply({ embeds: [embedReply] }); //logging From fb2b57638db8d28fb029c741a0a8be0b9ade3be1 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 16 Sep 2024 14:59:21 +0200 Subject: [PATCH 58/78] used the helper functions in the /pay command --- commands/economy/pay.js | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/commands/economy/pay.js b/commands/economy/pay.js index 0cfd3a9..849eb07 100644 --- a/commands/economy/pay.js +++ b/commands/economy/pay.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("discord.js"); +const { embedReplyPrimaryColor, embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -19,7 +20,11 @@ module.exports = { .setDMPermission(false), async execute(interaction) { if (!interaction.inGuild) { - var replyContent = "You can only pay out a member in a server."; + var embedReply = embedReplyFailureColor( + "Payment - Error", + "You can only pay out a member in a server.", + interaction + ); } else { const amount = interaction.options.getInteger("amount"); @@ -33,10 +38,18 @@ module.exports = { const targetUserBalance = targetUserBalanceQuery[0]?.balance || null; if (amount > userBalance) { - var replyContent = `:x: You can't pay that much money to <@${targetUserId}>!\nYour balance is only \`$${userBalance}\`.`; + var embedReply = embedReplyFailureColor( + "Payment - Error", + `:x: You can't pay that much money to <@${targetUserId}>!\nYour balance is only \`$${userBalance}\`.`, + interaction + ); } else if (amount <= 0) { - var replyContent = `:x: You can't pay a negative or zero amount of money to <@${targetUserId}>!\nTry again with a positive amount.`; + var embedReply = embedReplyFailureColor( + "Payment - Error", + `:x: You can't pay a negative or zero amount of money to <@${targetUserId}>!\nTry again with a positive amount.`, + interaction + ); } else { await db.query("UPDATE economy SET balance = balance - ? WHERE userId = ?", @@ -63,21 +76,14 @@ module.exports = { ); } - var replyContent = `:white_check_mark: <@${interactionUserId}> has successfully paid \`$${amount}\` to <@${targetUserId}>.`; + var embedReply = embedReplySuccessColor( + "Payment successful", + `:white_check_mark: <@${interactionUserId}> has successfully paid \`$${amount}\` to <@${targetUserId}>.`, + interaction + ); } } - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Paying to a member.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}`, - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); - await interaction.reply({ embeds: [embedReply] }); //logging From 75e6f882305647236a2d88258ecce9a5a951dc99 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 16 Sep 2024 15:10:32 +0200 Subject: [PATCH 59/78] used the helper functions in /rob and /roulette --- commands/economy/pay.js | 2 +- commands/economy/rob.js | 45 ++++++++++++++++---------- commands/economy/roulette.js | 62 ++++++++++++++++++++++++------------ 3 files changed, 71 insertions(+), 38 deletions(-) diff --git a/commands/economy/pay.js b/commands/economy/pay.js index 849eb07..c586fe0 100644 --- a/commands/economy/pay.js +++ b/commands/economy/pay.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplyPrimaryColor, embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embed-reply"); +const { embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/economy/rob.js b/commands/economy/rob.js index 1767fc9..207510a 100644 --- a/commands/economy/rob.js +++ b/commands/economy/rob.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("discord.js"); +const { embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -14,7 +15,11 @@ module.exports = { .setDMPermission(false), async execute(interaction) { if (!interaction.inGuild()) { - var replyContent = "You can only rob from a member in a server."; + var embedReply = embedReplyFailureColor( + "Robbing - Error", + "You can only rob from a member in a server.", + interaction + ); } else { const query = await db.query("SELECT userId, lastRobTime FROM economy WHERE userId = ?", [interaction.user.id]); @@ -25,7 +30,11 @@ module.exports = { const targetUserId = interaction.options.getUser("target").id; if (targetUserId == interaction.user.id) { - var replyContent = "Why are you trying to rob from yourself? :clown:\n**TIP:** If you're having trouble finding a target, try using the \`/leaderboard\` command." + var embedReply = embedReplyFailureColor( + "Robbing - Error", + "Why are you trying to rob from yourself? :clown:\n**TIP:** If you're having trouble finding a target, try using the \`/leaderboard\` command.", + interaction + ); } else { if (!lastRobTime || lastRobTime <= nextApprovedRobTimeUTC) { @@ -67,32 +76,34 @@ module.exports = { ); } - var replyContent = `<@${interaction.user.id}> has successfully robbed \`$${robAmount}\` from <@${targetUserId}>.`; + var embedReply = embedReplySuccessColor( + "Robbing successful", + `<@${interaction.user.id}> has successfully robbed \`$${robAmount}\` from <@${targetUserId}>.`, + interaction + ); } else { - var replyContent = `Your target (<@${targetUserId}>) must have a minimum of \`$50\`.\nPlease choose another target.\n**TIP:** You can check how much money the top memebers have with the \`/leaderboard\` command.`; + var embedReply = embedReplyFailureColor( + "Robbing - Error", + `Your target (<@${targetUserId}>) must have a minimum of \`$50\`.\nPlease choose another target.\n**TIP:** You can check how much money the top memebers have with the \`/leaderboard\` command.`, + interaction + ); } } else { const remainingTimeInSeconds = Math.ceil((lastRobTime.getTime() - nextApprovedRobTimeUTC.getTime()) / 1000); const remainingMinutes = Math.floor(remainingTimeInSeconds / 60); const remainingSeconds = remainingTimeInSeconds % 60; - var replyContent = `You've already robbed in the last 30 minutes.\nPlease wait **${remainingMinutes} minute(s)** and **${remainingSeconds} second(s)** before trying to **rob** again.`; + + var embedReply = embedReplyFailureColor( + "Robbing - Error", + `You've already robbed in the last 30 minutes.\nPlease wait **${remainingMinutes} minute(s)** and **${remainingSeconds} second(s)** before trying to **rob** again.`, + interaction + ); } } } - var embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Robbing a member.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}`, - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); - await interaction.reply({ embeds: [embedReply] }); //logging diff --git a/commands/economy/roulette.js b/commands/economy/roulette.js index 481b709..57b0615 100644 --- a/commands/economy/roulette.js +++ b/commands/economy/roulette.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("discord.js"); +const { embedReplySuccessColor, embedReplyFailureColor, embedReplyWarningColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const format = require("../../helpers/format"); const generate = require("../../helpers/generate"); @@ -26,7 +27,11 @@ module.exports = { .setDMPermission(false), async execute(interaction) { if (!interaction.inGuild()) { - var replyContent = "You can only play roulette in a server."; + var embedReply = embedReplyFailureColor( + "Roulette - Error", + "You can only play roulette in a server.", + interaction + ); } else { const interactionUserId = interaction.user.id; @@ -43,13 +48,25 @@ module.exports = { const remainingMinutes = Math.floor(remainingTimeInSeconds / 60); const remainingSeconds = remainingTimeInSeconds % 60; - var replyContent = `You've already played roulette in the last 15 minutes.\nPlease wait **${remainingMinutes} minute(s)** and **${remainingSeconds} second(s)** before trying to **play roulette** again.`; + var embedReply = embedReplyFailureColor( + "Roulette - Error", + `You've already played roulette in the last 15 minutes.\nPlease wait **${remainingMinutes} minute(s)** and **${remainingSeconds} second(s)** before trying to **play roulette** again.`, + interaction + ); } else if (userBalance < amount) { - var replyContent = `You can't play with that much money!\nYour current balance is only \`$${userBalance}\`.`; + var embedReply = embedReplyFailureColor( + "Roulette - Error", + `You can't play with that much money!\nYour current balance is only \`$${userBalance}\`.`, + interaction + ); } else if (amount <= 0) { - var replyContent = `You can't play without money.\nPlease enter a positive amount that's in you balance range.\nYour current balance is \`$${userBalance}\`.`; + var embedReply = embedReplyFailureColor( + "Roulette - Error", + `You can't play without money.\nPlease enter a positive amount that's in you balance range.\nYour current balance is \`$${userBalance}\`.`, + interaction + ); } else { const validColors = ["red", "black", "green"]; @@ -60,7 +77,11 @@ module.exports = { const randomNumber = randomOutcome.number; if(!validColors.includes(guessedColor)) { - var replyContent = "The color you've chosen is invalid.\nPlease choose from `red`, `black` or `green`."; + var embedReply = embedReplyFailureColor( + "Roulette - Error", + "The color you've chosen is invalid.\nPlease choose from `red`, `black` or `green`.", + interaction + ); } else if (guessedColor === randomColor) { if (guessedColor === "green") { @@ -72,7 +93,11 @@ module.exports = { ] ); - var replyContent = `The ball landed on **${format.formatRouletteColor(randomColor)} ${randomNumber}**.\nYour guess was **${format.formatRouletteColor(guessedColor)}**.\nYou hit the jackpot, and won \`$${amount * 35}\`! :money_mouth:`; + var embedReply = embedReplySuccessColor( + "Roulette - Jackpot", + `The ball landed on **${format.formatRouletteColor(randomColor)} ${randomNumber}**.\nYour guess was **${format.formatRouletteColor(guessedColor)}**.\nYou hit the jackpot, and won \`$${amount * 35}\`! :money_mouth:`, + interaction + ); } else { await db.query("UPDATE economy SET balance = balance + ?, lastRouletteTime = ? WHERE userId = ?", @@ -83,7 +108,11 @@ module.exports = { ] ); - var replyContent = `The ball landed on **${format.formatRouletteColor(randomColor)} ${randomNumber}**.\nYour guess was **${format.formatRouletteColor(guessedColor)}** as well!\nYou won \`$${amount * 2}\`. :money_mouth:`; + var embedReply = embedReplySuccessColor( + "Roulette - Won", + `The ball landed on **${format.formatRouletteColor(randomColor)} ${randomNumber}**.\nYour guess was **${format.formatRouletteColor(guessedColor)}** as well!\nYou won \`$${amount * 2}\`. :money_mouth:`, + interaction + ); } } else { @@ -95,22 +124,15 @@ module.exports = { ] ); - var replyContent = `The ball landed on **${format.formatRouletteColor(randomColor)} ${randomNumber}**.\nYour guess was **${format.formatRouletteColor(guessedColor)}**.\nMaybe try your luck again. :upside_down:`; + var embedReply = embedReplyWarningColor( + "Roulette - Lost", + `The ball landed on **${format.formatRouletteColor(randomColor)} ${randomNumber}**.\nYour guess was **${format.formatRouletteColor(guessedColor)}**.\nMaybe try your luck again. :upside_down:`, + interaction + ); } } } - var embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Playing roulette.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}`, - icon_url: interaction.user.displayAvatarURL({ dynamic: true }) - } - }); - await interaction.reply({ embeds: [embedReply] }) //logging From 14315a0136fdebe74ab66ea2beacd33f6d81c3f5 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 16 Sep 2024 19:14:54 +0200 Subject: [PATCH 60/78] used the helpers in other economy and fun commands --- commands/economy/withdraw.js | 26 ++++++++++++-------------- commands/economy/work.js | 34 +++++++++++++++++++--------------- commands/fun/coinflip.js | 18 +++++++----------- 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/commands/economy/withdraw.js b/commands/economy/withdraw.js index 8a132fe..f64ee05 100644 --- a/commands/economy/withdraw.js +++ b/commands/economy/withdraw.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("discord.js"); +const { embedSuccessColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -20,7 +21,11 @@ module.exports = { const balanceInBank = Number(query[0]?.balanceInBank) || 0; if (balanceInBank < amount) { - var replyContent = `You can't withdraw that much money from your bank account.\nYour current bank balance is only \`$${balanceInBank}\`. :bank:`; + var embedReply = embedReplyFailureColor( + "Withdraw - Error", + `You can't withdraw that much money from your bank account.\nYour current bank balance is only \`$${balanceInBank}\`. :bank:`, + interaction + ); } else { await db.query("UPDATE economy SET balance = balance + ?, balanceInBank = balanceInBank - ? WHERE userId = ?", @@ -31,20 +36,13 @@ module.exports = { ] ); - var replyContent = `You've successfully withdrawn \`$${amount}\` from your bank account.\nYour current balance in the bank is \`$${balanceInBank - amount}\`. :bank:\nYour current balance is \`$${balance + amount}\`. :moneybag:`; + var embedReply = embedSuccessColor( + "Withdraw successful.", + `You've successfully withdrawn \`$${amount}\` from your bank account.\nYour current balance in the bank is \`$${balanceInBank - amount}\`. :bank:\nYour current balance is \`$${balance + amount}\`. :moneybag:`, + interaction + ); } - var embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Withdrawing.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}`, - icon_url: interaction.user.displayAvatarURL({ dynamic: true }) - } - }); - await interaction.reply({ embeds: [embedReply] }); //logging diff --git a/commands/economy/work.js b/commands/economy/work.js index aaf7e48..eae0321 100644 --- a/commands/economy/work.js +++ b/commands/economy/work.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("discord.js"); +const { embedSuccessColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -24,13 +25,22 @@ module.exports = { ] ); - var replyContent = `You've worked and succesfully earned \`$${amount}\` dollars.`; + var embedReply = embedSuccessColor( + "Working.", + `You've worked and succesfully earned \`$${amount}\` dollars.`, + interaction + ); } else { const remainingTimeInSeconds = Math.ceil((lastWorkTime.getTime() - nextApprovedWorkTimeUTC.getTime()) / 1000); const remainingMinutes = Math.floor(remainingTimeInSeconds / 60); const remainingSeconds = remainingTimeInSeconds % 60; - var replyContent = `You've already worked in the last 5 minutes.\nPlease wait **${remainingMinutes} minute(s)** and **${remainingSeconds} second(s)** before trying to **work** again.`; + + var embedReply = embedReplyFailureColor( + "Work - Error", + `You've already worked in the last 5 minutes.\nPlease wait **${remainingMinutes} minute(s)** and **${remainingSeconds} second(s)** before trying to **work** again.`, + interaction + ); } } else { @@ -44,19 +54,13 @@ module.exports = { new Date().toISOString().slice(0, 19).replace('T', ' ') ] ); - var replyContent = `You've worked and succesfully earned \`$${amount}\` dollars.`; + + var embedReply = embedSuccessColor( + "Working.", + `You've worked and succesfully earned \`$${amount}\` dollars.`, + interaction + ); } - - var embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Working.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - } - }); await interaction.reply({ embeds: [embedReply] }); diff --git a/commands/fun/coinflip.js b/commands/fun/coinflip.js index c4d4cf4..6b7e060 100755 --- a/commands/fun/coinflip.js +++ b/commands/fun/coinflip.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require('discord.js'); +const { SlashCommandBuilder } = require('discord.js'); +const { embedReplyPrimaryColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -15,16 +16,11 @@ module.exports = { var result = "tails"; } - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Coinflip.", - description: `You've flipped **${result}**.`, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); + var embedReply = embedReplyPrimaryColor( + "Coinflip.", + `You've flipped **${result}**.`, + interaction + ); await interaction.reply({ embeds: [embedReply]}); From 8b15d1ff2b5c19accd1e3d37305c35c15c88346d Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 16 Sep 2024 19:15:16 +0200 Subject: [PATCH 61/78] added helper with img in the embed body --- helpers/embed-reply.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index ae72257..2f5c63c 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -143,6 +143,31 @@ function moderationDmEmbedReply(color, title, description, interaction) { return embedDmReply; } +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {image} image - An image (url) that will show up in the embed + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ +function embedReplyPrimaryColorImg(title, description, image, interaction) { + const embedReply = new EmbedBuilder({ + color: parseInt(color), + title: title, + description: description, + image: { + url: `${image}` + }, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + return embedReply; +} + module.exports = { embedReply, embedReplyPrimaryColor, @@ -151,4 +176,5 @@ module.exports = { embedReplyFailureColor, embedReplyWarningColor, moderationDmEmbedReply, + embedReplyPrimaryColorImg } \ No newline at end of file From 2d12de95143756a826da0fc0d5237d9e9cda8ffb Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 16 Sep 2024 19:15:45 +0200 Subject: [PATCH 62/78] fixed color in helper --- helpers/embed-reply.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index 2f5c63c..fc5bfb9 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -152,7 +152,7 @@ function moderationDmEmbedReply(color, title, description, interaction) { */ function embedReplyPrimaryColorImg(title, description, image, interaction) { const embedReply = new EmbedBuilder({ - color: parseInt(color), + color: embedColors.primary, title: title, description: description, image: { From d59604c3c9713871ba031c024a237f0b2f1854a6 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 16 Sep 2024 20:48:46 +0200 Subject: [PATCH 63/78] used helpers in the remaining fun commands --- commands/fun/randomfeet.js | 42 +++++++++++++++----------------------- helpers/embed-reply.js | 29 +++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/commands/fun/randomfeet.js b/commands/fun/randomfeet.js index 74456e5..141f286 100755 --- a/commands/fun/randomfeet.js +++ b/commands/fun/randomfeet.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("discord.js"); +const { embedReplyPrimaryColorImg, embedReplyImg } = require("../../helpers/embed-reply"); const fs = require("fs"); const path = require("path"); const linksFile = "./data/links.json"; @@ -38,7 +39,7 @@ async function loadLinks() { links = JSON.parse(fs.readFileSync(linksFile)); } catch { - links = await scrapeLinks("https://vb2007.hu/cdn/feetpics/"); + links = await scrapeLinks("https://cdn.vb2007.hu/autoindex/feetpics/"); await fs.writeFileSync(linksFile, JSON.stringify(links)); } @@ -58,36 +59,25 @@ module.exports = { //random képet választ a listából const randomFeet = links[Math.floor(Math.random() * links.length)]; - - var embedReplyColor; - var embedReplyTitle; - var embedReplyDescription; if (randomFeet == "https://vb2007.hu/cdn/feetpics/145.jpg") { - embedReplyColor = 0xEBB22F; - embedReplyTitle = "CONGRATULATIONS!"; - embedReplyDescription = "You found the hidden feetpic! :tada:"; + var embedReply = embedReplyImg( + 0xEBB22F, + "CONGRATULATIONS!", + "You found the hidden feetpic! :tada:", + randomFeet, + interaction + ); } else{ - embedReplyColor = 0x5F0FD6; - embedReplyTitle = "Randomfeet."; - embedReplyDescription = "Here is a random feetpic:"; + var embedReply = embedReplyPrimaryColorImg( + "Randomfeet.", + "Here is a random feetpic:", + randomFeet, + interaction + ); } - const embedReply = new EmbedBuilder({ - color: embedReplyColor, - title: embedReplyTitle, - description: embedReplyDescription, - image: { - url: `${randomFeet}` - }, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); - await interaction.editReply({ embeds: [embedReply] }); //logging diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index fc5bfb9..9e52e5f 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -143,6 +143,32 @@ function moderationDmEmbedReply(color, title, description, interaction) { return embedDmReply; } +/** + * @param {color} color - Embed's sidebar HEX Color + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {image} image - An image (url) that will show up in the embed + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ +function embedReplyImg(color, title, description, image, interaction) { + const embedReply = new EmbedBuilder({ + color: color, + title: title, + description: description, + image: { + url: `${image}` + }, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + return embedReply; +} + /** * @param {title} title - Embed's title * @param {description} description - Embed's description @@ -176,5 +202,6 @@ module.exports = { embedReplyFailureColor, embedReplyWarningColor, moderationDmEmbedReply, - embedReplyPrimaryColorImg + embedReplyImg, + embedReplyPrimaryColorImg, } \ No newline at end of file From e23465bdf62b5c16eaefd42e605999fffdaf5b2c Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 16 Sep 2024 21:43:48 +0200 Subject: [PATCH 64/78] used helpers in some fun and almost all moderation commands --- commands/administration/autorole-disable.js | 2 +- commands/fun/randomfeet.js | 2 +- commands/fun/randompic.js | 24 +++----- commands/moderation/ban.js | 59 +++++++++++--------- commands/moderation/kick.js | 62 ++++++++++++--------- commands/moderation/purge.js | 38 +++++++------ commands/moderation/timeout.js | 62 ++++++++++++--------- helpers/embed-reply.js | 6 +- 8 files changed, 141 insertions(+), 114 deletions(-) diff --git a/commands/administration/autorole-disable.js b/commands/administration/autorole-disable.js index e40bfbb..d575bf9 100755 --- a/commands/administration/autorole-disable.js +++ b/commands/administration/autorole-disable.js @@ -48,7 +48,7 @@ module.exports = { var localEmbedResponse = embedReply( embedColors.warning, "AutoRole Disable: Warning", - "Autorole has not been configured for this server.\nTherefore, you can't disable it.\nYou can enable this feature with `/autorole-configure`", + "Autorole has not been configured for this server.\nTherefore, you can't disable it.\nYou can enable this feature with `/autorole-configure`.", interaction ); } diff --git a/commands/fun/randomfeet.js b/commands/fun/randomfeet.js index 141f286..b33e60e 100755 --- a/commands/fun/randomfeet.js +++ b/commands/fun/randomfeet.js @@ -57,7 +57,7 @@ module.exports = { const links = await loadLinks(); - //random képet választ a listából + //picks a random image from the array const randomFeet = links[Math.floor(Math.random() * links.length)]; if (randomFeet == "https://vb2007.hu/cdn/feetpics/145.jpg") { diff --git a/commands/fun/randompic.js b/commands/fun/randompic.js index 0dc9e8b..d17d7d1 100755 --- a/commands/fun/randompic.js +++ b/commands/fun/randompic.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require('discord.js'); +const { SlashCommandBuilder } = require('discord.js'); +const { embedReplyPrimaryColorImg } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -7,22 +8,15 @@ module.exports = { .setDescription("Send a random picture using the picsum.photos API."), async execute(interaction) { // There are currently 1084 photos on picsum.images - // And we need an ID to keep a requested image + // And we need an ID to remember the specific image const randomImageId = (Math.floor(Math.random() * 1085)); - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Random pic.", - description: "Here is a random 512x512 image from picsum.photos (might take some time to load):", - image: { - url: `https://picsum.photos/id/${randomImageId}/512/512` - }, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); + const embedReply = embedReplyPrimaryColorImg( + "Random pic.", + "Here is a random 512x512 image from picsum.photos (might take some time to load):", + `https://picsum.photos/id/${randomImageId}/512/512`, + interaction + ); await interaction.reply({ embeds: [embedReply] }); diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index 325c047..f3cf7ad 100755 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { embedReplyFailureColor, moderationDmEmbedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -22,26 +23,32 @@ module.exports = { const reason = interaction.options.getString("reason") || "No reason provided"; if (!interaction.inGuild()) { - var replyContent = "You can only ban members in a server."; + var embedReply = embedReplyFailureColor( + "Ban - Error", + "You can only ban members in a server.", + interaction + ); } else if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.BanMembers)) { - var replyContent = "Bot lacks the ban permission, cannot ban the member."; + var embedReply = embedReplyFailureColor( + "Ban - Error", + "Bot lacks the ban permission, cannot ban the member.", + interaction + ); } else{ try{ await interaction.guild.members.ban(targetUser, { reason: reason }); + var replyContent = `Successfully banned user ${targetUser.tag} for: ${reason}`; + try{ - const embedDmReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "You have been banned.", - description: `You have banned from **${interaction.guild.name}** for: **${reason}** \nIf you believe this was a mistake, please contact a moderator.`, - timestamp: new Date().toISOString(), - footer: { - text: `Moderator: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); + const embedDmReply = moderationDmEmbedReplyFailureColor( + "You have been banned.", + `You have banned from **${interaction.guild.name}** for: **${reason}** \nIf you believe this was a mistake, please contact a moderator.`, + interaction + ); + await targetUser.send({ embeds: [embedDmReply] }); replyContent += "\nThe user was notified about the action & reason in their DMs."; } @@ -49,23 +56,23 @@ module.exports = { console.error(error); replyContent += "\nThere was an error while trying to DM the user."; } + + var embedReply = embedReplySuccessColor( + "Ban - Success", + replyContent, + interaction + ); } catch (error){ console.error(error); - var replyContent = "There was an error while trying to ban the user."; - } - } - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Smashing with the banhammer.", - description: `${replyContent}`, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); + var embedReply = embedReplyFailureColor( + "Ban - Error", + "There was an error while trying to ban the user.", + interaction + ); + } + } await interaction.reply({ embeds: [embedReply] }); diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 548d406..47d73b8 100755 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { embedReplySuccessColor, embedReplyFailureColor, moderationDmEmbedReplyFailureColor } = require('../../helpers/embed-reply'); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -22,29 +23,39 @@ module.exports = { const reason = interaction.options.getString("reason") || "No reason provided"; if (!interaction.inGuild()) { - var replyContent = "You can only kick members in a server."; + var embedReply = embedReplyFailureColor( + "Kick - Error", + "You can only kick members in a server.", + interaction + ); } else if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.KickMembers)) { - var replyContent = "Bot lacks the kick permission, cannot kick member."; + var embedReply = embedReplyFailureColor( + "Kick - Error", + "Bot lacks the kick permission, cannot kick target member.", + interaction + ); } else if (!targetUser.kickable) { - var replyContent = `The bot cannot kick user **${targetUser.tag}**.\nMaybe your, or the bot's rank is lower than theirs?`; + var embedReply = embedReplyFailureColor( + "Kick - Error", + `The bot cannot kick user **${targetUser.tag}**.\nMaybe your, or the bot's rank is lower than theirs?`, + interaction + ); } else{ try { await interaction.guild.members.kick(targetUser, { reason: reason }); + var replyContent = `Successfully kicked user **${targetUser.tag}** for: **${reason}**`; + try { - const embedDmReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "You have been kicked.", - description: `You have kicked out from **${interaction.guild.name}** for: **${reason}** \nIf you believe this was a mistake, please contact a moderator.`, - timestamp: new Date().toISOString(), - footer: { - text: `Moderator: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); + var embedDmReply = moderationDmEmbedReplyFailureColor( + "You have been kicked.", + `You have kicked out from **${interaction.guild.name}** for: **${reason}** \nIf you believe this was a mistake, please contact a moderator.`, + interaction + ); + await targetUser.send({ embeds: [embedDmReply] }); replyContent += "\nThe user was notified about the action & reason in their DMs."; } @@ -52,24 +63,23 @@ module.exports = { console.error(error); replyContent += "\nThere was an error while trying to DM the user."; } + + var embedReply = embedReplySuccessColor( + "Kick - Success", + replyContent, + interaction + ); } catch(error) { console.error(error); - var replyContent = "There was an error while trying to kick the user."; + var embedReply = embedReplyFailureColor( + "Kick - Error", + "There was an error while trying to kick the user.", + interaction + ); } } - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Kicking a user out.", - description: replyContent, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); - await interaction.reply({ embeds: [embedReply] }); //logging diff --git a/commands/moderation/purge.js b/commands/moderation/purge.js index 7b22de6..d1068a1 100755 --- a/commands/moderation/purge.js +++ b/commands/moderation/purge.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js'); +const { SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js'); +const { embedReplySuccessColor, embedReplyFailureColor } = require('../../helpers/embed-reply'); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -16,19 +17,35 @@ module.exports = { const messageAmount = interaction.options.get("amount").value; if (!interaction.inGuild()) { - var replyContent = "You can only purge messages in a server."; + var embedReply = embedReplyFailureColor( + "Purge - Error", + "You can only purge messages in a server.", + interaction + ); } else if (messageAmount > 100){ - var replyContent = "Cannot delete more than 100 messages at once due to Discord's limitations."; + var embedReply = embedReplyFailureColor( + "Purge - Error", + "Cannot delete more than 100 messages at once due to Discord's limitations.\nPlease try again with a lower amount.\nRun the command multiple times if needed.", + interaction + ); } else{ try{ await interaction.channel.bulkDelete(messageAmount); - var replyContent = `Deleted ${messageAmount} messages successfully.`; + var embedReply = embedReplySuccessColor( + "Purge - Success", + `Deleted ${messageAmount} messages successfully.`, + interaction + ); } catch (error){ console.error(error); - var replyContent = "There was an error trying to purge the messages."; + var embedReply = embedReplyFailureColor( + "Purge - Error", + "There was an error trying to purge the messages.", + interaction + ); } } @@ -40,17 +57,6 @@ module.exports = { const row = new ActionRowBuilder() .addComponents(deleteButton); - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Purging messages.", - description: `${replyContent}`, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); - await interaction.reply({ embeds: [embedReply], components: [row] diff --git a/commands/moderation/timeout.js b/commands/moderation/timeout.js index b918d21..0a56696 100755 --- a/commands/moderation/timeout.js +++ b/commands/moderation/timeout.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder, PermissionFlagsBits, time } = require('discord.js'); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { embedReplySuccessColor, embedReplyFailureColor, moderationDmEmbedReplyFailureColor } = require('../../helpers/embed-reply'); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -57,29 +58,39 @@ module.exports = { const [ time, timeString ] = timeInMs(timeInput); if (!interaction.inGuild()) { - var replyContent = "You can only timeout members in a server."; + var embedReply = embedReplyFailureColor( + "Timeout - Error", + "You can only timeout members in a server.", + interaction + ); } if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.MuteMembers)) { - var replyContent = "Bot **lacks the timeout(aka. mute) permission**, cannot time out the member."; + var embedReply = embedReplyFailureColor( + "Timeout - Error", + "Bot **lacks the timeout(aka. mute) permission**, cannot time out the member.", + interaction + ); } else if(isNaN(time)) { - var replyContent = time; + var embedReply = embedReplyFailureColor( + "Timeout - Error", + time, + interaction + ); } else{ try{ await targetUser.timeout(time, reason); + var replyContent = `Successfully timed out user ${targetUser} for **${timeString}**, with reason: **${reason}**`; + try{ - const embedDmReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "You have been timed out.", - description: `You have been timed out in **${interaction.guild.name}** for **${timeString}**, because of: **${reason}** \nIf you believe this was a mistake, please contact a moderator.`, - timestamp: new Date().toISOString(), - footer: { - text: `Moderator: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); + var embedDmReply = moderationDmEmbedReplyFailureColor( + "You have been timed out.", + `You have been timed out in **${interaction.guild.name}** for **${timeString}**, because of: **${reason}** \nIf you believe this was a mistake, please contact a moderator.`, + interaction + ); + await targetUser.send({ embeds: [embedDmReply] }); replyContent += "\nThe user was notified about the action & reason in their DMs."; } @@ -87,24 +98,23 @@ module.exports = { console.error(error); replyContent += "\nThere was an error while trying to DM the user."; } + + var embedReply = embedReplySuccessColor( + "Timeout - Success", + replyContent, + interaction + ); } catch (error){ console.error(error); - var replyContent = "There was an error while trying to time out the user."; + var embedReply = embedReplyFailureColor( + "Timeout - Error", + "There was an error while trying to time out the user.", + interaction + ); } } - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Timeout.", - description: `${replyContent}`, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); - await interaction.reply({ embeds: [embedReply] }); //logging diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index 9e52e5f..956b570 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -128,9 +128,9 @@ function embedReplyWarningColor(title, description, interaction) { return embedReply; } -function moderationDmEmbedReply(color, title, description, interaction) { +function moderationDmEmbedReplyFailureColor(title, description, interaction) { const embedDmReply = new EmbedBuilder({ - color: parseInt(color), + color: embedColors.failure, title: title, description: description, timestamp: new Date().toISOString(), @@ -201,7 +201,7 @@ module.exports = { embedReplySuccessSecondaryColor, embedReplyFailureColor, embedReplyWarningColor, - moderationDmEmbedReply, + moderationDmEmbedReplyFailureColor, embedReplyImg, embedReplyPrimaryColorImg, } \ No newline at end of file From 9788c398eef3deefa09f3f030bcf42d9c9e8aa95 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 16 Sep 2024 21:49:10 +0200 Subject: [PATCH 65/78] parsed integers in helper function sidebar colors --- helpers/embed-reply.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index 956b570..ecba2b9 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -31,7 +31,7 @@ function embedReply(color, title, description, interaction) { */ function embedReplyPrimaryColor(title, description, interaction) { const embedReply = new EmbedBuilder({ - color: embedColors.primary, + color: parseInt(embedColors.primary), title: title, description: description, timestamp: new Date().toISOString(), @@ -52,7 +52,7 @@ function embedReplyPrimaryColor(title, description, interaction) { */ function embedReplySuccessColor(title, description, interaction) { const embedReply = new EmbedBuilder({ - color: embedColors.success, + color: parseInt(embedColors.success), title: title, description: description, timestamp: new Date().toISOString(), @@ -73,7 +73,7 @@ function embedReplySuccessColor(title, description, interaction) { */ function embedReplySuccessSecondaryColor(title, description, interaction) { const embedReply = new EmbedBuilder({ - color: embedColors.successSecondary, + color: parseInt(embedColors.successSecondary), title: title, description: description, timestamp: new Date().toISOString(), @@ -94,7 +94,7 @@ function embedReplySuccessSecondaryColor(title, description, interaction) { */ function embedReplyFailureColor(title, description, interaction) { const embedReply = new EmbedBuilder({ - color: embedColors.failure, + color: parseInt(embedColors.failure), title: title, description: description, timestamp: new Date().toISOString(), @@ -115,7 +115,7 @@ function embedReplyFailureColor(title, description, interaction) { */ function embedReplyWarningColor(title, description, interaction) { const embedReply = new EmbedBuilder({ - color: embedColors.warning, + color: parseInt(embedColors.warning), title: title, description: description, timestamp: new Date().toISOString(), @@ -130,7 +130,7 @@ function embedReplyWarningColor(title, description, interaction) { function moderationDmEmbedReplyFailureColor(title, description, interaction) { const embedDmReply = new EmbedBuilder({ - color: embedColors.failure, + color: parseInt(embedColors.failure), title: title, description: description, timestamp: new Date().toISOString(), @@ -153,7 +153,7 @@ function moderationDmEmbedReplyFailureColor(title, description, interaction) { */ function embedReplyImg(color, title, description, image, interaction) { const embedReply = new EmbedBuilder({ - color: color, + color: parseInt(color), title: title, description: description, image: { @@ -178,7 +178,7 @@ function embedReplyImg(color, title, description, image, interaction) { */ function embedReplyPrimaryColorImg(title, description, image, interaction) { const embedReply = new EmbedBuilder({ - color: embedColors.primary, + color: parseInt(embedColors.primary), title: title, description: description, image: { From 1730c6c52fb5b5116ad6feea687d8ff04be44bc9 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 16 Sep 2024 22:02:53 +0200 Subject: [PATCH 66/78] used helper functions in /warn --- commands/moderation/warn.js | 54 +++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index 2c89abb..4267b32 100755 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); +const { embedReplySuccessColor, embedReplyFailureColor, moderationDmEmbedReplyFailureColor } = require('../../helpers/embed-reply'); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -22,43 +23,44 @@ module.exports = { const reason = interaction.options.getString("reason") || "No reason provided"; if (!interaction.inGuild()) { - var replyContent = "You can only warn members in a server."; + var embedReply = embedReplyFailureColor( + "Warn - Error", + "You can only warn members in a server.", + interaction + ); } else if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.ModerateMembers)) { - var replyContent = "Bot lacks the timeout (moderation) permission, cannot warn member."; + var embedReply = embedReplyFailureColor( + "Warn - Error", + "Bot **lacks the timeout (moderation) permission**, cannot warn member.", + interaction + ); } else{ try{ - const embedDmReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "You have been warned.", - description: `You have been warned in **${interaction.guild.name}** for: **${reason}** \nIf you believe this was a mistake, please contact a moderator.`, - timestamp: new Date().toISOString(), - footer: { - text: `Moderator: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); + const embedDmReply = moderationDmEmbedReplyFailureColor( + "You have been warned.", + `You have been warned in **${interaction.guild.name}** for: **${reason}** \nIf you believe this was a mistake, please contact a moderator.`, + interaction + ); + await targetUser.send({ embeds: [embedDmReply] }); - var replyContent = `Successfully warned user **${targetUser.tag}** for: **${reason}**.\nThey've been notified about the warn in their DMs.`; + var embedReply = embedReplySuccessColor( + "Warn - Success", + `Successfully warned user **${targetUser.tag}** for: **${reason}**.\nThey've been notified about the warn in their DMs.`, + interaction + ); } catch (error){ console.error(error); - var replyContent = "There was an error while trying to DM the user."; + var embedReply = embedReplyFailureColor( + "Warn - Error", + "There was an error while trying to warn the user.", + interaction + ); } } - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Warning a user.", - description: `${replyContent}`, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); - await interaction.reply({ embeds: [embedReply] }); //logging From f55916f83ab4c9fdd967f263fb5a8aaddd4085c1 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 18 Sep 2024 22:56:43 +0200 Subject: [PATCH 67/78] updated packages --- package-lock.json | 201 +++++++++++++++++++++------------------------- 1 file changed, 91 insertions(+), 110 deletions(-) diff --git a/package-lock.json b/package-lock.json index e7f60d3..9890780 100755 --- a/package-lock.json +++ b/package-lock.json @@ -589,20 +589,20 @@ "dev": true }, "node_modules/@discordjs/builders": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.8.2.tgz", - "integrity": "sha512-6wvG3QaCjtMu0xnle4SoOIeFB4y6fKMN6WZfy3BMKJdQQtPLik8KGzDwBVL/+wTtcE/ZlFjgEk74GublyEVZ7g==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.9.0.tgz", + "integrity": "sha512-0zx8DePNVvQibh5ly5kCEei5wtPBIUbSoE9n+91Rlladz4tgtFbJ36PZMxxZrTEOQ7AHMZ/b0crT/0fCy6FTKg==", "dependencies": { - "@discordjs/formatters": "^0.4.0", - "@discordjs/util": "^1.1.0", - "@sapphire/shapeshift": "^3.9.7", - "discord-api-types": "0.37.83", + "@discordjs/formatters": "^0.5.0", + "@discordjs/util": "^1.1.1", + "@sapphire/shapeshift": "^4.0.0", + "discord-api-types": "0.37.97", "fast-deep-equal": "^3.1.3", "ts-mixer": "^6.0.4", - "tslib": "^2.6.2" + "tslib": "^2.6.3" }, "engines": { - "node": ">=16.11.0" + "node": ">=18" }, "funding": { "url": "https://github.com/discordjs/discord.js?sponsor" @@ -617,45 +617,45 @@ } }, "node_modules/@discordjs/formatters": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.4.0.tgz", - "integrity": "sha512-fJ06TLC1NiruF35470q3Nr1bi95BdvKFAF+T5bNfZJ4bNdqZ3VZ+Ttg6SThqTxm6qumSG3choxLBHMC69WXNXQ==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.5.0.tgz", + "integrity": "sha512-98b3i+Y19RFq1Xke4NkVY46x8KjJQjldHUuEbCqMvp1F5Iq9HgnGpu91jOi/Ufazhty32eRsKnnzS8n4c+L93g==", "dependencies": { - "discord-api-types": "0.37.83" + "discord-api-types": "0.37.97" }, "engines": { - "node": ">=16.11.0" + "node": ">=18" }, "funding": { "url": "https://github.com/discordjs/discord.js?sponsor" } }, "node_modules/@discordjs/rest": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.3.0.tgz", - "integrity": "sha512-C1kAJK8aSYRv3ZwMG8cvrrW4GN0g5eMdP8AuN8ODH5DyOCbHgJspze1my3xHOAgwLJdKUbWNVyAeJ9cEdduqIg==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.4.0.tgz", + "integrity": "sha512-Xb2irDqNcq+O8F0/k/NaDp7+t091p+acb51iA4bCKfIn+WFWd6HrNvcsSbMMxIR9NjcMZS6NReTKygqiQN+ntw==", "dependencies": { - "@discordjs/collection": "^2.1.0", - "@discordjs/util": "^1.1.0", - "@sapphire/async-queue": "^1.5.2", + "@discordjs/collection": "^2.1.1", + "@discordjs/util": "^1.1.1", + "@sapphire/async-queue": "^1.5.3", "@sapphire/snowflake": "^3.5.3", - "@vladfrangu/async_event_emitter": "^2.2.4", - "discord-api-types": "0.37.83", + "@vladfrangu/async_event_emitter": "^2.4.6", + "discord-api-types": "0.37.97", "magic-bytes.js": "^1.10.0", - "tslib": "^2.6.2", - "undici": "6.13.0" + "tslib": "^2.6.3", + "undici": "6.19.8" }, "engines": { - "node": ">=16.11.0" + "node": ">=18" }, "funding": { "url": "https://github.com/discordjs/discord.js?sponsor" } }, "node_modules/@discordjs/rest/node_modules/@discordjs/collection": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.0.tgz", - "integrity": "sha512-mLcTACtXUuVgutoznkh6hS3UFqYirDYAg5Dc1m8xn6OvPjetnUlf/xjtqnnc47OwWdaoCQnHmHh9KofhD6uRqw==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz", + "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==", "engines": { "node": ">=18" }, @@ -663,20 +663,12 @@ "url": "https://github.com/discordjs/discord.js?sponsor" } }, - "node_modules/@discordjs/rest/node_modules/undici": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.13.0.tgz", - "integrity": "sha512-Q2rtqmZWrbP8nePMq7mOJIN98M0fYvSgV89vwl/BQRT4mDOeY2GXZngfGpcBBhtky3woM7G24wZV3Q304Bv6cw==", - "engines": { - "node": ">=18.0" - } - }, "node_modules/@discordjs/util": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.0.tgz", - "integrity": "sha512-IndcI5hzlNZ7GS96RV3Xw1R2kaDuXEp7tRIy/KlhidpN/BQ1qh1NZt3377dMLTa44xDUNKT7hnXkA/oUAzD/lg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.1.tgz", + "integrity": "sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g==", "engines": { - "node": ">=16.11.0" + "node": ">=18" }, "funding": { "url": "https://github.com/discordjs/discord.js?sponsor" @@ -705,9 +697,9 @@ } }, "node_modules/@discordjs/ws/node_modules/@discordjs/collection": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.0.tgz", - "integrity": "sha512-mLcTACtXUuVgutoznkh6hS3UFqYirDYAg5Dc1m8xn6OvPjetnUlf/xjtqnnc47OwWdaoCQnHmHh9KofhD6uRqw==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz", + "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==", "engines": { "node": ">=18" }, @@ -715,6 +707,11 @@ "url": "https://github.com/discordjs/discord.js?sponsor" } }, + "node_modules/@discordjs/ws/node_modules/discord-api-types": { + "version": "0.37.83", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.83.tgz", + "integrity": "sha512-urGGYeWtWNYMKnYlZnOnDHm8fVRffQs3U0SpE8RHeiuLKb/u92APS8HoQnPTFbnXmY1vVnXjXO4dOxcAn3J+DA==" + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -1076,9 +1073,9 @@ } }, "node_modules/@sapphire/shapeshift": { - "version": "3.9.7", - "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.9.7.tgz", - "integrity": "sha512-4It2mxPSr4OGn4HSQWGmhFMsNFGfFVhWeRPCRwbH972Ek2pzfGRZtb0pJ4Ze6oIzcyh2jw7nUDa6qGlWofgd9g==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-4.0.0.tgz", + "integrity": "sha512-d9dUmWVA7MMiKobL3VpLF8P2aeanRTu6ypG2OIaEv/ZHH/SUQ2iHOVyi5wAPjQ+HmnMuL0whK9ez8I/raWbtIg==", "dependencies": { "fast-deep-equal": "^3.1.3", "lodash": "^4.17.21" @@ -1200,9 +1197,9 @@ } }, "node_modules/@types/node": { - "version": "22.5.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.2.tgz", - "integrity": "sha512-acJsPTEqYqulZS/Yp/S3GgeE6GZ0qYODUR8aVr/DkhHQ8l9nd4j5x1/ZJy9/gHrRlFMqkO6i0I3E27Alu4jjPg==", + "version": "22.5.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz", + "integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==", "dependencies": { "undici-types": "~6.19.2" } @@ -1606,9 +1603,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001655", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001655.tgz", - "integrity": "sha512-jRGVy3iSGO5Uutn2owlb5gR6qsGngTw9ZTb4ali9f3glshcNmJ2noam4Mo9zia5P9Dk3jNNydy7vQjuE5dQmfg==", + "version": "1.0.30001660", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001660.tgz", + "integrity": "sha512-GacvNTTuATm26qC74pt+ad1fW15mlQ/zuTzzY1ZoIzECTP8HURDfF43kNxPgf7H1jmelCBQTTbBNxdSXOA7Bqg==", "dev": true, "funding": [ { @@ -1736,9 +1733,9 @@ } }, "node_modules/cjs-module-lexer": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.0.tgz", - "integrity": "sha512-N1NGmowPlGBLsOZLPvm48StN04V4YvQRL0i6b7ctrVY3epjP/ct7hFLOItz6pDIvRjwpfPxi52a2UWV2ziir8g==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.1.tgz", + "integrity": "sha512-cuSVIHi9/9E/+821Qjdvngor+xpnlwnuwIyZOaLmHBVdXL+gP+I6QQB9VkO7RI77YIcTV+S1W9AreJ5eN63JBA==", "dev": true }, "node_modules/cliui": { @@ -1901,12 +1898,12 @@ } }, "node_modules/debug": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", - "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", "dev": true, "dependencies": { - "ms": "2.1.2" + "ms": "^2.1.3" }, "engines": { "node": ">=6.0" @@ -1976,43 +1973,35 @@ } }, "node_modules/discord-api-types": { - "version": "0.37.83", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.83.tgz", - "integrity": "sha512-urGGYeWtWNYMKnYlZnOnDHm8fVRffQs3U0SpE8RHeiuLKb/u92APS8HoQnPTFbnXmY1vVnXjXO4dOxcAn3J+DA==" + "version": "0.37.97", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.97.tgz", + "integrity": "sha512-No1BXPcVkyVD4ZVmbNgDKaBoqgeQ+FJpzZ8wqHkfmBnTZig1FcH3iPPersiK1TUIAzgClh2IvOuVUYfcWLQAOA==" }, "node_modules/discord.js": { - "version": "14.15.3", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.15.3.tgz", - "integrity": "sha512-/UJDQO10VuU6wQPglA4kz2bw2ngeeSbogiIPx/TsnctfzV/tNf+q+i1HlgtX1OGpeOBpJH9erZQNO5oRM2uAtQ==", + "version": "14.16.2", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.16.2.tgz", + "integrity": "sha512-VGNi9WE2dZIxYM8/r/iatQQ+3LT8STW4hhczJOwm+DBeHq66vsKDCk8trChNCB01sMO9crslYuEMeZl2d7r3xw==", "dependencies": { - "@discordjs/builders": "^1.8.2", + "@discordjs/builders": "^1.9.0", "@discordjs/collection": "1.5.3", - "@discordjs/formatters": "^0.4.0", - "@discordjs/rest": "^2.3.0", - "@discordjs/util": "^1.1.0", - "@discordjs/ws": "^1.1.1", + "@discordjs/formatters": "^0.5.0", + "@discordjs/rest": "^2.4.0", + "@discordjs/util": "^1.1.1", + "@discordjs/ws": "1.1.1", "@sapphire/snowflake": "3.5.3", - "discord-api-types": "0.37.83", + "discord-api-types": "0.37.97", "fast-deep-equal": "3.1.3", "lodash.snakecase": "4.1.1", - "tslib": "2.6.2", - "undici": "6.13.0" + "tslib": "^2.6.3", + "undici": "6.19.8" }, "engines": { - "node": ">=16.11.0" + "node": ">=18" }, "funding": { "url": "https://github.com/discordjs/discord.js?sponsor" } }, - "node_modules/discord.js/node_modules/undici": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.13.0.tgz", - "integrity": "sha512-Q2rtqmZWrbP8nePMq7mOJIN98M0fYvSgV89vwl/BQRT4mDOeY2GXZngfGpcBBhtky3woM7G24wZV3Q304Bv6cw==", - "engines": { - "node": ">=18.0" - } - }, "node_modules/dom-serializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", @@ -2086,9 +2075,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.13", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.13.tgz", - "integrity": "sha512-lbBcvtIJ4J6sS4tb5TLp1b4LyfCdMkwStzXPyAgVgTRAsep4bvrAGaBOP7ZJtQMNJpSQ9SqG4brWOroNaQtm7Q==", + "version": "1.5.25", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.25.tgz", + "integrity": "sha512-kMb204zvK3PsSlgvvwzI3wBIcAw15tRkYk+NQdsjdDtcQWTp2RABbMQ9rUBy8KNEOM+/E6ep+XC3AykiWZld4g==", "dev": true }, "node_modules/emittery": { @@ -3609,28 +3598,20 @@ } }, "node_modules/mariadb": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/mariadb/-/mariadb-3.3.1.tgz", - "integrity": "sha512-L8bh4iuZU3J8H7Co7rQ6OY9FDLItAN1rGy8kPA7Dyxo8AiHADuuONoypKKp1pE09drs6e5LR7UW9luLZ/A4znA==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/mariadb/-/mariadb-3.3.2.tgz", + "integrity": "sha512-kZvRy00thfFxEksfbDWq+77nB2M520PIZ26LLuHbOvyeZ5XQ3OCY/YsDDu+ifYNHIcs+7UCmjm50GiPdogc24w==", "dependencies": { "@types/geojson": "^7946.0.14", - "@types/node": "^20.11.17", + "@types/node": "^22.5.4", "denque": "^2.1.0", "iconv-lite": "^0.6.3", - "lru-cache": "^10.2.0" + "lru-cache": "^10.3.0" }, "engines": { "node": ">= 14" } }, - "node_modules/mariadb/node_modules/@types/node": { - "version": "20.16.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.3.tgz", - "integrity": "sha512-/wdGiWRkMOm53gAsSyFMXFZHbVg7C6CbkrzHNpaHoYfsUWPg7m6ZRKtvQjgvQ9i8WT540a3ydRlRQbxjY30XxQ==", - "dependencies": { - "undici-types": "~6.19.2" - } - }, "node_modules/mariadb/node_modules/lru-cache": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", @@ -3698,9 +3679,9 @@ } }, "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, "node_modules/natural-compare": { @@ -3757,9 +3738,9 @@ "dev": true }, "node_modules/nodemon": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.4.tgz", - "integrity": "sha512-wjPBbFhtpJwmIeY2yP7QF+UKzPfltVGtfce1g/bB15/8vCGZj8uxD62b/b9M9/WVgme0NZudpownKN+c0plXlQ==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.5.tgz", + "integrity": "sha512-V5UtfYc7hjFD4SI3EzD5TR8ChAHEZ+Ns7Z5fBk8fAbTVAj+q3G+w7sHJrHxXBkVn6ApLVTljau8wfHwqmGUjMw==", "dev": true, "dependencies": { "chokidar": "^3.5.2", @@ -4025,9 +4006,9 @@ "peer": true }, "node_modules/picocolors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", - "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", + "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", "dev": true }, "node_modules/picomatch": { @@ -4623,9 +4604,9 @@ "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==" }, "node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" }, "node_modules/tunnel-agent": { "version": "0.6.0", From 4a7d07e480462d40d9d46a6c52805e5c6b2f493a Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 19 Sep 2024 12:15:10 +0200 Subject: [PATCH 68/78] added embed reply helper that works with fields --- helpers/embed-reply.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index ecba2b9..9ffd0ea 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -194,6 +194,30 @@ function embedReplyPrimaryColorImg(title, description, image, interaction) { return embedReply; } +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {fields} fields - A list of arrays + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ + +function embedReplyPrimaryColorWithFields(title, description, fields, interaction) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.primary), + title: title, + description: description, + fields: fields, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + return embedReply; +} + module.exports = { embedReply, embedReplyPrimaryColor, @@ -204,4 +228,5 @@ module.exports = { moderationDmEmbedReplyFailureColor, embedReplyImg, embedReplyPrimaryColorImg, + embedReplyPrimaryColorWithFields } \ No newline at end of file From b81f2fcd0e7adbb13201132523f14c1b1ea68bf4 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 19 Sep 2024 12:18:06 +0200 Subject: [PATCH 69/78] used the embed reply with fields helper function in the /help command --- commands/utility/help.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/commands/utility/help.js b/commands/utility/help.js index 049c26a..97fcb60 100755 --- a/commands/utility/help.js +++ b/commands/utility/help.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("discord.js"); +const { embedReplyPrimaryColorWithFields } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -6,11 +7,10 @@ module.exports = { .setName("help") .setDescription("Displays the bot's commands."), async execute(interaction) { - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Help.", - description: "Here is a list of the bot's currently avaliable commands:", - fields: [ + const embedReply = embedReplyPrimaryColorWithFields( + "Help.", + "Here is a list of the bot's currently avaliable commands:", + [ { name: "Utility", value: "`/help` - Displays this message.\n" + "`/ping` - Displays the discord API's current latency.\n" + @@ -47,12 +47,8 @@ module.exports = { "`/autorole-disable` - Disables the autorole feature. New members won't get the specified role automatically on join anymore.\n" }, ], - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - } - }) + interaction + ); await interaction.reply({ embeds: [embedReply] }); From 9fa5250212c2973365d21b4729543ed5d2a19c41 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 19 Sep 2024 12:27:13 +0200 Subject: [PATCH 70/78] used the embed helper function in the /ping-db command --- commands/utility/ping-db.js | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/commands/utility/ping-db.js b/commands/utility/ping-db.js index 6ea3489..c4ef2f5 100644 --- a/commands/utility/ping-db.js +++ b/commands/utility/ping-db.js @@ -1,4 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("discord.js"); +const { embedReplyPrimaryColorWithFields, embedReplyFailureColor } = require("../../helpers/embed-reply"); const db = require("../../helpers/db"); const { logToFileAndDatabase } = require("../../helpers/logger"); @@ -7,10 +8,7 @@ module.exports = { .setName("ping-db") .setDescription("Displays the the bot's MariaDB database's current latency."), async execute(interaction) { - // let conn; try { - // let conn; - // conn = await db.pool.getConnection(); const startTime = Date.now(); await db.query("SELECT 1"); @@ -18,26 +16,25 @@ module.exports = { const latency = endTime - startTime; - var embedRespone = `**${latency}ms** or **${latency / 1000}s**`; + const embedReply = embedReplyPrimaryColorWithFields( + "Ping the database", + "", + [ + { name: "Pong from the database! :ping_pong:", value: "" }, + { name: "Response time: ", value: `**${latency}ms** or **${latency / 1000}s**` }, + ], + interaction + ); } catch (error) { console.error(error); - var embedRespone = "**Error:** Database connection failed.\nIf this issue persists, please [report it on GitHub](https://github.com/vb2007/discordbot/issues/new)."; - } - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Ping the database.", - fields: [ - { name: "Pong from the database! :ping_pong:", value: "" }, - { name: "Response time: ", value: embedRespone, inline: true }, - ], - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}`, - icon_url: interaction.user.displayAvatarURL({ dynamic: true }) - } - }); + const embedReply = embedReplyFailureColor( + "Ping the database - Error", + "**Error:** Database connection failed.\nIf this issue persists, please [report it on GitHub](https://github.com/vb2007/discordbot/issues/new).", + interaction + ); + } await interaction.reply({ embeds: [embedReply] }); From 75d6a7f140ccf4f8d4796ab075e8407dccec8d72 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 19 Sep 2024 12:28:44 +0200 Subject: [PATCH 71/78] used the helper function in the /ping command --- commands/utility/ping.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/commands/utility/ping.js b/commands/utility/ping.js index 6dd8a01..d686e58 100755 --- a/commands/utility/ping.js +++ b/commands/utility/ping.js @@ -1,4 +1,5 @@ const { EmbedBuilder, SlashCommandBuilder } = require('discord.js'); +const { embedReplyPrimaryColorWithFields } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -7,19 +8,15 @@ module.exports = { .setDescription("Displays the discord API's current latency."), async execute(interaction) { - const embedReply = new EmbedBuilder({ - color : 0x5F0FD6, - title : "Ping.", - fields: [ + const embedReply = embedReplyPrimaryColorWithFields( + "Ping.", + "", + [ { name: "Pong! :ping_pong:", value: ""}, { name: "Response time: ", value: `${Date.now() - interaction.createdTimestamp}ms`, inline: true }, ], - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - } - }); + interaction + ); await interaction.reply({ embeds: [embedReply] }); From 940fb0d149911ec91ce728e9e1fa2f8ae1ffdbba Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 19 Sep 2024 12:38:07 +0200 Subject: [PATCH 72/78] added new embed helper reply function with an author paramter, made use of the function in the /server command --- commands/utility/ping.js | 4 +-- commands/utility/server.js | 55 +++++++++++++++++--------------------- helpers/embed-reply.js | 29 ++++++++++++++++++-- 3 files changed, 53 insertions(+), 35 deletions(-) diff --git a/commands/utility/ping.js b/commands/utility/ping.js index d686e58..e27c284 100755 --- a/commands/utility/ping.js +++ b/commands/utility/ping.js @@ -1,4 +1,4 @@ -const { EmbedBuilder, SlashCommandBuilder } = require('discord.js'); +const { SlashCommandBuilder } = require('discord.js'); const { embedReplyPrimaryColorWithFields } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); @@ -13,7 +13,7 @@ module.exports = { "", [ { name: "Pong! :ping_pong:", value: ""}, - { name: "Response time: ", value: `${Date.now() - interaction.createdTimestamp}ms`, inline: true }, + { name: "Response time: ", value: `${Date.now() - interaction.createdTimestamp}ms`, inline: true } ], interaction ); diff --git a/commands/utility/server.js b/commands/utility/server.js index c3011aa..85b6473 100755 --- a/commands/utility/server.js +++ b/commands/utility/server.js @@ -1,4 +1,5 @@ const { EmbedBuilder, SlashCommandBuilder } = require('discord.js'); +const { embedReplyPrimaryColorWithFieldsAndAuthor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -13,39 +14,31 @@ module.exports = { var embedDescription = "This function is only avalible on servers."; } else { - const { guild } = interaction; + // const { guild } = interaction; - var authorField = { name: guild.name, iconUrl: guild.iconURL({ size: 256}) } - var embedFields = [ - { name: "Creation date", value: guild.createdAt.toDateString(), inline : true }, - { name: "Members", value: guild.memberCount, inline: true }, - { name: "Owner", value: (await guild.fetchOwner()).user.tag, inline: true }, - //channel(c).type: - //0 = text channels - //2 = voice channels - //4 = categories - { name: "Text channels", value: guild.channels.cache.filter((c) => c.type === 0).toJSON().length, inline: true }, - { name: "Voice channels", value: guild.channels.cache.filter((c) => c.type === 2).toJSON().length, inline: true }, - { name: "Categories", value: guild.channels.cache.filter((c) => c.type === 4).toJSON().length, inline: true }, - //size - 1 --> @everyone excluded - { name: "Roles (@everyone included)", value: guild.roles.cache.size, inline: true }, - { name: "Role list", value: guild.roles.cache.toJSON().join(", ") }, - { name: "Server Id", value: guild.id }, - ]; + var embedReply = embedReplyPrimaryColorWithFieldsAndAuthor( + "Server information.", + "", + [ + { name: "Creation date", value: interaction.createdAt.toDateString(), inline : true }, + { name: "Members", value: interaction.memberCount, inline: true }, + { name: "Owner", value: (await interaction.fetchOwner()).user.tag, inline: true }, + //channel(c).type: + //0 = text channels + //2 = voice channels + //4 = categories + { name: "Text channels", value: interaction.channels.cache.filter((c) => c.type === 0).toJSON().length, inline: true }, + { name: "Voice channels", value: interaction.channels.cache.filter((c) => c.type === 2).toJSON().length, inline: true }, + { name: "Categories", value: interaction.channels.cache.filter((c) => c.type === 4).toJSON().length, inline: true }, + //size - 1 --> @everyone excluded + { name: "Roles (@everyone included)", value: interaction.roles.cache.size, inline: true }, + { name: "Role list", value: interaction.roles.cache.toJSON().join(", ") }, + { name: "Server Id", value: interaction.id }, + ], + { name: interaction.name, iconUrl: interaction.iconURL({ size: 256}) }, + interaction + ); } - - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "Server information.", - description: embedDescription, - author: authorField, - fields: embedFields, - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - } - }); await interaction.reply({ embeds: [embedReply] }); diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index 9ffd0ea..4db267f 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -201,7 +201,6 @@ function embedReplyPrimaryColorImg(title, description, image, interaction) { * @param {interaction} interaction - Interaction object from the command * @returns {embedReply} An embed reply object */ - function embedReplyPrimaryColorWithFields(title, description, fields, interaction) { const embedReply = new EmbedBuilder({ color: parseInt(embedColors.primary), @@ -218,6 +217,31 @@ function embedReplyPrimaryColorWithFields(title, description, fields, interactio return embedReply; } +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {fields} fields - A list of arrays + * @param {author} author - An object with the author's name and icon + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ +function embedReplyPrimaryColorWithFieldsAndAuthor(title, description, fields, author, interaction) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.primary), + title: title, + description: description, + fields: fields, + author: author, + timestamp: new Date().toISOString(), + footer: { + text: `Requested by: ${interaction.user.username}`, + icon_url: interaction.user.displayAvatarURL({ dynamic: true }) + } + }); + + return embedReply; +} + module.exports = { embedReply, embedReplyPrimaryColor, @@ -228,5 +252,6 @@ module.exports = { moderationDmEmbedReplyFailureColor, embedReplyImg, embedReplyPrimaryColorImg, - embedReplyPrimaryColorWithFields + embedReplyPrimaryColorWithFields, + embedReplyPrimaryColorWithFieldsAndAuthor } \ No newline at end of file From 735d347c68eca5b5be05d904af2375e3c52cf5c5 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 19 Sep 2024 12:39:48 +0200 Subject: [PATCH 73/78] fixed some function uses and imports in the /server command --- commands/utility/server.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/commands/utility/server.js b/commands/utility/server.js index 85b6473..cdb18d0 100755 --- a/commands/utility/server.js +++ b/commands/utility/server.js @@ -1,5 +1,5 @@ -const { EmbedBuilder, SlashCommandBuilder } = require('discord.js'); -const { embedReplyPrimaryColorWithFieldsAndAuthor } = require("../../helpers/embed-reply"); +const { SlashCommandBuilder } = require('discord.js'); +const { embedReplyPrimaryColorWithFieldsAndAuthor, embedReplyFailureColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -9,14 +9,16 @@ module.exports = { .setDMPermission(false), async execute(interaction) { if(!interaction.inGuild()) { - var authorField = {}; - var embedFields = []; - var embedDescription = "This function is only avalible on servers."; + const embedReply = embedReplyFailureColor( + "Server information - Error", + "This function is only avalible on servers.", + interaction + ); } else { // const { guild } = interaction; - var embedReply = embedReplyPrimaryColorWithFieldsAndAuthor( + const embedReply = embedReplyPrimaryColorWithFieldsAndAuthor( "Server information.", "", [ From 223d10921c525bba5cace7ea5cd1cf41463a39d0 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 19 Sep 2024 12:43:02 +0200 Subject: [PATCH 74/78] used embed helper in the /user command --- commands/utility/user.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/commands/utility/user.js b/commands/utility/user.js index 7507098..4911c06 100755 --- a/commands/utility/user.js +++ b/commands/utility/user.js @@ -1,4 +1,5 @@ -const { SlashCommandBuilder, EmbedBuilder } = require('discord.js'); +const { SlashCommandBuilder } = require('discord.js'); +const { embedReplyPrimaryColorWithFields } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -17,11 +18,10 @@ module.exports = { const targetUser = interaction.options.getUser("user") || interaction.user; const targetMember = await interaction.guild.members.fetch(targetUser.id); - const embedReply = new EmbedBuilder({ - color: 0x5F0FD6, - title: "User information.", - // thumbnail: targetUser.displayAvatarURL({ dynamic: true }), - fields: [ + const embedReply = embedReplyPrimaryColorWithFields( + "User information.", + "", + [ { name: "Username", value: targetUser.username || "None", inline : true }, { name: "Display name", value: targetUser.globalName || "None", inline : true }, { name: "Nickname", value: targetMember.nickname || "None", inline : true }, @@ -47,12 +47,8 @@ module.exports = { // { name: "Is custom status?", value: targetUser.presence.activities[0]?.type === "CUSTOM_STATUS", inline : true }, // { name: "Is competing?", value: targetUser.presence.activities[0]?.type === "COMPETING", inline : true }, ], - timestamp: new Date().toISOString(), - footer: { - text: `Requested by: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); + interaction + ); await interaction.reply({ embeds: [embedReply]}); From c4711b43b9282521ce54cec399c82b9c58c3aaf8 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 21 Sep 2024 21:50:55 +0200 Subject: [PATCH 75/78] fixed shit in /server and /ping-db --- commands/utility/ping-db.js | 5 ++--- commands/utility/server.js | 26 ++++++++++++-------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/commands/utility/ping-db.js b/commands/utility/ping-db.js index c4ef2f5..de42455 100644 --- a/commands/utility/ping-db.js +++ b/commands/utility/ping-db.js @@ -9,14 +9,13 @@ module.exports = { .setDescription("Displays the the bot's MariaDB database's current latency."), async execute(interaction) { try { - const startTime = Date.now(); await db.query("SELECT 1"); const endTime = Date.now(); const latency = endTime - startTime; - const embedReply = embedReplyPrimaryColorWithFields( + var embedReply = embedReplyPrimaryColorWithFields( "Ping the database", "", [ @@ -29,7 +28,7 @@ module.exports = { catch (error) { console.error(error); - const embedReply = embedReplyFailureColor( + var embedReply = embedReplyFailureColor( "Ping the database - Error", "**Error:** Database connection failed.\nIf this issue persists, please [report it on GitHub](https://github.com/vb2007/discordbot/issues/new).", interaction diff --git a/commands/utility/server.js b/commands/utility/server.js index cdb18d0..a956118 100755 --- a/commands/utility/server.js +++ b/commands/utility/server.js @@ -9,35 +9,33 @@ module.exports = { .setDMPermission(false), async execute(interaction) { if(!interaction.inGuild()) { - const embedReply = embedReplyFailureColor( + var embedReply = embedReplyFailureColor( "Server information - Error", "This function is only avalible on servers.", interaction ); } else { - // const { guild } = interaction; - - const embedReply = embedReplyPrimaryColorWithFieldsAndAuthor( + var embedReply = embedReplyPrimaryColorWithFieldsAndAuthor( "Server information.", "", [ - { name: "Creation date", value: interaction.createdAt.toDateString(), inline : true }, - { name: "Members", value: interaction.memberCount, inline: true }, - { name: "Owner", value: (await interaction.fetchOwner()).user.tag, inline: true }, + { name: "Creation date", value: interaction.guild.createdAt.toDateString(), inline : true }, + { name: "Members", value: interaction.guild.memberCount, inline: true }, + { name: "Owner", value: (await interaction.guild.fetchOwner()).user.tag, inline: true }, //channel(c).type: //0 = text channels //2 = voice channels //4 = categories - { name: "Text channels", value: interaction.channels.cache.filter((c) => c.type === 0).toJSON().length, inline: true }, - { name: "Voice channels", value: interaction.channels.cache.filter((c) => c.type === 2).toJSON().length, inline: true }, - { name: "Categories", value: interaction.channels.cache.filter((c) => c.type === 4).toJSON().length, inline: true }, + { name: "Text channels", value: interaction.guild.channels.cache.filter((c) => c.type === 0).toJSON().length, inline: true }, + { name: "Voice channels", value: interaction.guild.channels.cache.filter((c) => c.type === 2).toJSON().length, inline: true }, + { name: "Categories", value: interaction.guild.channels.cache.filter((c) => c.type === 4).toJSON().length, inline: true }, //size - 1 --> @everyone excluded - { name: "Roles (@everyone included)", value: interaction.roles.cache.size, inline: true }, - { name: "Role list", value: interaction.roles.cache.toJSON().join(", ") }, - { name: "Server Id", value: interaction.id }, + { name: "Roles (@everyone included)", value: interaction.guild.roles.cache.size, inline: true }, + { name: "Role list", value: interaction.guild.roles.cache.toJSON().join(", ") }, + { name: "Server Id", value: interaction.guild.id }, ], - { name: interaction.name, iconUrl: interaction.iconURL({ size: 256}) }, + { name: interaction.guild.name, iconUrl: interaction.guild.iconURL({ size: 256}) }, interaction ); } From 2e8617c69fc7b7a4f773a9df7a8db51df83678f9 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 21 Sep 2024 21:59:25 +0200 Subject: [PATCH 76/78] added dm reply helper function, changed sidebar color in warning embed dm reply --- commands/moderation/warn.js | 4 ++-- helpers/embed-reply.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index 4267b32..ac55adb 100755 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); -const { embedReplySuccessColor, embedReplyFailureColor, moderationDmEmbedReplyFailureColor } = require('../../helpers/embed-reply'); +const { embedReplySuccessColor, embedReplyFailureColor, moderationDmEmbedReplyWarningColor } = require('../../helpers/embed-reply'); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { @@ -38,7 +38,7 @@ module.exports = { } else{ try{ - const embedDmReply = moderationDmEmbedReplyFailureColor( + const embedDmReply = moderationDmEmbedReplyWarningColor( "You have been warned.", `You have been warned in **${interaction.guild.name}** for: **${reason}** \nIf you believe this was a mistake, please contact a moderator.`, interaction diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index 4db267f..fb19862 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -128,6 +128,12 @@ function embedReplyWarningColor(title, description, interaction) { return embedReply; } +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ function moderationDmEmbedReplyFailureColor(title, description, interaction) { const embedDmReply = new EmbedBuilder({ color: parseInt(embedColors.failure), @@ -143,6 +149,27 @@ function moderationDmEmbedReplyFailureColor(title, description, interaction) { return embedDmReply; } +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {interaction} interaction - Interaction object from the command + * @returns {embedReply} An embed reply object + */ +function moderationDmEmbedReplyWarningColor(title, description, interaction) { + const embedDmReply = new EmbedBuilder({ + color: parseInt(embedColors.warning), + title: title, + description: description, + timestamp: new Date().toISOString(), + footer: { + text: `Moderator: ${interaction.user.username}` , + icon_url: interaction.user.displayAvatarURL({ dynamic: true }), + }, + }); + + return embedDmReply; +} + /** * @param {color} color - Embed's sidebar HEX Color * @param {title} title - Embed's title @@ -250,6 +277,7 @@ module.exports = { embedReplyFailureColor, embedReplyWarningColor, moderationDmEmbedReplyFailureColor, + moderationDmEmbedReplyWarningColor, embedReplyImg, embedReplyPrimaryColorImg, embedReplyPrimaryColorWithFields, From 599d9efb613545af9e68c110616a434206419dc0 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 21 Sep 2024 22:03:23 +0200 Subject: [PATCH 77/78] fixed incorrect function in economy commands --- commands/economy/withdraw.js | 4 ++-- commands/economy/work.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/economy/withdraw.js b/commands/economy/withdraw.js index f64ee05..b67f5e9 100644 --- a/commands/economy/withdraw.js +++ b/commands/economy/withdraw.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedSuccessColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -36,7 +36,7 @@ module.exports = { ] ); - var embedReply = embedSuccessColor( + var embedReply = embedReplySuccessColor( "Withdraw successful.", `You've successfully withdrawn \`$${amount}\` from your bank account.\nYour current balance in the bank is \`$${balanceInBank - amount}\`. :bank:\nYour current balance is \`$${balance + amount}\`. :moneybag:`, interaction diff --git a/commands/economy/work.js b/commands/economy/work.js index eae0321..92ee19f 100644 --- a/commands/economy/work.js +++ b/commands/economy/work.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedSuccessColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -25,7 +25,7 @@ module.exports = { ] ); - var embedReply = embedSuccessColor( + var embedReply = embedReplySuccessColor( "Working.", `You've worked and succesfully earned \`$${amount}\` dollars.`, interaction From cadc5c0fd89574311483c8c196331e49cbc0dc2f Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 21 Sep 2024 22:25:56 +0200 Subject: [PATCH 78/78] fixed emojis in /pay command, fixed .env value parsing in command deployment --- commands/economy/pay.js | 6 +++--- deploy-commands.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/commands/economy/pay.js b/commands/economy/pay.js index c586fe0..c6b3f59 100644 --- a/commands/economy/pay.js +++ b/commands/economy/pay.js @@ -40,14 +40,14 @@ module.exports = { if (amount > userBalance) { var embedReply = embedReplyFailureColor( "Payment - Error", - `:x: You can't pay that much money to <@${targetUserId}>!\nYour balance is only \`$${userBalance}\`.`, + `You can't pay that much money to <@${targetUserId}>! :x:\nYour balance is only \`$${userBalance}\`.`, interaction ); } else if (amount <= 0) { var embedReply = embedReplyFailureColor( "Payment - Error", - `:x: You can't pay a negative or zero amount of money to <@${targetUserId}>!\nTry again with a positive amount.`, + `You can't pay a negative or zero amount of money to <@${targetUserId}>! :x:\nTry again with a positive amount.`, interaction ); } @@ -78,7 +78,7 @@ module.exports = { var embedReply = embedReplySuccessColor( "Payment successful", - `:white_check_mark: <@${interactionUserId}> has successfully paid \`$${amount}\` to <@${targetUserId}>.`, + `<@${interactionUserId}> has successfully paid \`$${amount}\` to <@${targetUserId}>. :white_check_mark:`, interaction ); } diff --git a/deploy-commands.js b/deploy-commands.js index 68f2263..79827e9 100755 --- a/deploy-commands.js +++ b/deploy-commands.js @@ -1,11 +1,11 @@ -const token = process.env.TOKEN; -const clientId = process.env.CLIENT_ID; -console.log(token); - const { REST, Routes } = require('discord.js'); const fs = require('node:fs'); const path = require('node:path'); +require('dotenv').config(); +const token = process.env.TOKEN; +const clientId = process.env.CLIENT_ID; + const commands = []; //specifying the path to the commands