From 7254526da86f77d678052c39f6ba14ec36ef0e6a Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 14 Oct 2024 22:08:44 +0200 Subject: [PATCH 001/100] updated packages --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 057aab0..41c6a4d 100755 --- a/package-lock.json +++ b/package-lock.json @@ -2107,9 +2107,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.36", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.36.tgz", - "integrity": "sha512-HYTX8tKge/VNp6FGO+f/uVDmUkq+cEfcxYhKf15Akc4M5yxt5YmorwlAitKWjWhWQnKcDRBAQKXkhqqXMqcrjw==", + "version": "1.5.37", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.37.tgz", + "integrity": "sha512-u7000ZB/X0K78TaQqXZ5ktoR7J79B9US7IkE4zyvcILYwOGY2Tx9GRPYstn7HmuPcMxZ+BDGqIsyLpZQi9ufPw==", "dev": true }, "node_modules/emittery": { @@ -4698,9 +4698,9 @@ "dev": true }, "node_modules/undici": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.20.0.tgz", - "integrity": "sha512-AITZfPuxubm31Sx0vr8bteSalEbs9wQb/BOBi9FPlD9Qpd6HxZ4Q0+hI742jBhkPb4RT2v5MQzaW5VhRVyj+9A==", + "version": "6.20.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.20.1.tgz", + "integrity": "sha512-AjQF1QsmqfJys+LXfGTNum+qw4S88CojRInG/6t31W/1fk6G59s92bnAvGz5Cmur+kQv2SURXEvvudLmbrE8QA==", "engines": { "node": ">=18.17" } From 1daaafc958d15691598749961bbbb8f37f26f07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20V=C3=A1gv=C3=B6lgyi?= Date: Tue, 15 Oct 2024 14:11:17 +0200 Subject: [PATCH 002/100] added logging configure / disable commands + base concept for logging-configure --- commands/administration/logging-configure.js | 22 ++++++++++++++++++++ commands/administration/logging-disable.js | 0 2 files changed, 22 insertions(+) create mode 100644 commands/administration/logging-configure.js create mode 100644 commands/administration/logging-disable.js diff --git a/commands/administration/logging-configure.js b/commands/administration/logging-configure.js new file mode 100644 index 0000000..dc72896 --- /dev/null +++ b/commands/administration/logging-configure.js @@ -0,0 +1,22 @@ +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const { embedReplySuccessColor, embedReplySuccessSecondaryColor, embedReplyWarningColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { logToFileAndDatabase } = require("../../helpers/logger"); +const db = require("../../helpers/db"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("logging-configure") + .setDescription("Sets up logging with various options for the current server.") + .addChannelOption(option => + option + .setName("target-channel") + .setDescription("A channel where the bot will send the logged data.") + .addChannelType(0) //= text channels + .setRequired(true) + ) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .setDMPermission(false), + async execute(interaction) { + + } +} \ No newline at end of file diff --git a/commands/administration/logging-disable.js b/commands/administration/logging-disable.js new file mode 100644 index 0000000..e69de29 From adaac3d4ddbf39c559bc7d5233cc3c3e8caac661 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Fri, 18 Oct 2024 22:51:58 +0200 Subject: [PATCH 003/100] updated sql table schemas for logging --- sql/commandUsageLog/table.sql | 19 +++++++++++++++++++ sql/log/table.sql | 17 ----------------- sql/messageLog/table.sql | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 sql/commandUsageLog/table.sql delete mode 100755 sql/log/table.sql create mode 100644 sql/messageLog/table.sql diff --git a/sql/commandUsageLog/table.sql b/sql/commandUsageLog/table.sql new file mode 100644 index 0000000..95b9226 --- /dev/null +++ b/sql/commandUsageLog/table.sql @@ -0,0 +1,19 @@ +-- discordbotTest.commandUsageLog definition + +CREATE TABLE `commandUsageLog` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `commandName` tinytext DEFAULT NULL, + `executorUserName` text DEFAULT NULL, + `executorUserId` bigint(20) DEFAULT NULL, + `isInServer` tinyint(1) DEFAULT NULL, + `serverName` text DEFAULT NULL, + `serverId` bigint(20) DEFAULT NULL, + `channelName` text DEFAULT NULL, + `channelId` bigint(20) DEFAULT NULL, + `usageTime` timestamp NOT NULL DEFAULT current_timestamp(), + `response` text DEFAULT NULL COMMENT 'Embed object that the bot sends back to the command''s executor.', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +CREATE INDEX IF NOT EXISTS idx_executorUserId ON commandUsageLog(executorUserId); +CREATE INDEX IF NOT EXISTS idx_usageTime ON commandUsageLog(usageTime); \ No newline at end of file diff --git a/sql/log/table.sql b/sql/log/table.sql deleted file mode 100755 index 766ee04..0000000 --- a/sql/log/table.sql +++ /dev/null @@ -1,17 +0,0 @@ --- discordbot.log definition - -CREATE TABLE IF NOT EXISTS `log` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT, - `commandName` tinytext DEFAULT NULL, - /* tinytext = max. 255 characters */ - `executorUserName` text DEFAULT NULL, - `executorUserId` bigint(20) DEFAULT NULL, - `isInServer` tinyint(1) DEFAULT NULL, - `serverName` text DEFAULT NULL, - `serverId` bigint(20) DEFAULT NULL, - `channelName` text DEFAULT NULL, - `channelId` bigint(20) DEFAULT NULL, - `time` TIMESTAMP NOT NULL DEFAULT current_timestamp(), - `response` text DEFAULT NULL COMMENT 'Embed object that the bot sends back to the command''s executor.', - PRIMARY KEY (`id`) -); \ No newline at end of file diff --git a/sql/messageLog/table.sql b/sql/messageLog/table.sql new file mode 100644 index 0000000..c5a537f --- /dev/null +++ b/sql/messageLog/table.sql @@ -0,0 +1,15 @@ +-- discordbot.messageLog definition + +CREATE TABLE IF NOT EXISTS `messageLog` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `message` text NOT NULL, + `senderUserName` text DEFAULT NULL, + `senderUserId` bigint(20) DEFAULT NULL, + `serverName` text DEFAULT NULL, + `serverId` bigint(20) DEFAULT NULL, + `channelName` text DEFAULT NULL, + `channelId` bigint(20) DEFAULT NULL, + `sentOn` TIMESTAMP NOT NULL, + `deletedOn` TIMESTAMP NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; \ No newline at end of file From ac9967a770fdfacb4fe27998753dfabf0987330b Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 19 Oct 2024 17:43:20 +0200 Subject: [PATCH 004/100] added messageCreate event and logging script, updated table schema --- events/messageCreate.js | 8 ++++++++ events/messageDelete.js | 0 events/scripts/messageCreate/logging.js | 24 ++++++++++++++++++++++++ sql/messageLog/table.sql | 6 +++--- 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 events/messageCreate.js create mode 100644 events/messageDelete.js create mode 100644 events/scripts/messageCreate/logging.js diff --git a/events/messageCreate.js b/events/messageCreate.js new file mode 100644 index 0000000..561be85 --- /dev/null +++ b/events/messageCreate.js @@ -0,0 +1,8 @@ +const logging = require("./scripts/messageCreate/logging"); + +module.exports = { + name: "messageCreate", + async execute(message) { + await logging.logMessage(message); + }, +}; \ No newline at end of file diff --git a/events/messageDelete.js b/events/messageDelete.js new file mode 100644 index 0000000..e69de29 diff --git a/events/scripts/messageCreate/logging.js b/events/scripts/messageCreate/logging.js new file mode 100644 index 0000000..31108e7 --- /dev/null +++ b/events/scripts/messageCreate/logging.js @@ -0,0 +1,24 @@ +const db = require("../../../helpers/db"); + +module.exports = { + async logMessage(message) { + const messageContent = message.content; + const senderUserName = message.author.username; + const senderUserId = message.author.id; + const serverName = message.guild.name; + const serverId = message.guild.id; + const channelName = message.channel.name; + const channelId = message.channel.id; + + try { + await db.query("INSERT INTO messageLog (message, senderUserName, senderUserId, serverName, serverId, channelName, channelId) VALUES (?, ?, ?, ?, ?, ?, ?)", + [ + messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId + ] + ); + } + catch (error) { + console.error(`Failed to log message: ${error}`); + } + } +} \ No newline at end of file diff --git a/sql/messageLog/table.sql b/sql/messageLog/table.sql index c5a537f..ec2cfa7 100644 --- a/sql/messageLog/table.sql +++ b/sql/messageLog/table.sql @@ -2,14 +2,14 @@ CREATE TABLE IF NOT EXISTS `messageLog` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, - `message` text NOT NULL, + `messageContent` text NOT NULL, `senderUserName` text DEFAULT NULL, `senderUserId` bigint(20) DEFAULT NULL, `serverName` text DEFAULT NULL, `serverId` bigint(20) DEFAULT NULL, `channelName` text DEFAULT NULL, `channelId` bigint(20) DEFAULT NULL, - `sentOn` TIMESTAMP NOT NULL, - `deletedOn` TIMESTAMP NOT NULL DEFAULT current_timestamp(), + `sentOn` TIMESTAMP NOT NULL DEFAULT current_timestamp(), + `deletedOn` TIMESTAMP DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; \ No newline at end of file From 713a433eeeff6c08d0063b21ff886094f6b2b162 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 19 Oct 2024 18:28:45 +0200 Subject: [PATCH 005/100] fixed logging --- commands/administration/logging-configure.js | 2 +- events/scripts/messageCreate/logging.js | 3 ++- index.js | 12 ++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/commands/administration/logging-configure.js b/commands/administration/logging-configure.js index dc72896..0eb14f8 100644 --- a/commands/administration/logging-configure.js +++ b/commands/administration/logging-configure.js @@ -11,7 +11,7 @@ module.exports = { option .setName("target-channel") .setDescription("A channel where the bot will send the logged data.") - .addChannelType(0) //= text channels + .addChannelTypes(0) //= text channels .setRequired(true) ) .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) diff --git a/events/scripts/messageCreate/logging.js b/events/scripts/messageCreate/logging.js index 31108e7..0f3edfd 100644 --- a/events/scripts/messageCreate/logging.js +++ b/events/scripts/messageCreate/logging.js @@ -11,11 +11,12 @@ module.exports = { const channelId = message.channel.id; try { - await db.query("INSERT INTO messageLog (message, senderUserName, senderUserId, serverName, serverId, channelName, channelId) VALUES (?, ?, ?, ?, ?, ?, ?)", + await db.query("INSERT INTO messageLog (messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId) VALUES (?, ?, ?, ?, ?, ?, ?)", [ messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId ] ); + console.log(`Logged message "${message.content}" from ${senderUserName} in ${serverName}.`); } catch (error) { console.error(`Failed to log message: ${error}`); diff --git a/index.js b/index.js index 5ee4bde..dffb07b 100755 --- a/index.js +++ b/index.js @@ -14,7 +14,14 @@ require("./scripts/verify-config-syntax"); const { Client, Collection, Events, GatewayIntentBits, ActivityType } = require("discord.js"); -const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers] }); +const client = new Client({ intents: + [ + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.MessageContent, + ] +}); //notifies owner on console if the app is ready client.once(Events.ClientReady, readyClient => { @@ -52,7 +59,8 @@ const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith(".js" for (const file of eventFiles) { const filePath = path.join(eventsPath, file); - const event = require(filePath) + const event = require(filePath); + console.log("Event: ", event); if (event.once) { client.once(event.name, (...args) => event.execute(...args)); From bc3255e0f0d4903e87ad0af53a0f47c0f0342d4c Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 19 Oct 2024 19:27:29 +0200 Subject: [PATCH 006/100] added table schema for logging configuration --- sql/configLogging/table.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 sql/configLogging/table.sql diff --git a/sql/configLogging/table.sql b/sql/configLogging/table.sql new file mode 100644 index 0000000..f77c703 --- /dev/null +++ b/sql/configLogging/table.sql @@ -0,0 +1,15 @@ +CREATE TABLE IF NOT EXISTS `configLogging` ( + `guildId` varchar(50) NOT NULL, + `logChannelId` text DEFAULT NULL, + `logChannelName` text DEFAULT NULL, + `lastModifiedAt` timestamp NOT NULL DEFAULT current_timestamp(), + `lastModifierId` text DEFAULT NULL, + `lastModifierName` text DEFAULT NULL, + `addedAt` timestamp NOT NULL DEFAULT current_timestamp(), + `firstConfigurerId` text DEFAULT NULL, + `firstConfigurerName` text DEFAULT NULL, + PRIMARY KEY (`guildId`) +); + +CREATE INDEX IF NOT EXISTS idx_guildId ON configLogging(guildId); +CREATE INDEX IF NOT EXISTS idx_logChannelId ON configLogging(logChannelId); \ No newline at end of file From c2cffbaf5df4fc41f3dd0ed5bd0e3f3a9998de68 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sat, 19 Oct 2024 22:47:29 +0200 Subject: [PATCH 007/100] updated table schema, updated logging-configure --- commands/administration/logging-configure.js | 81 +++++++++++++++++++- sql/configLogging/table.sql | 6 +- 2 files changed, 82 insertions(+), 5 deletions(-) diff --git a/commands/administration/logging-configure.js b/commands/administration/logging-configure.js index 0eb14f8..1ead1ef 100644 --- a/commands/administration/logging-configure.js +++ b/commands/administration/logging-configure.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { embedReplySuccessColor, embedReplySuccessSecondaryColor, embedReplyWarningColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplySuccessColor, embedReplySuccessSecondaryColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -17,6 +17,83 @@ module.exports = { .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) .setDMPermission(false), async execute(interaction) { - + if (!interaction.inGuild()) { + var embedReply = embedReplyFailureColor( + "Logging Configure: Error", + "You can only set up logging in a server.", + interaction + ); + } + else if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.Administrator)) { + var embedReply = embedReplyFailureColor( + "Logging Configure: Error", + "Logging some actions requires **administrator** *(8)* privileges which the bot currently lacks.\nIf you want this feature to work properly, please re-invite the bot with accurate privileges.", + interaction + ); + } + else { + try { + const targetChannel = interaction.options.getChannel("target-channel"); + const interactionUserId = interaction.user.id; + const interactionUsername = interaction.user.username + const targetChannelId = targetChannel.id; + const targetChannelName = targetChannel.name; + const guildId = interaction.guild.id; + + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const existingGuildId = query[0]?.guildId || null; + const existingLogChannelId = query[0]?.logChannelId || null; + + if (existingLogChannelId == targetChannelId) { + var embedReply = embedReplyFailureColor( + "Logging Configure: Error", + `Logging has already been configured for this server for the channel <#${targetChannelId}>. :x:\nRun the command with another channel to overwrite the current channel.`, + interaction + ); + } + else { + if (existingGuildId == guildId) { + var embedReply = embedReplySuccessSecondaryColor( + "Logging Configure: Configuration Modified", + `The logging channel has been updated to <#${targetChannelId}>. :white_check_mark:\nRun this command again to modify the channel.\nRun \`/logging-disable\` to disable this feature completely.`, + interaction + ); + + await db.query("UPDATE configLogging SET logChannelId = ?, logChannelName = ?, lastModifierId = ?, lastModifierName = ? WHERE guildId = ?", + [ + targetChannelId, targetChannelName, interactionUserId, interactionUsername, guildId + ] + ); + } + else { + var embedReply = embedReplySuccessColor( + "Logging Configure: Configuration Set", + `Logging has been set up for this server in <#${targetChannelId}>. :white_check_mark:\nRun this command again to modify the channel.\nRun \`/logging-disable\` to disable this feature completely.`, + interaction + ); + + await db.query("INSERT INTO configLogging (guildId, logChannelId, logChannelName, firstConfigurerId, firstConfigurerName) VALUES (?, ?, ?, ?, ?)", + [ + guildId, targetChannelId, targetChannelName, interactionUserId, interactionUsername + ] + ); + } + } + } + catch (error) { + // console.error(`Failed to configure logging: ${error}`); + var embedReply = embedReplyFailureColor( + "Logging Configure: Error", + "Failed to configure logging. Please try again.", + interaction + ); + } + } + + await interaction.reply({ embeds: [embedReply] }); + + //logging + const response = JSON.stringify(localEmbedResponse.toJSON()); + await logToFileAndDatabase(interaction, response); } } \ No newline at end of file diff --git a/sql/configLogging/table.sql b/sql/configLogging/table.sql index f77c703..b997d61 100644 --- a/sql/configLogging/table.sql +++ b/sql/configLogging/table.sql @@ -1,13 +1,13 @@ CREATE TABLE IF NOT EXISTS `configLogging` ( `guildId` varchar(50) NOT NULL, - `logChannelId` text DEFAULT NULL, + `logChannelId` text NOT NULL, `logChannelName` text DEFAULT NULL, `lastModifiedAt` timestamp NOT NULL DEFAULT current_timestamp(), `lastModifierId` text DEFAULT NULL, `lastModifierName` text DEFAULT NULL, `addedAt` timestamp NOT NULL DEFAULT current_timestamp(), - `firstConfigurerId` text DEFAULT NULL, - `firstConfigurerName` text DEFAULT NULL, + `firstConfigurerId` text NOT NULL, + `firstConfigurerName` text NOT NULL, PRIMARY KEY (`guildId`) ); From b3dfddcdffd2806410d362bb1717757707e07e85 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 20 Oct 2024 18:43:06 +0200 Subject: [PATCH 008/100] added base for logging-disable --- commands/administration/logging-disable.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/commands/administration/logging-disable.js b/commands/administration/logging-disable.js index e69de29..721785b 100644 --- a/commands/administration/logging-disable.js +++ b/commands/administration/logging-disable.js @@ -0,0 +1,15 @@ +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { logToFileAndDatabase } = require("../../helpers/logger"); +const db = require("../../helpers/db"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("logging-disable") + .setDescription("Disables the logging feature for the current server.") + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .setDMPermission(false), + async execute(interaction) { + + } +} \ No newline at end of file From 816300f402454e47309b06dcac9639283061c622 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 20 Oct 2024 18:51:47 +0200 Subject: [PATCH 009/100] added base logic for logging-disable --- commands/administration/autorole-disable.js | 4 +- commands/administration/logging-disable.js | 51 +++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/commands/administration/autorole-disable.js b/commands/administration/autorole-disable.js index d575bf9..9fe682b 100755 --- a/commands/administration/autorole-disable.js +++ b/commands/administration/autorole-disable.js @@ -40,7 +40,7 @@ module.exports = { var localEmbedResponse = embedReply( embedColors.success, "AutoRole Disable: Success", - "The autorole feature has been disabled succesfully.\nYou can re-enable it with `/autorole-configure`.", + "The autorole feature has been disabled succesfully. :white_check_mark:\nYou can re-enable it with `/autorole-configure`.", interaction ); } @@ -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. :x:\nTherefore, you can't disable it.\nYou can enable this feature with `/autorole-configure`.", interaction ); } diff --git a/commands/administration/logging-disable.js b/commands/administration/logging-disable.js index 721785b..f49611b 100644 --- a/commands/administration/logging-disable.js +++ b/commands/administration/logging-disable.js @@ -10,6 +10,57 @@ module.exports = { .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) .setDMPermission(false), async execute(interaction) { + if (!interaction.inGuild()) { + var embedReply = embedReplyFailureColor( + "Logging Disable: Error", + "You can only disable logging in a server.", + interaction + ); + } + else if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.Administartor)) { + var embedReply = 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 { + const currentGuildId = interaction.guild.id; + const query = await db.query("SELECT guildId FROM configLogging WHERE guildId = ?", [currentGuildId]); + const existingGuildId = query[0]?.guildId || null; + if (existingGuildId) { + await db.query("DELETE FROM configLogging WHERE guildId = ?", [currentGuildId]); + var embedReply = embedReplySuccessColor( + "Logging Disable: Success", + "The logging feature has been disabled successfully. :white_check_mark:\nYou can re-enable it with `/logging-configure`.", + interaction + ); + } + else { + var embedReply = embedReplyFailureColor( + "Logging Disable: Error", + "Logging has not been configured for this server. :x:\nTherefore, you can't disable it.\nYou can enable this feature with `/logging-configure`.", + interaction + ) + } + } + catch (error) { + console.error(`Error while disabling logging: ${error}`); + var embedReply = embedReplyFailureColor( + "Logging Disable: Error", + "An error occurred while disabling the logging feature.", + interaction + ); + } + } + + await interaction.reply({ embeds: [embedReply] }); + + //logging + const response = JSON.stringify(embedReply.toJSON()); + await logToFileAndDatabase(interaction, response); } } \ No newline at end of file From a6c378f536d2dec8ac2238762e1d4c922b8e49b6 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 20 Oct 2024 23:40:27 +0200 Subject: [PATCH 010/100] fixed typos --- .env.example | 2 +- commands/administration/logging-disable.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 5121a41..34b7ef3 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ TOKEN=BOT-TOKE-GOES-HERE -CLIENT_ID=-BOT-CLIENT-ID-GOES-HERE +CLIENT_ID=BOT-CLIENT-ID-GOES-HERE DATABASE_HOST_ADDRESS=AN-IP-ADDRESS-OR-DOMAIN-TO-YOUR-DATABASE DATABASE_NAME=YOUR-DATABASE-NAME diff --git a/commands/administration/logging-disable.js b/commands/administration/logging-disable.js index f49611b..0652b80 100644 --- a/commands/administration/logging-disable.js +++ b/commands/administration/logging-disable.js @@ -18,8 +18,7 @@ module.exports = { ); } else if (!interaction.guild.members.me.permissions.has(PermissionFlagsBits.Administartor)) { - var embedReply = embedReply( - embedColors.failure, + var embedReply = embedReplyFailureColor( "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 From e0c0dbc75abd15bede1c48a9a149abf92f097e81 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 20 Oct 2024 23:55:53 +0200 Subject: [PATCH 011/100] made logging to local db configureable --- config.json.example | 2 +- events/scripts/messageCreate/logging.js | 37 +++++++++++++------------ index.js | 1 - 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/config.json.example b/config.json.example index 2261bc3..50f3c0a 100644 --- a/config.json.example +++ b/config.json.example @@ -3,7 +3,7 @@ "logToFile" : "[True/False]", "logToDatabase" : "[True/False]", - + "logMessagesToLocalDatabase" : "[True/False]", "//": "Appearance settings", diff --git a/events/scripts/messageCreate/logging.js b/events/scripts/messageCreate/logging.js index 0f3edfd..06f1c27 100644 --- a/events/scripts/messageCreate/logging.js +++ b/events/scripts/messageCreate/logging.js @@ -1,25 +1,28 @@ const db = require("../../../helpers/db"); +const { logMessagesToLocalDatabase } = require("../../../config.json"); module.exports = { async logMessage(message) { - const messageContent = message.content; - const senderUserName = message.author.username; - const senderUserId = message.author.id; - const serverName = message.guild.name; - const serverId = message.guild.id; - const channelName = message.channel.name; - const channelId = message.channel.id; + if (logMessagesToLocalDatabase == "True") { + const messageContent = message.content; + const senderUserName = message.author.username; + const senderUserId = message.author.id; + const serverName = message.guild.name; + const serverId = message.guild.id; + const channelName = message.channel.name; + const channelId = message.channel.id; - try { - await db.query("INSERT INTO messageLog (messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId) VALUES (?, ?, ?, ?, ?, ?, ?)", - [ - messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId - ] - ); - console.log(`Logged message "${message.content}" from ${senderUserName} in ${serverName}.`); - } - catch (error) { - console.error(`Failed to log message: ${error}`); + try { + await db.query("INSERT INTO messageLog (messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId) VALUES (?, ?, ?, ?, ?, ?, ?)", + [ + messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId + ] + ); + console.log(`Logged message "${message.content}" from ${senderUserName} in ${serverName}.`); + } + catch (error) { + console.error(`Failed to log message: ${error}`); + } } } } \ No newline at end of file diff --git a/index.js b/index.js index dffb07b..396dfb6 100755 --- a/index.js +++ b/index.js @@ -60,7 +60,6 @@ const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith(".js" for (const file of eventFiles) { const filePath = path.join(eventsPath, file); const event = require(filePath); - console.log("Event: ", event); if (event.once) { client.once(event.name, (...args) => event.execute(...args)); From 4e7ea10e3cb161ba91114d67ac9f1df2f87f902c Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 20 Oct 2024 23:58:31 +0200 Subject: [PATCH 012/100] added events for logging (thx https://github.com/devdeem/Logger-Bot/tree/main/src/events) --- events/channelCreate.js | 0 events/channelDelete.js | 0 events/channelPinsUpdate.js | 0 events/channelUpdate.js | 0 events/emojiCreate.js | 0 events/emojiDelete.js | 0 events/emojiUpdate.js | 0 events/guildBanAdd.js | 0 events/guildBanRemove.js | 0 events/guildMemberRemove.js | 0 events/messageUpdate.js | 0 events/voiceStateUpdate.js | 0 12 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 events/channelCreate.js create mode 100644 events/channelDelete.js create mode 100644 events/channelPinsUpdate.js create mode 100644 events/channelUpdate.js create mode 100644 events/emojiCreate.js create mode 100644 events/emojiDelete.js create mode 100644 events/emojiUpdate.js create mode 100644 events/guildBanAdd.js create mode 100644 events/guildBanRemove.js create mode 100644 events/guildMemberRemove.js create mode 100644 events/messageUpdate.js create mode 100644 events/voiceStateUpdate.js diff --git a/events/channelCreate.js b/events/channelCreate.js new file mode 100644 index 0000000..e69de29 diff --git a/events/channelDelete.js b/events/channelDelete.js new file mode 100644 index 0000000..e69de29 diff --git a/events/channelPinsUpdate.js b/events/channelPinsUpdate.js new file mode 100644 index 0000000..e69de29 diff --git a/events/channelUpdate.js b/events/channelUpdate.js new file mode 100644 index 0000000..e69de29 diff --git a/events/emojiCreate.js b/events/emojiCreate.js new file mode 100644 index 0000000..e69de29 diff --git a/events/emojiDelete.js b/events/emojiDelete.js new file mode 100644 index 0000000..e69de29 diff --git a/events/emojiUpdate.js b/events/emojiUpdate.js new file mode 100644 index 0000000..e69de29 diff --git a/events/guildBanAdd.js b/events/guildBanAdd.js new file mode 100644 index 0000000..e69de29 diff --git a/events/guildBanRemove.js b/events/guildBanRemove.js new file mode 100644 index 0000000..e69de29 diff --git a/events/guildMemberRemove.js b/events/guildMemberRemove.js new file mode 100644 index 0000000..e69de29 diff --git a/events/messageUpdate.js b/events/messageUpdate.js new file mode 100644 index 0000000..e69de29 diff --git a/events/voiceStateUpdate.js b/events/voiceStateUpdate.js new file mode 100644 index 0000000..e69de29 From a1986b56609df84eb2023c7125810bb419ad8fa8 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 20 Oct 2024 23:59:37 +0200 Subject: [PATCH 013/100] replaced logging.js to common event script folder --- events/scripts/common/README.md | 1 + events/scripts/{messageCreate => common}/logging.js | 0 2 files changed, 1 insertion(+) create mode 100644 events/scripts/common/README.md rename events/scripts/{messageCreate => common}/logging.js (100%) diff --git a/events/scripts/common/README.md b/events/scripts/common/README.md new file mode 100644 index 0000000..fa193bb --- /dev/null +++ b/events/scripts/common/README.md @@ -0,0 +1 @@ +Scripts that are used by multiple events go here. \ No newline at end of file diff --git a/events/scripts/messageCreate/logging.js b/events/scripts/common/logging.js similarity index 100% rename from events/scripts/messageCreate/logging.js rename to events/scripts/common/logging.js From b93f2ee7b735bc3e9b1dac18de3187943a57dedc Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 00:01:23 +0200 Subject: [PATCH 014/100] corrected event placement --- events/messageCreate.js | 4 +-- events/scripts/common/logging.js | 28 ------------------- .../scripts/messageCreate/messageLogging.js | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 events/scripts/messageCreate/messageLogging.js diff --git a/events/messageCreate.js b/events/messageCreate.js index 561be85..dbfb04a 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -1,8 +1,8 @@ -const logging = require("./scripts/messageCreate/logging"); +const messageLogging = require("./scripts/messageCreate/messageLogging"); module.exports = { name: "messageCreate", async execute(message) { - await logging.logMessage(message); + await messageLogging.logMessage(message); }, }; \ No newline at end of file diff --git a/events/scripts/common/logging.js b/events/scripts/common/logging.js index 06f1c27..e69de29 100644 --- a/events/scripts/common/logging.js +++ b/events/scripts/common/logging.js @@ -1,28 +0,0 @@ -const db = require("../../../helpers/db"); -const { logMessagesToLocalDatabase } = require("../../../config.json"); - -module.exports = { - async logMessage(message) { - if (logMessagesToLocalDatabase == "True") { - const messageContent = message.content; - const senderUserName = message.author.username; - const senderUserId = message.author.id; - const serverName = message.guild.name; - const serverId = message.guild.id; - const channelName = message.channel.name; - const channelId = message.channel.id; - - try { - await db.query("INSERT INTO messageLog (messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId) VALUES (?, ?, ?, ?, ?, ?, ?)", - [ - messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId - ] - ); - console.log(`Logged message "${message.content}" from ${senderUserName} in ${serverName}.`); - } - catch (error) { - console.error(`Failed to log message: ${error}`); - } - } - } -} \ No newline at end of file diff --git a/events/scripts/messageCreate/messageLogging.js b/events/scripts/messageCreate/messageLogging.js new file mode 100644 index 0000000..06f1c27 --- /dev/null +++ b/events/scripts/messageCreate/messageLogging.js @@ -0,0 +1,28 @@ +const db = require("../../../helpers/db"); +const { logMessagesToLocalDatabase } = require("../../../config.json"); + +module.exports = { + async logMessage(message) { + if (logMessagesToLocalDatabase == "True") { + const messageContent = message.content; + const senderUserName = message.author.username; + const senderUserId = message.author.id; + const serverName = message.guild.name; + const serverId = message.guild.id; + const channelName = message.channel.name; + const channelId = message.channel.id; + + try { + await db.query("INSERT INTO messageLog (messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId) VALUES (?, ?, ?, ?, ?, ?, ?)", + [ + messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId + ] + ); + console.log(`Logged message "${message.content}" from ${senderUserName} in ${serverName}.`); + } + catch (error) { + console.error(`Failed to log message: ${error}`); + } + } + } +} \ No newline at end of file From c4de3208ef2a0ba86eb2611fb948f6beeddad808 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 20:46:31 +0200 Subject: [PATCH 015/100] added embed message helpers in all colors --- helpers/embed-reply.js | 87 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/helpers/embed-reply.js b/helpers/embed-reply.js index de55a95..c513c22 100644 --- a/helpers/embed-reply.js +++ b/helpers/embed-reply.js @@ -330,6 +330,86 @@ function embedMessage(color, title, description) { return embedReply; } +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @returns {embedReply} An embed reply object + */ +function embedMessagePrimaryColor(title, description) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.primary), + title: title, + description: description, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @returns {embedReply} An embed reply object + */ +function embedMessageSuccessColor(title, description) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.success), + title: title, + description: description, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @returns {embedReply} An embed reply object + */ +function embedMessageSuccessSecondaryColor(title, description) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.successSecondary), + title: title, + description: description, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @returns {embedReply} An embed reply object + */ +function embedMessageFailureColor(title, description) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.failure), + title: title, + description: description, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @returns {embedReply} An embed reply object + */ +function embedMessageWarningColor(title, description) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.warning), + title: title, + description: description, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + module.exports = { embedReply, embedReplyPrimaryColor, @@ -344,5 +424,10 @@ module.exports = { embedReplyPrimaryColorWithFields, embedReplyPrimaryColorWithFieldsAndAuthor, embedReplySaidByPrimaryColor, - embedMessage + embedMessage, + embedMessagePrimaryColor, + embedMessageSuccessColor, + embedMessageSuccessSecondaryColor, + embedMessageFailureColor, + embedMessageWarningColor } \ No newline at end of file From cee458a0295f5eac66c6eb4143dd5f2364678fd1 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 20:48:34 +0200 Subject: [PATCH 016/100] added logging on join --- .../guildMemberAdd/logEventToChannel.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 events/scripts/guildMemberAdd/logEventToChannel.js diff --git a/events/scripts/guildMemberAdd/logEventToChannel.js b/events/scripts/guildMemberAdd/logEventToChannel.js new file mode 100644 index 0000000..da158c1 --- /dev/null +++ b/events/scripts/guildMemberAdd/logEventToChannel.js @@ -0,0 +1,26 @@ +const db = require("../../../helpers/db"); +const { embedMessageSuccessColor } = require("../../../helpers/embed-reply"); + +module.exports = { + async sendLogInfo(member) { + const guildId = member.guild.id; + + try { + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const existingGuildId = query[0]?.guildId; + const logChannelId = query[0]?.logChannelId; + + if (existingGuildId) { + const logEmbed = embedMessageSuccessColor( + "Member joined", + `${member.user.tag} joined the server.`, + ); + + await logChannelId.send({ embeds: [logEmbed] }); + } + } + catch (error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file From f470c414fc8defef87b6cd30c70695c297589655 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 20:50:47 +0200 Subject: [PATCH 017/100] fixed table creation sql script --- sql/commandUsageLog/table.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/commandUsageLog/table.sql b/sql/commandUsageLog/table.sql index 95b9226..deb23e0 100644 --- a/sql/commandUsageLog/table.sql +++ b/sql/commandUsageLog/table.sql @@ -1,6 +1,6 @@ -- discordbotTest.commandUsageLog definition -CREATE TABLE `commandUsageLog` ( +CREATE TABLE IF NOT EXISTS `commandUsageLog` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `commandName` tinytext DEFAULT NULL, `executorUserName` text DEFAULT NULL, From 0c27b6dd7947d6e1b7f64e5370f992cfe425cf6a Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 20:50:55 +0200 Subject: [PATCH 018/100] renamed function --- events/scripts/messageCreate/messageLogging.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events/scripts/messageCreate/messageLogging.js b/events/scripts/messageCreate/messageLogging.js index 06f1c27..830dede 100644 --- a/events/scripts/messageCreate/messageLogging.js +++ b/events/scripts/messageCreate/messageLogging.js @@ -2,7 +2,7 @@ const db = require("../../../helpers/db"); const { logMessagesToLocalDatabase } = require("../../../config.json"); module.exports = { - async logMessage(message) { + async logMessagesToLocalDatabase(message) { if (logMessagesToLocalDatabase == "True") { const messageContent = message.content; const senderUserName = message.author.username; From d3457330daab8271b79e171803d2c4e8c2d98af2 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 21:13:51 +0200 Subject: [PATCH 019/100] added channel creation logging, fixed typos in variable and function names, removed common script folder --- commands/administration/logging-configure.js | 2 +- events/channelCreate.js | 8 ++++++ events/messageCreate.js | 2 +- .../channelCreate/logEventToChannel.js | 28 +++++++++++++++++++ events/scripts/common/README.md | 1 - events/scripts/common/logging.js | 0 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 events/scripts/channelCreate/logEventToChannel.js delete mode 100644 events/scripts/common/README.md delete mode 100644 events/scripts/common/logging.js diff --git a/commands/administration/logging-configure.js b/commands/administration/logging-configure.js index 1ead1ef..6c6e1c1 100644 --- a/commands/administration/logging-configure.js +++ b/commands/administration/logging-configure.js @@ -93,7 +93,7 @@ module.exports = { await interaction.reply({ embeds: [embedReply] }); //logging - const response = JSON.stringify(localEmbedResponse.toJSON()); + const response = JSON.stringify(embedReply.toJSON()); await logToFileAndDatabase(interaction, response); } } \ No newline at end of file diff --git a/events/channelCreate.js b/events/channelCreate.js index e69de29..f8b8960 100644 --- a/events/channelCreate.js +++ b/events/channelCreate.js @@ -0,0 +1,8 @@ +const logEventToChannel = require("./scripts/channelCreate/logEventToChannel"); + +module.exports = { + name: "channelCreate", + async execute(channel) { + await logEventToChannel.sendLogInfo(channel); + }, +}; \ No newline at end of file diff --git a/events/messageCreate.js b/events/messageCreate.js index dbfb04a..2c39c44 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -3,6 +3,6 @@ const messageLogging = require("./scripts/messageCreate/messageLogging"); module.exports = { name: "messageCreate", async execute(message) { - await messageLogging.logMessage(message); + await messageLogging.logMessagesToLocalDatabase(message); }, }; \ No newline at end of file diff --git a/events/scripts/channelCreate/logEventToChannel.js b/events/scripts/channelCreate/logEventToChannel.js new file mode 100644 index 0000000..690fe68 --- /dev/null +++ b/events/scripts/channelCreate/logEventToChannel.js @@ -0,0 +1,28 @@ +const db = require("../../../helpers/db"); +const { embedMessageSuccessColor } = require("../../../helpers/embed-reply"); + +module.exports = { + async sendLogInfo(channel) { + const guildId = channel.guild.id; + + try { + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const existingGuildId = query[0]?.guildId; + + if (existingGuildId) { + const logChannelId = query[0]?.logChannelId; + const channel = channel.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessageSuccessColor( + "Channel created", + `${channel.name} channel was created.`, + ); + + await logChannelId.send({ embeds: [logEmbed] }); + } + } + catch (error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file diff --git a/events/scripts/common/README.md b/events/scripts/common/README.md deleted file mode 100644 index fa193bb..0000000 --- a/events/scripts/common/README.md +++ /dev/null @@ -1 +0,0 @@ -Scripts that are used by multiple events go here. \ No newline at end of file diff --git a/events/scripts/common/logging.js b/events/scripts/common/logging.js deleted file mode 100644 index e69de29..0000000 From bff8a61d412d6bf68cc9db3f9e02fc9a830ee776 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 21:19:19 +0200 Subject: [PATCH 020/100] added more permission requirements to the bot in index.js, fixed channel creation logging --- events/scripts/channelCreate/logEventToChannel.js | 4 ++-- index.js | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/events/scripts/channelCreate/logEventToChannel.js b/events/scripts/channelCreate/logEventToChannel.js index 690fe68..3e39897 100644 --- a/events/scripts/channelCreate/logEventToChannel.js +++ b/events/scripts/channelCreate/logEventToChannel.js @@ -11,14 +11,14 @@ module.exports = { if (existingGuildId) { const logChannelId = query[0]?.logChannelId; - const channel = channel.guild.channels.cache.get(logChannelId); + const logChannel = channel.guild.channels.cache.get(logChannelId); const logEmbed = embedMessageSuccessColor( "Channel created", `${channel.name} channel was created.`, ); - await logChannelId.send({ embeds: [logEmbed] }); + await logChannel.send({ embeds: [logEmbed] }); } } catch (error) { diff --git a/index.js b/index.js index 396dfb6..6e92f72 100755 --- a/index.js +++ b/index.js @@ -12,14 +12,17 @@ db.getConnection(); require("./scripts/verify-config-syntax"); // validateConfig(); -const { Client, Collection, Events, GatewayIntentBits, ActivityType } = require("discord.js"); +const { Client, Collection, Events, GatewayIntentBits, Partials, ActivityType } = require("discord.js"); -const client = new Client({ intents: - [ +const client = new Client({ + intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, + ], + partials: [ + Partials.Channel, ] }); From 4af9db24f3b14479c34dd21b18527a26a3584881 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 21:52:14 +0200 Subject: [PATCH 021/100] seperated the embed helper functions and refactored the references to them --- commands/administration/autorole-configure.js | 2 +- commands/administration/autorole-disable.js | 2 +- commands/administration/logging-configure.js | 2 +- commands/administration/logging-disable.js | 2 +- commands/administration/rename.js | 2 +- commands/administration/welcome-configure.js | 2 +- commands/administration/welcome-disable.js | 2 +- commands/economy/balance.js | 2 +- commands/economy/beg.js | 2 +- commands/economy/deposit.js | 2 +- commands/economy/leaderboard.js | 2 +- commands/economy/pay.js | 2 +- commands/economy/rob.js | 2 +- commands/economy/roulette.js | 2 +- commands/economy/withdraw.js | 2 +- commands/economy/work.js | 2 +- commands/fun/911-countdown.js | 2 +- commands/fun/coinflip.js | 2 +- commands/fun/randomfeet.js | 2 +- commands/fun/randompic.js | 2 +- commands/moderation/ban.js | 3 +- commands/moderation/kick.js | 3 +- commands/moderation/purge.js | 2 +- commands/moderation/timeout.js | 3 +- commands/moderation/warn.js | 2 +- commands/utility/help.js | 2 +- commands/utility/ping-db.js | 2 +- commands/utility/ping.js | 2 +- commands/utility/say.js | 2 +- commands/utility/server.js | 2 +- commands/utility/translate.js | 2 +- commands/utility/user.js | 2 +- .../channelCreate/logEventToChannel.js | 2 +- .../guildMemberAdd/logEventToChannel.js | 2 +- events/scripts/guildMemberAdd/welcome.js | 2 +- helpers/embeds/embed-message.js | 105 ++++++++++++ helpers/embeds/embed-reply-moderation.js | 46 ++++++ helpers/{ => embeds}/embed-reply.js | 150 +----------------- 38 files changed, 191 insertions(+), 183 deletions(-) create mode 100644 helpers/embeds/embed-message.js create mode 100644 helpers/embeds/embed-reply-moderation.js rename helpers/{ => embeds}/embed-reply.js (68%) diff --git a/commands/administration/autorole-configure.js b/commands/administration/autorole-configure.js index e723b4f..c23107e 100755 --- a/commands/administration/autorole-configure.js +++ b/commands/administration/autorole-configure.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { embedReply } = require("../../helpers/embed-reply"); +const { embedReply } = require("../../helpers/embeds/embed-reply"); const { embedColors } = require("../../config.json"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/administration/autorole-disable.js b/commands/administration/autorole-disable.js index 9fe682b..833d49b 100755 --- a/commands/administration/autorole-disable.js +++ b/commands/administration/autorole-disable.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { embedReply } = require("../../helpers/embed-reply"); +const { embedReply } = require("../../helpers/embeds/embed-reply"); const { embedColors } = require("../../config.json"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/administration/logging-configure.js b/commands/administration/logging-configure.js index 6c6e1c1..7366931 100644 --- a/commands/administration/logging-configure.js +++ b/commands/administration/logging-configure.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { embedReplySuccessColor, embedReplySuccessSecondaryColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplySuccessColor, embedReplySuccessSecondaryColor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/administration/logging-disable.js b/commands/administration/logging-disable.js index 0652b80..63b8c41 100644 --- a/commands/administration/logging-disable.js +++ b/commands/administration/logging-disable.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/administration/rename.js b/commands/administration/rename.js index 79edeb8..ff89272 100644 --- a/commands/administration/rename.js +++ b/commands/administration/rename.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { embedReplyFailureColor, embedReplySuccessColor, embedReplyWarningColor, moderationDmEmbedReplyWarningColor } = require("../../helpers/embed-reply"); +const { embedReplyFailureColor, embedReplySuccessColor, embedReplyWarningColor, moderationDmEmbedReplyWarningColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/administration/welcome-configure.js b/commands/administration/welcome-configure.js index 6d07f2e..cdab2cd 100644 --- a/commands/administration/welcome-configure.js +++ b/commands/administration/welcome-configure.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { embedReplySuccessColor, embedReplySuccessSecondaryColor, embedReplyWarningColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplySuccessColor, embedReplySuccessSecondaryColor, embedReplyWarningColor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/administration/welcome-disable.js b/commands/administration/welcome-disable.js index 84514d2..923b46a 100644 --- a/commands/administration/welcome-disable.js +++ b/commands/administration/welcome-disable.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { embedReplyPrimaryColor, embedReplyFailureColor, embedReplyWarningColor, embedReplySuccessColor } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColor, embedReplyFailureColor, embedReplyWarningColor, embedReplySuccessColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/economy/balance.js b/commands/economy/balance.js index 15e1021..c1c002a 100644 --- a/commands/economy/balance.js +++ b/commands/economy/balance.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplyPrimaryColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); const db = require("../../helpers/db"); const { logToFileAndDatabase } = require("../../helpers/logger"); diff --git a/commands/economy/beg.js b/commands/economy/beg.js index 3495dd3..64e376a 100644 --- a/commands/economy/beg.js +++ b/commands/economy/beg.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplySuccessColor, embedReplyWarningColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplySuccessColor, embedReplyWarningColor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/economy/deposit.js b/commands/economy/deposit.js index 6deb157..73e8322 100644 --- a/commands/economy/deposit.js +++ b/commands/economy/deposit.js @@ -1,5 +1,5 @@ const { ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder } = require("discord.js"); -const { embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embed-reply"); +const { embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/economy/leaderboard.js b/commands/economy/leaderboard.js index 055aaf5..9af4739 100644 --- a/commands/economy/leaderboard.js +++ b/commands/economy/leaderboard.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplyPrimaryColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); const db = require("../../helpers/db"); const { logToFileAndDatabase } = require("../../helpers/logger"); diff --git a/commands/economy/pay.js b/commands/economy/pay.js index c6b3f59..0130aac 100644 --- a/commands/economy/pay.js +++ b/commands/economy/pay.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embed-reply"); +const { embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embeds/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 207510a..06c7994 100644 --- a/commands/economy/rob.js +++ b/commands/economy/rob.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embed-reply"); +const { embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/economy/roulette.js b/commands/economy/roulette.js index 57b0615..1105c05 100644 --- a/commands/economy/roulette.js +++ b/commands/economy/roulette.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplySuccessColor, embedReplyFailureColor, embedReplyWarningColor } = require("../../helpers/embed-reply"); +const { embedReplySuccessColor, embedReplyFailureColor, embedReplyWarningColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const format = require("../../helpers/format"); const generate = require("../../helpers/generate"); diff --git a/commands/economy/withdraw.js b/commands/economy/withdraw.js index b67f5e9..85f6d21 100644 --- a/commands/economy/withdraw.js +++ b/commands/economy/withdraw.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/economy/work.js b/commands/economy/work.js index c605e7b..c8bbb5c 100644 --- a/commands/economy/work.js +++ b/commands/economy/work.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); diff --git a/commands/fun/911-countdown.js b/commands/fun/911-countdown.js index 8abebcd..3890ec2 100644 --- a/commands/fun/911-countdown.js +++ b/commands/fun/911-countdown.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplyPrimaryColorWithFields } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColorWithFields } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/fun/coinflip.js b/commands/fun/coinflip.js index 6b7e060..9e42468 100755 --- a/commands/fun/coinflip.js +++ b/commands/fun/coinflip.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require('discord.js'); -const { embedReplyPrimaryColor } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/fun/randomfeet.js b/commands/fun/randomfeet.js index ad9b7fd..d6f3a35 100755 --- a/commands/fun/randomfeet.js +++ b/commands/fun/randomfeet.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplyPrimaryColorImg, embedReplyImg } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColorImg, embedReplyImg } = require("../../helpers/embeds/embed-reply"); const fs = require("fs"); const path = require("path"); const linksFile = "./data/links.json"; diff --git a/commands/fun/randompic.js b/commands/fun/randompic.js index d17d7d1..e8ac9b7 100755 --- a/commands/fun/randompic.js +++ b/commands/fun/randompic.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require('discord.js'); -const { embedReplyPrimaryColorImg } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColorImg } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index f3cf7ad..39dceaf 100755 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -1,5 +1,6 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); -const { embedReplyFailureColor, moderationDmEmbedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embed-reply"); +const { embedReplyFailureColor, embedReplySuccessColor } = require("../../helpers/embeds/embed-reply"); +const { moderationDmEmbedReplyFailureColor } = require("../../helpers/embeds/embed-reply-moderation"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 47d73b8..a13d033 100755 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -1,5 +1,6 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); -const { embedReplySuccessColor, embedReplyFailureColor, moderationDmEmbedReplyFailureColor } = require('../../helpers/embed-reply'); +const { embedReplySuccessColor, embedReplyFailureColor } = require('../../helpers/embeds/embed-reply'); +const { moderationDmEmbedReplyFailureColor } = require('../../helpers/embeds/embed-reply-moderation'); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/moderation/purge.js b/commands/moderation/purge.js index d1068a1..0e8b73b 100755 --- a/commands/moderation/purge.js +++ b/commands/moderation/purge.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits, ButtonBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js'); -const { embedReplySuccessColor, embedReplyFailureColor } = require('../../helpers/embed-reply'); +const { embedReplySuccessColor, embedReplyFailureColor } = require('../../helpers/embeds/embed-reply'); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/moderation/timeout.js b/commands/moderation/timeout.js index 0a56696..76ffdf9 100755 --- a/commands/moderation/timeout.js +++ b/commands/moderation/timeout.js @@ -1,5 +1,6 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); -const { embedReplySuccessColor, embedReplyFailureColor, moderationDmEmbedReplyFailureColor } = require('../../helpers/embed-reply'); +const { embedReplySuccessColor, embedReplyFailureColor } = require('../../helpers/embeds/embed-reply'); +const { moderationDmEmbedReplyFailureColor } = require('../../helpers/embeds/embed-reply-moderation'); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index ac55adb..ac3dce0 100755 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js'); -const { embedReplySuccessColor, embedReplyFailureColor, moderationDmEmbedReplyWarningColor } = require('../../helpers/embed-reply'); +const { embedReplySuccessColor, embedReplyFailureColor, moderationDmEmbedReplyWarningColor } = require('../../helpers/embeds/embed-reply'); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/utility/help.js b/commands/utility/help.js index ba622f1..188f560 100755 --- a/commands/utility/help.js +++ b/commands/utility/help.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplyPrimaryColorWithFields, embedReplyErrorColorWithFields } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColorWithFields, embedReplyErrorColorWithFields } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/utility/ping-db.js b/commands/utility/ping-db.js index de42455..b14aa24 100644 --- a/commands/utility/ping-db.js +++ b/commands/utility/ping-db.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplyPrimaryColorWithFields, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColorWithFields, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); const db = require("../../helpers/db"); const { logToFileAndDatabase } = require("../../helpers/logger"); diff --git a/commands/utility/ping.js b/commands/utility/ping.js index e27c284..d81eb28 100755 --- a/commands/utility/ping.js +++ b/commands/utility/ping.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require('discord.js'); -const { embedReplyPrimaryColorWithFields } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColorWithFields } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/utility/say.js b/commands/utility/say.js index 57b5e01..9aeb108 100644 --- a/commands/utility/say.js +++ b/commands/utility/say.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplySaidByPrimaryColor } = require("../../helpers/embed-reply"); +const { embedReplySaidByPrimaryColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/utility/server.js b/commands/utility/server.js index a956118..c8856fe 100755 --- a/commands/utility/server.js +++ b/commands/utility/server.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require('discord.js'); -const { embedReplyPrimaryColorWithFieldsAndAuthor, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColorWithFieldsAndAuthor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/commands/utility/translate.js b/commands/utility/translate.js index 9f7ea91..146651d 100644 --- a/commands/utility/translate.js +++ b/commands/utility/translate.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require("discord.js"); -const { embedReplyPrimaryColorWithFields, embedReplyFailureColor } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColorWithFields, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const translate = require('google-translate-api-x'); const fs = require('fs'); diff --git a/commands/utility/user.js b/commands/utility/user.js index 4911c06..0b13ca5 100755 --- a/commands/utility/user.js +++ b/commands/utility/user.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder } = require('discord.js'); -const { embedReplyPrimaryColorWithFields } = require("../../helpers/embed-reply"); +const { embedReplyPrimaryColorWithFields } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); module.exports = { diff --git a/events/scripts/channelCreate/logEventToChannel.js b/events/scripts/channelCreate/logEventToChannel.js index 3e39897..fb8b57c 100644 --- a/events/scripts/channelCreate/logEventToChannel.js +++ b/events/scripts/channelCreate/logEventToChannel.js @@ -1,5 +1,5 @@ const db = require("../../../helpers/db"); -const { embedMessageSuccessColor } = require("../../../helpers/embed-reply"); +const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(channel) { diff --git a/events/scripts/guildMemberAdd/logEventToChannel.js b/events/scripts/guildMemberAdd/logEventToChannel.js index da158c1..cb400c2 100644 --- a/events/scripts/guildMemberAdd/logEventToChannel.js +++ b/events/scripts/guildMemberAdd/logEventToChannel.js @@ -1,5 +1,5 @@ const db = require("../../../helpers/db"); -const { embedMessageSuccessColor } = require("../../../helpers/embed-reply"); +const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(member) { diff --git a/events/scripts/guildMemberAdd/welcome.js b/events/scripts/guildMemberAdd/welcome.js index c578287..ace5d86 100644 --- a/events/scripts/guildMemberAdd/welcome.js +++ b/events/scripts/guildMemberAdd/welcome.js @@ -1,6 +1,6 @@ const db = require("../../../helpers/db"); const { embedColors } = require("../../../config.json"); -const { embedMessage } = require("../../../helpers/embed-reply"); +const { embedMessage } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendWelcomeMessage(member) { diff --git a/helpers/embeds/embed-message.js b/helpers/embeds/embed-message.js new file mode 100644 index 0000000..413dd99 --- /dev/null +++ b/helpers/embeds/embed-message.js @@ -0,0 +1,105 @@ +/** + * @param {color} color - Embed's sidebar HEX Color + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @returns {embedReply} An embed reply object + */ +function embedMessage(color, title, description) { + const embedReply = new EmbedBuilder({ + color: parseInt(color), + title: title, + description: description, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @returns {embedReply} An embed reply object + */ +function embedMessagePrimaryColor(title, description) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.primary), + title: title, + description: description, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @returns {embedReply} An embed reply object + */ +function embedMessageSuccessColor(title, description) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.success), + title: title, + description: description, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @returns {embedReply} An embed reply object + */ +function embedMessageSuccessSecondaryColor(title, description) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.successSecondary), + title: title, + description: description, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @returns {embedReply} An embed reply object + */ +function embedMessageFailureColor(title, description) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.failure), + title: title, + description: description, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @returns {embedReply} An embed reply object + */ +function embedMessageWarningColor(title, description) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.warning), + title: title, + description: description, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +odule.exports = { + embedMessage, + embedMessagePrimaryColor, + embedMessageSuccessColor, + embedMessageSuccessSecondaryColor, + embedMessageFailureColor, + embedMessageWarningColor +} \ No newline at end of file diff --git a/helpers/embeds/embed-reply-moderation.js b/helpers/embeds/embed-reply-moderation.js new file mode 100644 index 0000000..997de97 --- /dev/null +++ b/helpers/embeds/embed-reply-moderation.js @@ -0,0 +1,46 @@ +/** + * @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), + title: title, + description: description, + timestamp: new Date().toISOString(), + footer: { + text: `Moderator: ${interaction.user.username}` , + icon_url: interaction.user.displayAvatarURL({ dynamic: true }), + }, + }); + + 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; +} + +module.exports = { + moderationDmEmbedReplyFailureColor, + moderationDmEmbedReplyWarningColor, +} \ No newline at end of file diff --git a/helpers/embed-reply.js b/helpers/embeds/embed-reply.js similarity index 68% rename from helpers/embed-reply.js rename to helpers/embeds/embed-reply.js index c513c22..9b4c68c 100644 --- a/helpers/embed-reply.js +++ b/helpers/embeds/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 @@ -128,48 +128,6 @@ 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), - title: title, - description: description, - timestamp: new Date().toISOString(), - footer: { - text: `Moderator: ${interaction.user.username}` , - icon_url: interaction.user.displayAvatarURL({ dynamic: true }), - }, - }); - - 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 @@ -313,103 +271,6 @@ function embedReplySaidByPrimaryColor(title, description, interaction) { return embedReply; } -/** - * @param {color} color - Embed's sidebar HEX Color - * @param {title} title - Embed's title - * @param {description} description - Embed's description - * @returns {embedReply} An embed reply object - */ -function embedMessage(color, title, description) { - const embedReply = new EmbedBuilder({ - color: parseInt(color), - title: title, - description: description, - timestamp: new Date().toISOString() - }); - - return embedReply; -} - -/** - * @param {title} title - Embed's title - * @param {description} description - Embed's description - * @returns {embedReply} An embed reply object - */ -function embedMessagePrimaryColor(title, description) { - const embedReply = new EmbedBuilder({ - color: parseInt(embedColors.primary), - title: title, - description: description, - timestamp: new Date().toISOString() - }); - - return embedReply; -} - -/** - * @param {title} title - Embed's title - * @param {description} description - Embed's description - * @returns {embedReply} An embed reply object - */ -function embedMessageSuccessColor(title, description) { - const embedReply = new EmbedBuilder({ - color: parseInt(embedColors.success), - title: title, - description: description, - timestamp: new Date().toISOString() - }); - - return embedReply; -} - -/** - * @param {title} title - Embed's title - * @param {description} description - Embed's description - * @returns {embedReply} An embed reply object - */ -function embedMessageSuccessSecondaryColor(title, description) { - const embedReply = new EmbedBuilder({ - color: parseInt(embedColors.successSecondary), - title: title, - description: description, - timestamp: new Date().toISOString() - }); - - return embedReply; -} - -/** - * @param {title} title - Embed's title - * @param {description} description - Embed's description - * @returns {embedReply} An embed reply object - */ -function embedMessageFailureColor(title, description) { - const embedReply = new EmbedBuilder({ - color: parseInt(embedColors.failure), - title: title, - description: description, - timestamp: new Date().toISOString() - }); - - return embedReply; -} - -/** - * @param {title} title - Embed's title - * @param {description} description - Embed's description - * @returns {embedReply} An embed reply object - */ -function embedMessageWarningColor(title, description) { - const embedReply = new EmbedBuilder({ - color: parseInt(embedColors.warning), - title: title, - description: description, - timestamp: new Date().toISOString() - }); - - return embedReply; -} - module.exports = { embedReply, embedReplyPrimaryColor, @@ -417,17 +278,10 @@ module.exports = { embedReplySuccessSecondaryColor, embedReplyFailureColor, embedReplyWarningColor, - moderationDmEmbedReplyFailureColor, - moderationDmEmbedReplyWarningColor, embedReplyImg, embedReplyPrimaryColorImg, embedReplyPrimaryColorWithFields, + embedReplyErrorColorWithFields, embedReplyPrimaryColorWithFieldsAndAuthor, embedReplySaidByPrimaryColor, - embedMessage, - embedMessagePrimaryColor, - embedMessageSuccessColor, - embedMessageSuccessSecondaryColor, - embedMessageFailureColor, - embedMessageWarningColor } \ No newline at end of file From b04f7f84bef449559b1e9b0d0b056a428cb34cd4 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 22:54:59 +0200 Subject: [PATCH 022/100] updated logging table --- helpers/logger.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpers/logger.js b/helpers/logger.js index ee65fcb..f330a77 100755 --- a/helpers/logger.js +++ b/helpers/logger.js @@ -48,9 +48,9 @@ Response: ${response}\n\n`; channelId = null; } - //insert data into the log table + //insert data into the commandUsageLog table await db.query( - `INSERT INTO log (commandName, executorUserName, executorUserId, isInServer, serverName, serverId, channelName, channelId, time, response) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, + `INSERT INTO commandUsageLog (commandName, executorUserName, executorUserId, isInServer, serverName, serverId, channelName, channelId, time, response) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [ interaction.commandName, interaction.user.username, From aa0345c33f546c2d73b9bff9084a82035d1ef18f Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 23:11:13 +0200 Subject: [PATCH 023/100] fixed embed replies --- helpers/embeds/embed-message.js | 17 ++++++++++------- helpers/embeds/embed-reply-moderation.js | 3 +++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/helpers/embeds/embed-message.js b/helpers/embeds/embed-message.js index 413dd99..d71fd43 100644 --- a/helpers/embeds/embed-message.js +++ b/helpers/embeds/embed-message.js @@ -1,8 +1,11 @@ +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 - * @returns {embedReply} An embed reply object + * @returns {embedReply} An embed message object */ function embedMessage(color, title, description) { const embedReply = new EmbedBuilder({ @@ -18,7 +21,7 @@ function embedMessage(color, title, description) { /** * @param {title} title - Embed's title * @param {description} description - Embed's description - * @returns {embedReply} An embed reply object + * @returns {embedReply} An embed message object */ function embedMessagePrimaryColor(title, description) { const embedReply = new EmbedBuilder({ @@ -34,7 +37,7 @@ function embedMessagePrimaryColor(title, description) { /** * @param {title} title - Embed's title * @param {description} description - Embed's description - * @returns {embedReply} An embed reply object + * @returns {embedReply} An embed message object */ function embedMessageSuccessColor(title, description) { const embedReply = new EmbedBuilder({ @@ -50,7 +53,7 @@ function embedMessageSuccessColor(title, description) { /** * @param {title} title - Embed's title * @param {description} description - Embed's description - * @returns {embedReply} An embed reply object + * @returns {embedReply} An embed message object */ function embedMessageSuccessSecondaryColor(title, description) { const embedReply = new EmbedBuilder({ @@ -66,7 +69,7 @@ function embedMessageSuccessSecondaryColor(title, description) { /** * @param {title} title - Embed's title * @param {description} description - Embed's description - * @returns {embedReply} An embed reply object + * @returns {embedReply} An embed message object */ function embedMessageFailureColor(title, description) { const embedReply = new EmbedBuilder({ @@ -82,7 +85,7 @@ function embedMessageFailureColor(title, description) { /** * @param {title} title - Embed's title * @param {description} description - Embed's description - * @returns {embedReply} An embed reply object + * @returns {embedReply} An embed message object */ function embedMessageWarningColor(title, description) { const embedReply = new EmbedBuilder({ @@ -95,7 +98,7 @@ function embedMessageWarningColor(title, description) { return embedReply; } -odule.exports = { +module.exports = { embedMessage, embedMessagePrimaryColor, embedMessageSuccessColor, diff --git a/helpers/embeds/embed-reply-moderation.js b/helpers/embeds/embed-reply-moderation.js index 997de97..498258e 100644 --- a/helpers/embeds/embed-reply-moderation.js +++ b/helpers/embeds/embed-reply-moderation.js @@ -1,3 +1,6 @@ +const { EmbedBuilder } = require("discord.js"); +const { embedColors } = require("../../config.json"); + /** * @param {title} title - Embed's title * @param {description} description - Embed's description From 5104d7391a036bbdc91f34ef7687e8bd94d49b9a Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 23:11:52 +0200 Subject: [PATCH 024/100] added channel delete event logging --- events/channelDelete.js | 8 ++++++ .../channelDelete/logEventToChannel.js | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 events/scripts/channelDelete/logEventToChannel.js diff --git a/events/channelDelete.js b/events/channelDelete.js index e69de29..c59b483 100644 --- a/events/channelDelete.js +++ b/events/channelDelete.js @@ -0,0 +1,8 @@ +const logEventToChannel = require("./scripts/channelDelete/logEventToChannel"); + +module.exports = { + name: "channelDelete", + async execute(channel) { + await logEventToChannel.sendLogInfo(channel); + }, +}; \ No newline at end of file diff --git a/events/scripts/channelDelete/logEventToChannel.js b/events/scripts/channelDelete/logEventToChannel.js new file mode 100644 index 0000000..4e81580 --- /dev/null +++ b/events/scripts/channelDelete/logEventToChannel.js @@ -0,0 +1,28 @@ +const db = require("../../../helpers/db"); +const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async sendLogInfo(channel) { + const guildId = channel.guild.id; + + try { + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const existingGuildId = query[0]?.guildId; + + if (existingGuildId) { + const logChannelId = query[0]?.logChannelId; + const logChannel = channel.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessageFailureColor( + "Channel deleted", + `${channel.name} channel was deleted.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + catch (error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file From 0952041adf720a5f9b2409120721fe3c75c77601 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 23:33:41 +0200 Subject: [PATCH 025/100] fixed column name, added emojiCreate event, added more intents to index.js (might remove later) --- events/emojiCreate.js | 8 ++++++ .../scripts/emojiCreate/logEventToChannel.js | 28 +++++++++++++++++++ helpers/logger.js | 2 +- index.js | 18 ++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 events/scripts/emojiCreate/logEventToChannel.js diff --git a/events/emojiCreate.js b/events/emojiCreate.js index e69de29..da6a35b 100644 --- a/events/emojiCreate.js +++ b/events/emojiCreate.js @@ -0,0 +1,8 @@ +const logEventToChannel = require("./scripts/emojiCreate/logEventToChannel"); + +module.exports = { + name: "emojiCreate", + async execute(emoji) { + await logEventToChannel.sendLogInfo(emoji); + }, +}; \ No newline at end of file diff --git a/events/scripts/emojiCreate/logEventToChannel.js b/events/scripts/emojiCreate/logEventToChannel.js new file mode 100644 index 0000000..1af9733 --- /dev/null +++ b/events/scripts/emojiCreate/logEventToChannel.js @@ -0,0 +1,28 @@ +const db = require("../../../helpers/db"); +const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async sendLogInfo(emoji) { + const guildId = emoji.guild.id; + + try { + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const existingGuildId = query[0]?.guildId; + + if (existingGuildId) { + const logChannelId = query[0]?.logChannelId; + const logChannel = channel.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessageSuccessColor( + "Emoji created", + `${emoji.name} emoji was created.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + catch (error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file diff --git a/helpers/logger.js b/helpers/logger.js index f330a77..5538688 100755 --- a/helpers/logger.js +++ b/helpers/logger.js @@ -50,7 +50,7 @@ Response: ${response}\n\n`; //insert data into the commandUsageLog table await db.query( - `INSERT INTO commandUsageLog (commandName, executorUserName, executorUserId, isInServer, serverName, serverId, channelName, channelId, time, response) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, + `INSERT INTO commandUsageLog (commandName, executorUserName, executorUserId, isInServer, serverName, serverId, channelName, channelId, usageTime, response) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [ interaction.commandName, interaction.user.username, diff --git a/index.js b/index.js index 6e92f72..0b74526 100755 --- a/index.js +++ b/index.js @@ -17,12 +17,30 @@ const { Client, Collection, Events, GatewayIntentBits, Partials, ActivityType } const client = new Client({ intents: [ GatewayIntentBits.Guilds, + GatewayIntentBits.GuildEmojisAndStickers, + // GatewayIntentBits.GuildIntegrations, + GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildMessageReactions, + // GatewayIntentBits.GuildMessageTyping, GatewayIntentBits.GuildMessages, + // GatewayIntentBits.GuildPresences, + // GatewayIntentBits.GuildScheduledEvents, + GatewayIntentBits.GuildVoiceStates, + GatewayIntentBits.GuildWebhooks, + // GatewayIntentBits.DirectMessages, + // GatewayIntentBits.DirectMessageTyping, + // GatewayIntentBits.DirectMessageReactions, GatewayIntentBits.MessageContent, ], partials: [ Partials.Channel, + // Partials.GuildMember, + // Partials.GuildScheduledEvent, + // Partials.Message, + // Partials.Reaction, + // Partials.ThreadMember, + // Partials.User, ] }); From eeead30d0926f441a31af8c9466d2b43b268aa75 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 21 Oct 2024 23:35:36 +0200 Subject: [PATCH 026/100] fixed emojiCreate --- events/scripts/emojiCreate/logEventToChannel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/events/scripts/emojiCreate/logEventToChannel.js b/events/scripts/emojiCreate/logEventToChannel.js index 1af9733..ee26653 100644 --- a/events/scripts/emojiCreate/logEventToChannel.js +++ b/events/scripts/emojiCreate/logEventToChannel.js @@ -11,7 +11,7 @@ module.exports = { if (existingGuildId) { const logChannelId = query[0]?.logChannelId; - const logChannel = channel.guild.channels.cache.get(logChannelId); + const logChannel = emoji.guild.channels.cache.get(logChannelId); const logEmbed = embedMessageSuccessColor( "Emoji created", From 45f78686c18edf4604c40984d0907d161415d70a Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 23 Oct 2024 17:59:07 +0200 Subject: [PATCH 027/100] added channel pin update event logging --- events/channelPinsUpdate.js | 8 ++++++ .../channelPinsUpdate/logEventToChannel.js | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 events/scripts/channelPinsUpdate/logEventToChannel.js diff --git a/events/channelPinsUpdate.js b/events/channelPinsUpdate.js index e69de29..602f10f 100644 --- a/events/channelPinsUpdate.js +++ b/events/channelPinsUpdate.js @@ -0,0 +1,8 @@ +const logEventToChannel = require("./scripts/channelPinsUpdate/logEventToChannel"); + +module.exports = { + name: "channelPinsUpdate", + async execute(channel) { + await logEventToChannel.sendLogInfo(channel); + }, +} \ No newline at end of file diff --git a/events/scripts/channelPinsUpdate/logEventToChannel.js b/events/scripts/channelPinsUpdate/logEventToChannel.js new file mode 100644 index 0000000..131850d --- /dev/null +++ b/events/scripts/channelPinsUpdate/logEventToChannel.js @@ -0,0 +1,28 @@ +const db = require("../../../helpers/db"); +const { embedMessagePrimaryColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async sendLogInfo(channel) { + const guildId = channel.guild.id; + + try { + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const existingGuildId = query[0]?.guildId; + + if (existingGuildId) { + const logChannelId = query[0]?.logChannelId; + const logChannel = channel.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessagePrimaryColor( + "Channel pins updated", + `${channel.name} channel pins were updated.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + catch (error) { + console.error(`Failed to send message pin log info to target channel: ${error}`); + } + } +} \ No newline at end of file From 94c34f1e4212cff0a2026d339584812824f1128a Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 24 Oct 2024 00:38:01 +0200 Subject: [PATCH 028/100] added emojiDelete event logging --- events/emojiDelete.js | 8 ++++++ .../scripts/emojiDelete/logEventToChannel.js | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 events/scripts/emojiDelete/logEventToChannel.js diff --git a/events/emojiDelete.js b/events/emojiDelete.js index e69de29..843bfcb 100644 --- a/events/emojiDelete.js +++ b/events/emojiDelete.js @@ -0,0 +1,8 @@ +const logEventToChannel = require("./scripts/emojiDelete/logEventToChannel"); + +module.exports = { + name: "emojiDelete", + async execute(emoji) { + await logEventToChannel.sendLogInfo(emoji); + }, +} \ No newline at end of file diff --git a/events/scripts/emojiDelete/logEventToChannel.js b/events/scripts/emojiDelete/logEventToChannel.js new file mode 100644 index 0000000..e83eabb --- /dev/null +++ b/events/scripts/emojiDelete/logEventToChannel.js @@ -0,0 +1,28 @@ +const db = require("../../../helpers/db"); +const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async sendLogInfo(emoji) { + const guildId = emoji.guild.id; + + try { + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const existingGuildId = query[0]?.guildId; + + if (existingGuildId) { + const logChannelId = query[0]?.logChannelId; + const logChannel = emoji.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessageFailureColor( + "Emoji deleted", + `${emoji.name} emoji was deleted.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + catch (error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file From b3b73ac7fd32b30082916effeab370e71d45eaad Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 24 Oct 2024 00:38:18 +0200 Subject: [PATCH 029/100] added emojiUpdate event logging --- events/channelUpdate.js | 8 ++++++++ events/emojiUpdate.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/events/channelUpdate.js b/events/channelUpdate.js index e69de29..f4a6191 100644 --- a/events/channelUpdate.js +++ b/events/channelUpdate.js @@ -0,0 +1,8 @@ +const logEventToChannel = require("./scripts/channelUpdate/logEventToChannel"); + +module.exports = { + name: "channelUpdate", + async execute(oldChannel, newChannel) { + await logEventToChannel.sendLogInfo(channel); + }, +} \ No newline at end of file diff --git a/events/emojiUpdate.js b/events/emojiUpdate.js index e69de29..347e9a6 100644 --- a/events/emojiUpdate.js +++ b/events/emojiUpdate.js @@ -0,0 +1,8 @@ +const logEventToChannel = require("./scripts/emojiUpdate/logEventToChannel"); + +module.exports = { + name: "emojiUpdate", + async execute(oldEmoji, newEmoji) { + await logEventToChannel.sendLogInfo(oldEmoji, newEmoji); + }, +} \ No newline at end of file From 8554008725850c1d0f277376f97c1ad69a17068d Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 24 Oct 2024 00:38:48 +0200 Subject: [PATCH 030/100] added emojiUpdate event logging --- .../channelUpdate/logEventToChannel.js | 44 +++++++++++++++++++ .../scripts/emojiUpdate/logEventToChannel.js | 28 ++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 events/scripts/channelUpdate/logEventToChannel.js create mode 100644 events/scripts/emojiUpdate/logEventToChannel.js diff --git a/events/scripts/channelUpdate/logEventToChannel.js b/events/scripts/channelUpdate/logEventToChannel.js new file mode 100644 index 0000000..5c2130f --- /dev/null +++ b/events/scripts/channelUpdate/logEventToChannel.js @@ -0,0 +1,44 @@ +const db = require("../../../helpers/db"); +const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async getGuildFromDB(channel) { + const guildId = channel.guild.id; + + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const existingGuildId = query[0]?.guildId; + + const doesGuildExist = existingGuildId ? true : false; + + return doesGuildExist, query; + }, + + async sendLogInfoNSFW(oldChannel, newChannel) { + const doesGuildExist = await this.getGuildFromDB(newChannel); + + try { + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const existingGuildId = query[0]?.guildId; + + if (existingGuildId) { + const logChannelId = query[0]?.logChannelId; + const logChannel = channel.guild.channels.cache.get(logChannelId); + + const nsfwStatus = channel.nsfw ? "NSFW" : "Not NSFW"; + const logEmbed = embedMessageSuccessColor( + "Channel updated", + `NSFW status was set to **${nsfwStatus}** in ${channel.name}.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + catch (error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + }, + + async sendLogInfoName(oldChannel, newChannel) { + console.log(""); + } +} \ No newline at end of file diff --git a/events/scripts/emojiUpdate/logEventToChannel.js b/events/scripts/emojiUpdate/logEventToChannel.js new file mode 100644 index 0000000..cc93e14 --- /dev/null +++ b/events/scripts/emojiUpdate/logEventToChannel.js @@ -0,0 +1,28 @@ +const db = require("../../../helpers/db"); +const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async sendLogInfo(oldEmoji, newEmoji) { + const guildId = oldEmoji.guild.id; + + try { + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const existingGuildId = query[0]?.guildId; + + if (existingGuildId) { + const logChannelId = query[0]?.logChannelId; + const logChannel = oldEmoji.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessageSuccessColor( + "Emoji updated", + `${oldEmoji.name} emoji was updated.\n\nOld name: ${oldEmoji.name}\nNew name: ${newEmoji.name}`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + catch (error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file From 36b37b588c85248e8f51be901831f74be439e39c Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 24 Oct 2024 00:42:25 +0200 Subject: [PATCH 031/100] added scripts for remaining events --- events/scripts/guildBanAdd/logEventToChannel.js | 0 events/scripts/guildBanRemove/logEventToChannel.js | 0 events/scripts/guildMemberRemove/logEventToChannel.js | 0 events/scripts/messageDelete/logEventToChannel.js | 0 events/scripts/messageUpdate/logEventToChannel.js | 0 events/scripts/voiceStateUpdate/logEventToChannel.js | 0 6 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 events/scripts/guildBanAdd/logEventToChannel.js create mode 100644 events/scripts/guildBanRemove/logEventToChannel.js create mode 100644 events/scripts/guildMemberRemove/logEventToChannel.js create mode 100644 events/scripts/messageDelete/logEventToChannel.js create mode 100644 events/scripts/messageUpdate/logEventToChannel.js create mode 100644 events/scripts/voiceStateUpdate/logEventToChannel.js diff --git a/events/scripts/guildBanAdd/logEventToChannel.js b/events/scripts/guildBanAdd/logEventToChannel.js new file mode 100644 index 0000000..e69de29 diff --git a/events/scripts/guildBanRemove/logEventToChannel.js b/events/scripts/guildBanRemove/logEventToChannel.js new file mode 100644 index 0000000..e69de29 diff --git a/events/scripts/guildMemberRemove/logEventToChannel.js b/events/scripts/guildMemberRemove/logEventToChannel.js new file mode 100644 index 0000000..e69de29 diff --git a/events/scripts/messageDelete/logEventToChannel.js b/events/scripts/messageDelete/logEventToChannel.js new file mode 100644 index 0000000..e69de29 diff --git a/events/scripts/messageUpdate/logEventToChannel.js b/events/scripts/messageUpdate/logEventToChannel.js new file mode 100644 index 0000000..e69de29 diff --git a/events/scripts/voiceStateUpdate/logEventToChannel.js b/events/scripts/voiceStateUpdate/logEventToChannel.js new file mode 100644 index 0000000..e69de29 From c101bb062bceccdffacd5c047f4fd69c05679e03 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 24 Oct 2024 00:54:19 +0200 Subject: [PATCH 032/100] added script imports for remaining events --- events/guildBanAdd.js | 8 ++++++++ events/guildBanRemove.js | 8 ++++++++ events/guildMemberRemove.js | 8 ++++++++ events/messageDelete.js | 8 ++++++++ events/messageUpdate.js | 8 ++++++++ events/voiceStateUpdate.js | 8 ++++++++ 6 files changed, 48 insertions(+) diff --git a/events/guildBanAdd.js b/events/guildBanAdd.js index e69de29..3298b26 100644 --- a/events/guildBanAdd.js +++ b/events/guildBanAdd.js @@ -0,0 +1,8 @@ +const logEventToChannel = require("./scripts/guildBanAdd/logEventToChannel"); + +module.exports = { + name: "guildBanAdd", + async execute(member, reason) { + await logEventToChannel.sendLogInfo(member, reason); + }, +} \ No newline at end of file diff --git a/events/guildBanRemove.js b/events/guildBanRemove.js index e69de29..f2233a9 100644 --- a/events/guildBanRemove.js +++ b/events/guildBanRemove.js @@ -0,0 +1,8 @@ +const logEventToChannel = require("./scripts/guildBanRemove/logEventToChannel"); + +module.exports = { + name: "guildBanRemove", + async execute(member, reason) { + await logEventToChannel.sendLogInfo(member, reason); + }, +} \ No newline at end of file diff --git a/events/guildMemberRemove.js b/events/guildMemberRemove.js index e69de29..41d6781 100644 --- a/events/guildMemberRemove.js +++ b/events/guildMemberRemove.js @@ -0,0 +1,8 @@ +const logEventToChannel = require("./scripts/guildMemberRemove/logEventToChannel"); + +module.exports = { + name: "guildMemberRemove", + async execute(member, reason) { + await logEventToChannel.sendLogInfo(member, reason); + }, +} \ No newline at end of file diff --git a/events/messageDelete.js b/events/messageDelete.js index e69de29..1a256ab 100644 --- a/events/messageDelete.js +++ b/events/messageDelete.js @@ -0,0 +1,8 @@ +const messageLogging = require("./scripts/messageDelete/messageLogging"); + +module.exports = { + name: "messageDelete", + async execute(message) { + await messageLogging.logMessagesToLocalDatabase(message); + }, +}; \ No newline at end of file diff --git a/events/messageUpdate.js b/events/messageUpdate.js index e69de29..71c889c 100644 --- a/events/messageUpdate.js +++ b/events/messageUpdate.js @@ -0,0 +1,8 @@ +const messageLogging = require("./scripts/messageUpdate/messageLogging"); + +module.exports = { + name: "messageUpdate", + async execute(oldMessage, newMessage) { + await messageLogging.logMessagesToLocalDatabase(oldMessage, newMessage); + }, +}; \ No newline at end of file diff --git a/events/voiceStateUpdate.js b/events/voiceStateUpdate.js index e69de29..c916e11 100644 --- a/events/voiceStateUpdate.js +++ b/events/voiceStateUpdate.js @@ -0,0 +1,8 @@ +const messageLogging = require("./scripts/voiceStateUpdate/messageLogging"); + +module.exports = { + name: "voiceStateUpdate", + async execute(oldState, newState) { + await messageLogging.logMessagesToLocalDatabase(oldState, newState); + }, +}; \ No newline at end of file From 6541393a4823acb9d7f799c09800da897861f956 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 24 Oct 2024 23:09:57 +0200 Subject: [PATCH 033/100] updated packages --- package-lock.json | 260 ++++++++++++++++++++++------------------------ 1 file changed, 125 insertions(+), 135 deletions(-) diff --git a/package-lock.json b/package-lock.json index 41c6a4d..28a2a27 100755 --- a/package-lock.json +++ b/package-lock.json @@ -39,12 +39,12 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.25.7.tgz", - "integrity": "sha512-0xZJFNE5XMpENsgfHYTw8FbX4kv53mFLn2i3XPoq69LyhYSCBJtitaHx9QnsVTrsogI4Z3+HtEfZ2/GFPOtf5g==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.25.9.tgz", + "integrity": "sha512-z88xeGxnzehn2sqZ8UdGQEvYErF1odv2CftxInpSYJt6uHuPe9YjahKZITGs3l5LeI9d2ROG+obuDAoSlqbNfQ==", "dev": true, "dependencies": { - "@babel/highlight": "^7.25.7", + "@babel/highlight": "^7.25.9", "picocolors": "^1.0.0" }, "engines": { @@ -52,30 +52,30 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.8.tgz", - "integrity": "sha512-ZsysZyXY4Tlx+Q53XdnOFmqwfB9QDTHYxaZYajWRoBLuLEAwI2UIbtxOjWh/cFaa9IKUlcB+DDuoskLuKu56JA==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.9.tgz", + "integrity": "sha512-yD+hEuJ/+wAJ4Ox2/rpNv5HIuPG82x3ZlQvYVn8iYCprdxzE7P1udpGF1jyjQVBU4dgznN+k2h103vxZ7NdPyw==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.8.tgz", - "integrity": "sha512-Oixnb+DzmRT30qu9d3tJSQkxuygWm32DFykT4bRoORPa9hZ/L4KhVB/XiRm6KG+roIEM7DBQlmg27kw2HZkdZg==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.9.tgz", + "integrity": "sha512-WYvQviPw+Qyib0v92AwNIrdLISTp7RfDkM7bPqBvpbnhY4wq8HvHBZREVdYDXk98C8BkOIVnHAY3yvj7AVISxQ==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.25.7", - "@babel/generator": "^7.25.7", - "@babel/helper-compilation-targets": "^7.25.7", - "@babel/helper-module-transforms": "^7.25.7", - "@babel/helpers": "^7.25.7", - "@babel/parser": "^7.25.8", - "@babel/template": "^7.25.7", - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.8", + "@babel/code-frame": "^7.25.9", + "@babel/generator": "^7.25.9", + "@babel/helper-compilation-targets": "^7.25.9", + "@babel/helper-module-transforms": "^7.25.9", + "@babel/helpers": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/template": "^7.25.9", + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -91,12 +91,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.7.tgz", - "integrity": "sha512-5Dqpl5fyV9pIAD62yK9P7fcA768uVPUyrQmqpqstHWgMma4feF1x/oFysBCVZLY5wJ2GkMUCdsNDnGZrPoR6rA==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.9.tgz", + "integrity": "sha512-omlUGkr5EaoIJrhLf9CJ0TvjBRpd9+AXRG//0GEQ9THSo8wPiTlbpy1/Ow8ZTrbXpjd9FHXfbFQx32I04ht0FA==", "dev": true, "dependencies": { - "@babel/types": "^7.25.7", + "@babel/types": "^7.25.9", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^3.0.2" @@ -106,13 +106,13 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.7.tgz", - "integrity": "sha512-DniTEax0sv6isaw6qSQSfV4gVRNtw2rte8HHM45t9ZR0xILaufBRNkpMifCRiAPyvL4ACD6v0gfCwCmtOQaV4A==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.9.tgz", + "integrity": "sha512-j9Db8Suy6yV/VHa4qzrj9yZfZxhLWQdVnRlXxmKLYlhWUVB1sB2G5sxuWYXk/whHD9iW76PmNzxZ4UCnTQTVEQ==", "dev": true, "dependencies": { - "@babel/compat-data": "^7.25.7", - "@babel/helper-validator-option": "^7.25.7", + "@babel/compat-data": "^7.25.9", + "@babel/helper-validator-option": "^7.25.9", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", "semver": "^6.3.1" @@ -122,28 +122,28 @@ } }, "node_modules/@babel/helper-module-imports": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.7.tgz", - "integrity": "sha512-o0xCgpNmRohmnoWKQ0Ij8IdddjyBFE4T2kagL/x6M3+4zUgc+4qTOUBoNe4XxDskt1HPKO007ZPiMgLDq2s7Kw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz", + "integrity": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==", "dev": true, "dependencies": { - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7" + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.7.tgz", - "integrity": "sha512-k/6f8dKG3yDz/qCwSM+RKovjMix563SLxQFo0UhRNo239SP6n9u5/eLtKD6EAjwta2JHJ49CsD8pms2HdNiMMQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.9.tgz", + "integrity": "sha512-TvLZY/F3+GvdRYFZFyxMvnsKi+4oJdgZzU3BoGN9Uc2d9C6zfNwJcKKhjqLAhK8i46mv93jsO74fDh3ih6rpHA==", "dev": true, "dependencies": { - "@babel/helper-module-imports": "^7.25.7", - "@babel/helper-simple-access": "^7.25.7", - "@babel/helper-validator-identifier": "^7.25.7", - "@babel/traverse": "^7.25.7" + "@babel/helper-module-imports": "^7.25.9", + "@babel/helper-simple-access": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9", + "@babel/traverse": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -153,74 +153,74 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.7.tgz", - "integrity": "sha512-eaPZai0PiqCi09pPs3pAFfl/zYgGaE6IdXtYvmf0qlcDTd3WCtO7JWCcRd64e0EQrcYgiHibEZnOGsSY4QSgaw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", + "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-simple-access": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.25.7.tgz", - "integrity": "sha512-FPGAkJmyoChQeM+ruBGIDyrT2tKfZJO8NcxdC+CWNJi7N8/rZpSxK7yvBJ5O/nF1gfu5KzN7VKG3YVSLFfRSxQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.25.9.tgz", + "integrity": "sha512-c6WHXuiaRsJTyHYLJV75t9IqsmTbItYfdj99PnzYGQZkYKvan5/2jKJ7gu31J3/BJ/A18grImSPModuyG/Eo0Q==", "dev": true, "dependencies": { - "@babel/traverse": "^7.25.7", - "@babel/types": "^7.25.7" + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-string-parser": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.7.tgz", - "integrity": "sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz", - "integrity": "sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.7.tgz", - "integrity": "sha512-ytbPLsm+GjArDYXJ8Ydr1c/KJuutjF2besPNbIZnZ6MKUxi/uTA22t2ymmA4WFjZFpjiAMO0xuuJPqK2nvDVfQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz", + "integrity": "sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helpers": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.7.tgz", - "integrity": "sha512-Sv6pASx7Esm38KQpF/U/OXLwPPrdGHNKoeblRxgZRLXnAtnkEe4ptJPDtAZM7fBLadbc1Q07kQpSiGQ0Jg6tRA==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.9.tgz", + "integrity": "sha512-oKWp3+usOJSzDZOucZUAMayhPz/xVjzymyDzUN8dk0Wd3RWMlGLXi07UCQ/CgQVb8LvXx3XBajJH4XGgkt7H7g==", "dev": true, "dependencies": { - "@babel/template": "^7.25.7", - "@babel/types": "^7.25.7" + "@babel/template": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.25.7.tgz", - "integrity": "sha512-iYyACpW3iW8Fw+ZybQK+drQre+ns/tKpXbNESfrhNnPLIklLbXr7MYJ6gPEd0iETGLOK+SxMjVvKb/ffmk+FEw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.25.9.tgz", + "integrity": "sha512-llL88JShoCsth8fF8R4SJnIn+WLvR6ccFxu1H3FlMhDontdcmZWf2HgIZ7AIqV3Xcck1idlohrN4EUBQz6klbw==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.25.7", + "@babel/helper-validator-identifier": "^7.25.9", "chalk": "^2.4.2", "js-tokens": "^4.0.0", "picocolors": "^1.0.0" @@ -301,12 +301,12 @@ } }, "node_modules/@babel/parser": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.8.tgz", - "integrity": "sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.9.tgz", + "integrity": "sha512-aI3jjAAO1fh7vY/pBGsn1i9LDbRP43+asrRlkPuTXW5yHXtd1NgTEMudbBoDDxrf1daEEfPJqR+JBMakzrR4Dg==", "dev": true, "dependencies": { - "@babel/types": "^7.25.8" + "@babel/types": "^7.25.9" }, "bin": { "parser": "bin/babel-parser.js" @@ -367,12 +367,12 @@ } }, "node_modules/@babel/plugin-syntax-import-attributes": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.25.7.tgz", - "integrity": "sha512-AqVo+dguCgmpi/3mYBdu9lkngOBlQ2w2vnNpa6gfiCxQZLzV4ZbhsXitJ2Yblkoe1VQwtHSaNmIaGll/26YWRw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.25.9.tgz", + "integrity": "sha512-u3EN9ub8LyYvgTnrgp8gboElouayiwPdnM7x5tcnW3iSt09/lQYPwMNK40I9IUxo7QOZhAsPHCmmuO7EPdruqg==", "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" + "@babel/helper-plugin-utils": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -406,12 +406,12 @@ } }, "node_modules/@babel/plugin-syntax-jsx": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.7.tgz", - "integrity": "sha512-ruZOnKO+ajVL/MVx+PwNBPOkrnXTXoWMtte1MBpegfCArhqOe3Bj52avVj1huLLxNKYKXYaSxZ2F+woK1ekXfw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.9.tgz", + "integrity": "sha512-ld6oezHQMZsZfp6pWtbjaNDF2tiiCYYDqQszHt5VV437lewP9aSi2Of99CK0D0XB21k7FLgnLcmQKyKzynfeAA==", "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" + "@babel/helper-plugin-utils": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -523,12 +523,12 @@ } }, "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.7.tgz", - "integrity": "sha512-rR+5FDjpCHqqZN2bzZm18bVYGaejGq5ZkpVCJLXor/+zlSrSoc4KWcHI0URVWjl/68Dyr1uwZUz/1njycEAv9g==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.9.tgz", + "integrity": "sha512-hjMgRy5hb8uJJjUcdWunWVcoi9bGpJp8p5Ol1229PoN6aytsLwNMgmdftO23wnCLMfVmTwZDWMPNq/D1SY60JQ==", "dev": true, "dependencies": { - "@babel/helper-plugin-utils": "^7.25.7" + "@babel/helper-plugin-utils": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -538,30 +538,30 @@ } }, "node_modules/@babel/template": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.7.tgz", - "integrity": "sha512-wRwtAgI3bAS+JGU2upWNL9lSlDcRCqD05BZ1n3X2ONLH1WilFP6O1otQjeMK/1g0pvYcXC7b/qVUB1keofjtZA==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.9.tgz", + "integrity": "sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.25.7", - "@babel/parser": "^7.25.7", - "@babel/types": "^7.25.7" + "@babel/code-frame": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/types": "^7.25.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.25.7", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.7.tgz", - "integrity": "sha512-jatJPT1Zjqvh/1FyJs6qAHL+Dzb7sTb+xr7Q+gM1b+1oBsMsQQ4FkVKb6dFlJvLlVssqkRzV05Jzervt9yhnzg==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.9.tgz", + "integrity": "sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.25.7", - "@babel/generator": "^7.25.7", - "@babel/parser": "^7.25.7", - "@babel/template": "^7.25.7", - "@babel/types": "^7.25.7", + "@babel/code-frame": "^7.25.9", + "@babel/generator": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/template": "^7.25.9", + "@babel/types": "^7.25.9", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -570,14 +570,13 @@ } }, "node_modules/@babel/types": { - "version": "7.25.8", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.8.tgz", - "integrity": "sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.9.tgz", + "integrity": "sha512-OwS2CM5KocvQ/k7dFJa8i5bNGJP0hXWfVCfDkqRFP1IreH1JDC7wG6eCYCi0+McbfT8OR/kNqsI0UU0xP9H6PQ==", "dev": true, "dependencies": { - "@babel/helper-string-parser": "^7.25.7", - "@babel/helper-validator-identifier": "^7.25.7", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -1221,9 +1220,9 @@ } }, "node_modules/@types/node": { - "version": "22.7.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.5.tgz", - "integrity": "sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==", + "version": "22.7.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.9.tgz", + "integrity": "sha512-jrTfRC7FM6nChvU7X2KqcrgquofrWLFDeYC1hKfwNWomVvrn7JIksqf344WN2X/y8xrgqBd2dJATZV4GbatBfg==", "dependencies": { "undici-types": "~6.19.2" } @@ -1562,9 +1561,9 @@ } }, "node_modules/browserslist": { - "version": "4.24.0", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.0.tgz", - "integrity": "sha512-Rmb62sR1Zpjql25eSanFGEhAxcFwfA1K0GuQcLoaJBAcENegrQut3hYdhXFF1obQfiDyqIW/cLM5HSJ/9k884A==", + "version": "4.24.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz", + "integrity": "sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg==", "dev": true, "funding": [ { @@ -1581,10 +1580,10 @@ } ], "dependencies": { - "caniuse-lite": "^1.0.30001663", - "electron-to-chromium": "^1.5.28", + "caniuse-lite": "^1.0.30001669", + "electron-to-chromium": "^1.5.41", "node-releases": "^2.0.18", - "update-browserslist-db": "^1.1.0" + "update-browserslist-db": "^1.1.1" }, "bin": { "browserslist": "cli.js" @@ -1627,9 +1626,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001668", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001668.tgz", - "integrity": "sha512-nWLrdxqCdblixUO+27JtGJJE/txpJlyUy5YN1u53wLZkP0emYCo5zgS6QYft7VUYR42LGgi/S5hdLZTrnyIddw==", + "version": "1.0.30001669", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001669.tgz", + "integrity": "sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w==", "dev": true, "funding": [ { @@ -2107,9 +2106,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.37", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.37.tgz", - "integrity": "sha512-u7000ZB/X0K78TaQqXZ5ktoR7J79B9US7IkE4zyvcILYwOGY2Tx9GRPYstn7HmuPcMxZ+BDGqIsyLpZQi9ufPw==", + "version": "1.5.45", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.45.tgz", + "integrity": "sha512-vOzZS6uZwhhbkZbcRyiy99Wg+pYFV5hk+5YaECvx0+Z31NR3Tt5zS6dze2OepT6PCTzVzT0dIJItti+uAW5zmw==", "dev": true }, "node_modules/emittery": { @@ -2286,9 +2285,9 @@ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" }, "node_modules/fast-uri": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.2.tgz", - "integrity": "sha512-GR6f0hD7XXyNJa25Tb9BuIdN0tdr+0BMi6/CJPH3wJO1JjNG3n/VsSw38AwRdKZABm8lGbPfakLRkYzx2V9row==" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.3.tgz", + "integrity": "sha512-aLrHthzCjH5He4Z2H9YZ+v6Ujb9ocRuW6ZzkJQOrTxleEijANq4v1TsaPaVG1PZcuurEzrLcWRyYBYXD5cEiaw==" }, "node_modules/fb-watchman": { "version": "2.0.2", @@ -4050,9 +4049,9 @@ "peer": true }, "node_modules/picocolors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", - "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "dev": true }, "node_modules/picomatch": { @@ -4600,15 +4599,6 @@ "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", "dev": true }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -4648,9 +4638,9 @@ "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==" }, "node_modules/tslib": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", - "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz", + "integrity": "sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==" }, "node_modules/tunnel-agent": { "version": "0.6.0", From 1770eadc65c8148fe594a95c061adeb3f85348d5 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Fri, 25 Oct 2024 18:42:18 +0200 Subject: [PATCH 034/100] added query helper --- .../channelUpdate/logEventToChannel.js | 11 ----------- helpers/log-data-query.js | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 helpers/log-data-query.js diff --git a/events/scripts/channelUpdate/logEventToChannel.js b/events/scripts/channelUpdate/logEventToChannel.js index 5c2130f..65c386a 100644 --- a/events/scripts/channelUpdate/logEventToChannel.js +++ b/events/scripts/channelUpdate/logEventToChannel.js @@ -2,17 +2,6 @@ const db = require("../../../helpers/db"); const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); module.exports = { - async getGuildFromDB(channel) { - const guildId = channel.guild.id; - - const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); - const existingGuildId = query[0]?.guildId; - - const doesGuildExist = existingGuildId ? true : false; - - return doesGuildExist, query; - }, - async sendLogInfoNSFW(oldChannel, newChannel) { const doesGuildExist = await this.getGuildFromDB(newChannel); diff --git a/helpers/log-data-query.js b/helpers/log-data-query.js new file mode 100644 index 0000000..75009db --- /dev/null +++ b/helpers/log-data-query.js @@ -0,0 +1,19 @@ +const db = require("./db"); + +/** + * @param {object} object - An channel, message, etc. object from a guild + * @returns {doesGuildExist} A boolean value indicating if the guild exists in the database + * @returns {query} A query object containing the guildId and logChannelId + */ +module.exports = { + async getGuildFromDB(object) { + const guildId = object.guild.id; + + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const existingGuildId = query[0]?.guildId; + + const doesGuildExist = existingGuildId ? true : false; + + return doesGuildExist, query; + } +} \ No newline at end of file From 8376166eca99d8c8def75f908f9e1db6eeeb3e8e Mon Sep 17 00:00:00 2001 From: vb2007 Date: Fri, 25 Oct 2024 19:18:28 +0200 Subject: [PATCH 035/100] fixed helper, fixed logging channel actions, fixed other things --- events/channelUpdate.js | 2 +- events/messageDelete.js | 14 +++++------ events/messageUpdate.js | 14 +++++------ .../channelUpdate/logEventToChannel.js | 24 +++++++++---------- events/voiceStateUpdate.js | 14 +++++------ helpers/log-data-query.js | 17 ++++++------- 6 files changed, 42 insertions(+), 43 deletions(-) diff --git a/events/channelUpdate.js b/events/channelUpdate.js index f4a6191..9fb0ba7 100644 --- a/events/channelUpdate.js +++ b/events/channelUpdate.js @@ -3,6 +3,6 @@ const logEventToChannel = require("./scripts/channelUpdate/logEventToChannel"); module.exports = { name: "channelUpdate", async execute(oldChannel, newChannel) { - await logEventToChannel.sendLogInfo(channel); + await logEventToChannel.sendLogInfoNSFW(oldChannel, newChannel); }, } \ No newline at end of file diff --git a/events/messageDelete.js b/events/messageDelete.js index 1a256ab..9f1d294 100644 --- a/events/messageDelete.js +++ b/events/messageDelete.js @@ -1,8 +1,8 @@ -const messageLogging = require("./scripts/messageDelete/messageLogging"); +// const messageLogging = require("./scripts/messageDelete/messageLogging"); -module.exports = { - name: "messageDelete", - async execute(message) { - await messageLogging.logMessagesToLocalDatabase(message); - }, -}; \ No newline at end of file +// module.exports = { +// name: "messageDelete", +// async execute(message) { +// await messageLogging.logMessagesToLocalDatabase(message); +// }, +// }; \ No newline at end of file diff --git a/events/messageUpdate.js b/events/messageUpdate.js index 71c889c..368d5cf 100644 --- a/events/messageUpdate.js +++ b/events/messageUpdate.js @@ -1,8 +1,8 @@ -const messageLogging = require("./scripts/messageUpdate/messageLogging"); +// const messageLogging = require("./scripts/messageUpdate/messageLogging"); -module.exports = { - name: "messageUpdate", - async execute(oldMessage, newMessage) { - await messageLogging.logMessagesToLocalDatabase(oldMessage, newMessage); - }, -}; \ No newline at end of file +// module.exports = { +// name: "messageUpdate", +// async execute(oldMessage, newMessage) { +// await messageLogging.logMessagesToLocalDatabase(oldMessage, newMessage); +// }, +// }; \ No newline at end of file diff --git a/events/scripts/channelUpdate/logEventToChannel.js b/events/scripts/channelUpdate/logEventToChannel.js index 65c386a..eea6c43 100644 --- a/events/scripts/channelUpdate/logEventToChannel.js +++ b/events/scripts/channelUpdate/logEventToChannel.js @@ -1,22 +1,20 @@ const db = require("../../../helpers/db"); +const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfoNSFW(oldChannel, newChannel) { - const doesGuildExist = await this.getGuildFromDB(newChannel); - try { - const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); - const existingGuildId = query[0]?.guildId; - - if (existingGuildId) { - const logChannelId = query[0]?.logChannelId; - const logChannel = channel.guild.channels.cache.get(logChannelId); + const { doesGuildExist, logChannelId } = await getGuildFromDB(oldChannel); + console.log(doesGuildExist, logChannelId); - const nsfwStatus = channel.nsfw ? "NSFW" : "Not NSFW"; + if (doesGuildExist) { + const logChannel = oldChannel.guild.channels.cache.get(logChannelId); + + const nsfwStatus = oldChannel.nsfw ? "NSFW" : "Not NSFW"; const logEmbed = embedMessageSuccessColor( "Channel updated", - `NSFW status was set to **${nsfwStatus}** in ${channel.name}.`, + `NSFW status was set to **${nsfwStatus}** in ${oldChannel.name}.`, ); await logChannel.send({ embeds: [logEmbed] }); @@ -27,7 +25,7 @@ module.exports = { } }, - async sendLogInfoName(oldChannel, newChannel) { - console.log(""); - } + // async sendLogInfoName(oldChannel, newChannel) { + // console.log(""); + // } } \ No newline at end of file diff --git a/events/voiceStateUpdate.js b/events/voiceStateUpdate.js index c916e11..361972a 100644 --- a/events/voiceStateUpdate.js +++ b/events/voiceStateUpdate.js @@ -1,8 +1,8 @@ -const messageLogging = require("./scripts/voiceStateUpdate/messageLogging"); +// const messageLogging = require("./scripts/voiceStateUpdate/messageLogging"); -module.exports = { - name: "voiceStateUpdate", - async execute(oldState, newState) { - await messageLogging.logMessagesToLocalDatabase(oldState, newState); - }, -}; \ No newline at end of file +// module.exports = { +// name: "voiceStateUpdate", +// async execute(oldState, newState) { +// await messageLogging.logMessagesToLocalDatabase(oldState, newState); +// }, +// }; \ No newline at end of file diff --git a/helpers/log-data-query.js b/helpers/log-data-query.js index 75009db..bc94a9a 100644 --- a/helpers/log-data-query.js +++ b/helpers/log-data-query.js @@ -3,17 +3,18 @@ const db = require("./db"); /** * @param {object} object - An channel, message, etc. object from a guild * @returns {doesGuildExist} A boolean value indicating if the guild exists in the database - * @returns {query} A query object containing the guildId and logChannelId + * @returns {logChannelId} A log channel ID from the database based on the guild ID (if configured) */ module.exports = { async getGuildFromDB(object) { const guildId = object.guild.id; - + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); - const existingGuildId = query[0]?.guildId; - - const doesGuildExist = existingGuildId ? true : false; - - return doesGuildExist, query; + const logChannelId = query[0]?.logChannelId; + + const doesGuildExist = logChannelId ? true : false; + + console.log(doesGuildExist, logChannelId); + return { doesGuildExist, logChannelId }; } -} \ No newline at end of file +} \ No newline at end of file From 4f0097bed4c582b0d1f86adc9a546df7eef3ab12 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Fri, 25 Oct 2024 19:41:15 +0200 Subject: [PATCH 036/100] fixed channel nsfw status change logging --- .../channelUpdate/logEventToChannel.js | 20 ++++++++++--------- .../scripts/messageCreate/messageLogging.js | 2 +- helpers/log-data-query.js | 3 +-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/events/scripts/channelUpdate/logEventToChannel.js b/events/scripts/channelUpdate/logEventToChannel.js index eea6c43..89c79a5 100644 --- a/events/scripts/channelUpdate/logEventToChannel.js +++ b/events/scripts/channelUpdate/logEventToChannel.js @@ -6,18 +6,20 @@ module.exports = { async sendLogInfoNSFW(oldChannel, newChannel) { try { const { doesGuildExist, logChannelId } = await getGuildFromDB(oldChannel); - console.log(doesGuildExist, logChannelId); if (doesGuildExist) { - const logChannel = oldChannel.guild.channels.cache.get(logChannelId); + if (oldChannel.nsfw !== newChannel.nsfw) { + const logChannel = oldChannel.guild.channels.cache.get(logChannelId); - const nsfwStatus = oldChannel.nsfw ? "NSFW" : "Not NSFW"; - const logEmbed = embedMessageSuccessColor( - "Channel updated", - `NSFW status was set to **${nsfwStatus}** in ${oldChannel.name}.`, - ); - - await logChannel.send({ embeds: [logEmbed] }); + const oldNSFWStatus = oldChannel.nsfw ? "NSFW" : "Not NSFW"; + const newNSFWStatus = newChannel.nsfw ? "NSFW" : "Not NSFW"; + const logEmbed = embedMessageSuccessColor( + "Channel updated", + `NSFW status was set to **${newNSFWStatus}** from **${oldNSFWStatus}** in ${oldChannel.name}.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } } } catch (error) { diff --git a/events/scripts/messageCreate/messageLogging.js b/events/scripts/messageCreate/messageLogging.js index 830dede..8698511 100644 --- a/events/scripts/messageCreate/messageLogging.js +++ b/events/scripts/messageCreate/messageLogging.js @@ -18,7 +18,7 @@ module.exports = { messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId ] ); - console.log(`Logged message "${message.content}" from ${senderUserName} in ${serverName}.`); + console.log(`Logged message "${message.content}" to database from ${senderUserName} in ${serverName}.`); } catch (error) { console.error(`Failed to log message: ${error}`); diff --git a/helpers/log-data-query.js b/helpers/log-data-query.js index bc94a9a..ee086b6 100644 --- a/helpers/log-data-query.js +++ b/helpers/log-data-query.js @@ -13,8 +13,7 @@ module.exports = { const logChannelId = query[0]?.logChannelId; const doesGuildExist = logChannelId ? true : false; - - console.log(doesGuildExist, logChannelId); + return { doesGuildExist, logChannelId }; } } \ No newline at end of file From e1684bb3456c665fd69f5a6058673ac24ef0f697 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 27 Oct 2024 17:10:59 +0100 Subject: [PATCH 037/100] fixed channelUpdate event logging --- events/channelUpdate.js | 2 +- .../channelUpdate/logEventToChannel.js | 47 ++++++++++++++----- helpers/log-data-query.js | 10 ++-- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/events/channelUpdate.js b/events/channelUpdate.js index 9fb0ba7..5136dac 100644 --- a/events/channelUpdate.js +++ b/events/channelUpdate.js @@ -3,6 +3,6 @@ const logEventToChannel = require("./scripts/channelUpdate/logEventToChannel"); module.exports = { name: "channelUpdate", async execute(oldChannel, newChannel) { - await logEventToChannel.sendLogInfoNSFW(oldChannel, newChannel); + await logEventToChannel.sendLogInfo(oldChannel, newChannel); }, } \ No newline at end of file diff --git a/events/scripts/channelUpdate/logEventToChannel.js b/events/scripts/channelUpdate/logEventToChannel.js index 89c79a5..06087c4 100644 --- a/events/scripts/channelUpdate/logEventToChannel.js +++ b/events/scripts/channelUpdate/logEventToChannel.js @@ -1,21 +1,46 @@ -const db = require("../../../helpers/db"); const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfoNSFW(oldChannel, newChannel) { + async sendLogInfo(oldChannel, newChannel) { try { const { doesGuildExist, logChannelId } = await getGuildFromDB(oldChannel); if (doesGuildExist) { + const logChannel = oldChannel.guild.channels.cache.get(logChannelId); + const changedChannelId = newChannel.id; + if (oldChannel.nsfw !== newChannel.nsfw) { - const logChannel = oldChannel.guild.channels.cache.get(logChannelId); - - const oldNSFWStatus = oldChannel.nsfw ? "NSFW" : "Not NSFW"; - const newNSFWStatus = newChannel.nsfw ? "NSFW" : "Not NSFW"; const logEmbed = embedMessageSuccessColor( - "Channel updated", - `NSFW status was set to **${newNSFWStatus}** from **${oldNSFWStatus}** in ${oldChannel.name}.`, + "Channel Updated: NSFW status", + `Channel NSFW status was changed to "**${newChannel.nsfw ? "NSFW" : "Not NSFW"}**" from "**${oldChannel.nsfw ? "NSFW" : "Not NSFW"}**" in <#${changedChannelId}>.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + + if (oldChannel.name !== newChannel.name) { + const logEmbed = embedMessageSuccessColor( + "Channel Updated: Name", + `Channel name was changed to "**${newChannel.name}**" from "**${oldChannel.name}**" in <#${changedChannelId}>.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + + if (oldChannel.topic !== newChannel.topic) { + const logEmbed = embedMessageSuccessColor( + "Channel Updated: Topic", + `Channel topic *(description)* was changed to "**${newChannel.topic == "" ? "*empty description*" : newChannel.topic}**" from "**${newChannel.topic == "" ? "*empty description*" : newChannel.topic}**" in <#${changedChannelId}>.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + + if (oldChannel.rateLimitPerUser !== newChannel.rateLimitPerUser) { + const logEmbed = embedMessageSuccessColor( + "Channel Updated: Slowmode", + `Channel slowmode was changed to "**${newChannel.rateLimitPerUser}**" seconds from "**${oldChannel.rateLimitPerUser}**" seconds in <#${changedChannelId}>.`, ); await logChannel.send({ embeds: [logEmbed] }); @@ -25,9 +50,5 @@ module.exports = { catch (error) { console.error(`Failed to send log info to target channel: ${error}`); } - }, - - // async sendLogInfoName(oldChannel, newChannel) { - // console.log(""); - // } + } } \ No newline at end of file diff --git a/helpers/log-data-query.js b/helpers/log-data-query.js index ee086b6..d50a6c8 100644 --- a/helpers/log-data-query.js +++ b/helpers/log-data-query.js @@ -1,11 +1,11 @@ const db = require("./db"); -/** - * @param {object} object - An channel, message, etc. object from a guild - * @returns {doesGuildExist} A boolean value indicating if the guild exists in the database - * @returns {logChannelId} A log channel ID from the database based on the guild ID (if configured) - */ module.exports = { + /** + * @param {object} object - An channel, message, etc. object from a guild + * @returns {doesGuildExist} A boolean value indicating if the guild exists in the database + * @returns {logChannelId} A log channel ID from the database based on the guild ID (if configured) + */ async getGuildFromDB(object) { const guildId = object.guild.id; From dfe1bcf053348ef50da469c6be002240ec0e3895 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 27 Oct 2024 17:31:15 +0100 Subject: [PATCH 038/100] replaced repetetive script with helpers in other event scripts --- events/scripts/channelCreate/logEventToChannel.js | 10 +++------- events/scripts/channelDelete/logEventToChannel.js | 10 +++------- .../scripts/channelPinsUpdate/logEventToChannel.js | 10 +++------- events/scripts/emojiCreate/logEventToChannel.js | 10 +++------- events/scripts/emojiDelete/logEventToChannel.js | 10 +++------- events/scripts/emojiUpdate/logEventToChannel.js | 10 +++------- events/scripts/guildMemberAdd/logEventToChannel.js | 12 +++++------- 7 files changed, 23 insertions(+), 49 deletions(-) diff --git a/events/scripts/channelCreate/logEventToChannel.js b/events/scripts/channelCreate/logEventToChannel.js index fb8b57c..3086d1d 100644 --- a/events/scripts/channelCreate/logEventToChannel.js +++ b/events/scripts/channelCreate/logEventToChannel.js @@ -1,16 +1,12 @@ -const db = require("../../../helpers/db"); +const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(channel) { - const guildId = channel.guild.id; - try { - const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); - const existingGuildId = query[0]?.guildId; + const { doesGuildExist, logChannelId } = await getGuildFromDB(channel); - if (existingGuildId) { - const logChannelId = query[0]?.logChannelId; + if (doesGuildExist) { const logChannel = channel.guild.channels.cache.get(logChannelId); const logEmbed = embedMessageSuccessColor( diff --git a/events/scripts/channelDelete/logEventToChannel.js b/events/scripts/channelDelete/logEventToChannel.js index 4e81580..2bb5a48 100644 --- a/events/scripts/channelDelete/logEventToChannel.js +++ b/events/scripts/channelDelete/logEventToChannel.js @@ -1,16 +1,12 @@ -const db = require("../../../helpers/db"); +const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(channel) { - const guildId = channel.guild.id; - try { - const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); - const existingGuildId = query[0]?.guildId; + const { doesGuildExist, logChannelId } = await getGuildFromDB(channel); - if (existingGuildId) { - const logChannelId = query[0]?.logChannelId; + if (doesGuildExist) { const logChannel = channel.guild.channels.cache.get(logChannelId); const logEmbed = embedMessageFailureColor( diff --git a/events/scripts/channelPinsUpdate/logEventToChannel.js b/events/scripts/channelPinsUpdate/logEventToChannel.js index 131850d..2b2f177 100644 --- a/events/scripts/channelPinsUpdate/logEventToChannel.js +++ b/events/scripts/channelPinsUpdate/logEventToChannel.js @@ -1,16 +1,12 @@ -const db = require("../../../helpers/db"); +const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessagePrimaryColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(channel) { - const guildId = channel.guild.id; - try { - const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); - const existingGuildId = query[0]?.guildId; + const { doesGuildExist, logChannelId } = await getGuildFromDB(channel); - if (existingGuildId) { - const logChannelId = query[0]?.logChannelId; + if (doesGuildExist) { const logChannel = channel.guild.channels.cache.get(logChannelId); const logEmbed = embedMessagePrimaryColor( diff --git a/events/scripts/emojiCreate/logEventToChannel.js b/events/scripts/emojiCreate/logEventToChannel.js index ee26653..c1210a6 100644 --- a/events/scripts/emojiCreate/logEventToChannel.js +++ b/events/scripts/emojiCreate/logEventToChannel.js @@ -1,16 +1,12 @@ -const db = require("../../../helpers/db"); +const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(emoji) { - const guildId = emoji.guild.id; - try { - const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); - const existingGuildId = query[0]?.guildId; + const { doesGuildExist, logChannelId } = await getGuildFromDB(emoji); - if (existingGuildId) { - const logChannelId = query[0]?.logChannelId; + if (doesGuildExist) { const logChannel = emoji.guild.channels.cache.get(logChannelId); const logEmbed = embedMessageSuccessColor( diff --git a/events/scripts/emojiDelete/logEventToChannel.js b/events/scripts/emojiDelete/logEventToChannel.js index e83eabb..c55c78b 100644 --- a/events/scripts/emojiDelete/logEventToChannel.js +++ b/events/scripts/emojiDelete/logEventToChannel.js @@ -1,16 +1,12 @@ -const db = require("../../../helpers/db"); +const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(emoji) { - const guildId = emoji.guild.id; - try { - const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); - const existingGuildId = query[0]?.guildId; + const { doesGuildExist, logChannelId } = await getGuildFromDB(emoji); - if (existingGuildId) { - const logChannelId = query[0]?.logChannelId; + if (doesGuildExist) { const logChannel = emoji.guild.channels.cache.get(logChannelId); const logEmbed = embedMessageFailureColor( diff --git a/events/scripts/emojiUpdate/logEventToChannel.js b/events/scripts/emojiUpdate/logEventToChannel.js index cc93e14..2a8f8b4 100644 --- a/events/scripts/emojiUpdate/logEventToChannel.js +++ b/events/scripts/emojiUpdate/logEventToChannel.js @@ -1,16 +1,12 @@ -const db = require("../../../helpers/db"); +const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(oldEmoji, newEmoji) { - const guildId = oldEmoji.guild.id; - try { - const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); - const existingGuildId = query[0]?.guildId; + const { doesGuildExist, logChannelId } = await getGuildFromDB(oldEmoji); - if (existingGuildId) { - const logChannelId = query[0]?.logChannelId; + if (doesGuildExist) { const logChannel = oldEmoji.guild.channels.cache.get(logChannelId); const logEmbed = embedMessageSuccessColor( diff --git a/events/scripts/guildMemberAdd/logEventToChannel.js b/events/scripts/guildMemberAdd/logEventToChannel.js index cb400c2..9966320 100644 --- a/events/scripts/guildMemberAdd/logEventToChannel.js +++ b/events/scripts/guildMemberAdd/logEventToChannel.js @@ -1,22 +1,20 @@ -const db = require("../../../helpers/db"); +const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(member) { - const guildId = member.guild.id; - try { - const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); - const existingGuildId = query[0]?.guildId; - const logChannelId = query[0]?.logChannelId; + const { doesGuildExist, logChannelId } = await getGuildFromDB(member); if (existingGuildId) { + const logChannel = oldChannel.guild.channels.cache.get(logChannelId); + const logEmbed = embedMessageSuccessColor( "Member joined", `${member.user.tag} joined the server.`, ); - await logChannelId.send({ embeds: [logEmbed] }); + await logChannel.send({ embeds: [logEmbed] }); } } catch (error) { From fec3d50d1094e35b3fca798cf4a565714fdb6ec1 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 27 Oct 2024 18:07:30 +0100 Subject: [PATCH 039/100] added logging for remaining events (except voiceStateUpdate) --- events/guildBanRemove.js | 4 ++-- events/guildMemberRemove.js | 4 ++-- events/messageDelete.js | 14 +++++------ events/messageUpdate.js | 14 +++++------ .../scripts/guildBanAdd/logEventToChannel.js | 24 +++++++++++++++++++ .../guildBanRemove/logEventToChannel.js | 24 +++++++++++++++++++ .../guildMemberRemove/logEventToChannel.js | 24 +++++++++++++++++++ .../messageDelete/logEventToChannel.js | 24 +++++++++++++++++++ .../messageUpdate/logEventToChannel.js | 24 +++++++++++++++++++ 9 files changed, 138 insertions(+), 18 deletions(-) diff --git a/events/guildBanRemove.js b/events/guildBanRemove.js index f2233a9..55ce227 100644 --- a/events/guildBanRemove.js +++ b/events/guildBanRemove.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/guildBanRemove/logEventToChannel"); module.exports = { name: "guildBanRemove", - async execute(member, reason) { - await logEventToChannel.sendLogInfo(member, reason); + async execute(member) { + await logEventToChannel.sendLogInfo(member); }, } \ No newline at end of file diff --git a/events/guildMemberRemove.js b/events/guildMemberRemove.js index 41d6781..59fcacd 100644 --- a/events/guildMemberRemove.js +++ b/events/guildMemberRemove.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/guildMemberRemove/logEventToChannel module.exports = { name: "guildMemberRemove", - async execute(member, reason) { - await logEventToChannel.sendLogInfo(member, reason); + async execute(member) { + await logEventToChannel.sendLogInfo(member); }, } \ No newline at end of file diff --git a/events/messageDelete.js b/events/messageDelete.js index 9f1d294..654b6c2 100644 --- a/events/messageDelete.js +++ b/events/messageDelete.js @@ -1,8 +1,8 @@ -// const messageLogging = require("./scripts/messageDelete/messageLogging"); +const logEventToChannel = require("./scripts/mmessageDelete/logEventToChannel"); -// module.exports = { -// name: "messageDelete", -// async execute(message) { -// await messageLogging.logMessagesToLocalDatabase(message); -// }, -// }; \ No newline at end of file +module.exports = { + name: "messageDelete", + async execute(message) { + await logEventToChannel.sendLogInfo(message); + }, +} \ No newline at end of file diff --git a/events/messageUpdate.js b/events/messageUpdate.js index 368d5cf..efafbc3 100644 --- a/events/messageUpdate.js +++ b/events/messageUpdate.js @@ -1,8 +1,8 @@ -// const messageLogging = require("./scripts/messageUpdate/messageLogging"); +const logEventToChannel = require("./scripts/messageUpdate/logEventToChannel"); -// module.exports = { -// name: "messageUpdate", -// async execute(oldMessage, newMessage) { -// await messageLogging.logMessagesToLocalDatabase(oldMessage, newMessage); -// }, -// }; \ No newline at end of file +module.exports = { + name: "messageUpdate", + async execute(oldMessage, newMessage) { + await logEventToChannel.sendLogInfo(oldMessage, newMessage); + }, +} \ No newline at end of file diff --git a/events/scripts/guildBanAdd/logEventToChannel.js b/events/scripts/guildBanAdd/logEventToChannel.js index e69de29..d3ad418 100644 --- a/events/scripts/guildBanAdd/logEventToChannel.js +++ b/events/scripts/guildBanAdd/logEventToChannel.js @@ -0,0 +1,24 @@ +const { getGuildFromDB } = require("../../../helpers/log-data-query"); +const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async sendLogInfo(member, reason) { + try { + const { doesGuildExist, logChannelId } = await getGuildFromDB(member); + + if (doesGuildExist) { + const logChannel = member.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessageFailureColor( + "Member banned", + `${member.user.tag} was banned from the server.\nReason: ${reason}`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + catch(error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file diff --git a/events/scripts/guildBanRemove/logEventToChannel.js b/events/scripts/guildBanRemove/logEventToChannel.js index e69de29..617cf7d 100644 --- a/events/scripts/guildBanRemove/logEventToChannel.js +++ b/events/scripts/guildBanRemove/logEventToChannel.js @@ -0,0 +1,24 @@ +const { getGuildFromDB } = require("../../../helpers/log-data-query"); +const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async sendLogInfo(member) { + try { + const { doesGuildExist, logChannelId } = await getGuildFromDB(member); + + if (doesGuildExist) { + const logChannel = member.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessageSuccessColor( + "Member unbanned", + `${member.user.tag} has been unbanned from the server.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + catch(error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file diff --git a/events/scripts/guildMemberRemove/logEventToChannel.js b/events/scripts/guildMemberRemove/logEventToChannel.js index e69de29..8ed5c4e 100644 --- a/events/scripts/guildMemberRemove/logEventToChannel.js +++ b/events/scripts/guildMemberRemove/logEventToChannel.js @@ -0,0 +1,24 @@ +const { getGuildFromDB } = require("../../../helpers/log-data-query"); +const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async sendLogInfo(member) { + try { + const { doesGuildExist, logChannelId } = await getGuildFromDB(member); + + if (doesGuildExist) { + const logChannel = member.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessageFailureColor( + "Member left", + `<@${member.user.id}> has left the server.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + catch(error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file diff --git a/events/scripts/messageDelete/logEventToChannel.js b/events/scripts/messageDelete/logEventToChannel.js index e69de29..c9a93af 100644 --- a/events/scripts/messageDelete/logEventToChannel.js +++ b/events/scripts/messageDelete/logEventToChannel.js @@ -0,0 +1,24 @@ +const { getGuildFromDB } = require("../../../helpers/log-data-query"); +const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async sendLogInfo(message) { + try { + const { doesGuildExist, logChannelId } = await getGuildFromDB(message); + + if (doesGuildExist) { + const logChannel = message.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessageFailureColor( + "Message deleted", + `Message "**${message.content}**" from <@${message.author.id}> has been deleted from <#${message.channel.id}>.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + catch(error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file diff --git a/events/scripts/messageUpdate/logEventToChannel.js b/events/scripts/messageUpdate/logEventToChannel.js index e69de29..0fbb04e 100644 --- a/events/scripts/messageUpdate/logEventToChannel.js +++ b/events/scripts/messageUpdate/logEventToChannel.js @@ -0,0 +1,24 @@ +const { getGuildFromDB } = require("../../../helpers/log-data-query"); +const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async sendLogInfo(oldMessage, newMessage) { + try { + const { doesGuildExist, logChannelId } = await getGuildFromDB(oldMessage); + + if (doesGuildExist) { + const logChannel = oldMessage.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessageFailureColor( + "Message updated", + `Message "**${oldMessage.content}**" from <@${oldMessage.author.id}> has been updated to "**${newMessage.content}**" in <#${message.channel.id}>.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + catch(error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file From 6ab61fea225ee5cfab529e048bb479394ea9a063 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 27 Oct 2024 18:11:32 +0100 Subject: [PATCH 040/100] fixed typos, updated color --- events/messageDelete.js | 2 +- events/scripts/messageUpdate/logEventToChannel.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/events/messageDelete.js b/events/messageDelete.js index 654b6c2..342f4be 100644 --- a/events/messageDelete.js +++ b/events/messageDelete.js @@ -1,4 +1,4 @@ -const logEventToChannel = require("./scripts/mmessageDelete/logEventToChannel"); +const logEventToChannel = require("./scripts/messageDelete/logEventToChannel"); module.exports = { name: "messageDelete", diff --git a/events/scripts/messageUpdate/logEventToChannel.js b/events/scripts/messageUpdate/logEventToChannel.js index 0fbb04e..ff0ea0e 100644 --- a/events/scripts/messageUpdate/logEventToChannel.js +++ b/events/scripts/messageUpdate/logEventToChannel.js @@ -11,7 +11,7 @@ module.exports = { const logEmbed = embedMessageFailureColor( "Message updated", - `Message "**${oldMessage.content}**" from <@${oldMessage.author.id}> has been updated to "**${newMessage.content}**" in <#${message.channel.id}>.`, + `Message "**${oldMessage.content}**" from <@${oldMessage.author.id}> has been updated to "**${newMessage.content}**" in <#${oldMessage.channel.id}>.`, ); await logChannel.send({ embeds: [logEmbed] }); From 97114c7125fd14ee6ad99fe312117a26358f035a Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 27 Oct 2024 18:16:24 +0100 Subject: [PATCH 041/100] uncommented some intents and partials in index.js --- index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 0b74526..dcf84f7 100755 --- a/index.js +++ b/index.js @@ -18,13 +18,13 @@ const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildEmojisAndStickers, - // GatewayIntentBits.GuildIntegrations, + GatewayIntentBits.GuildIntegrations, GatewayIntentBits.GuildInvites, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessageReactions, // GatewayIntentBits.GuildMessageTyping, GatewayIntentBits.GuildMessages, - // GatewayIntentBits.GuildPresences, + GatewayIntentBits.GuildPresences, // GatewayIntentBits.GuildScheduledEvents, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildWebhooks, @@ -35,12 +35,12 @@ const client = new Client({ ], partials: [ Partials.Channel, - // Partials.GuildMember, - // Partials.GuildScheduledEvent, - // Partials.Message, - // Partials.Reaction, - // Partials.ThreadMember, - // Partials.User, + Partials.GuildMember, + Partials.GuildScheduledEvent, + Partials.Message, + Partials.Reaction, + Partials.ThreadMember, + Partials.User, ] }); From 18c08d44e896f061b8e296943e58efdb931607ed Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 27 Oct 2024 18:28:10 +0100 Subject: [PATCH 042/100] fixed & added new member join logging --- events/guildMemberAdd.js | 2 ++ events/scripts/guildMemberAdd/logEventToChannel.js | 4 ++-- index.js | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js index 328edfc..e140583 100755 --- a/events/guildMemberAdd.js +++ b/events/guildMemberAdd.js @@ -1,9 +1,11 @@ +const logEventToChannel = require("./scripts/guildMemberAdd/logEventToChannel"); const autorole = require("./scripts/guildMemberAdd/autorole"); const welcome = require("./scripts/guildMemberAdd/welcome"); module.exports = { name: "guildMemberAdd", async execute(member) { + await logEventToChannel.sendLogInfo(member); await autorole.assignRole(member); await welcome.sendWelcomeMessage(member); }, diff --git a/events/scripts/guildMemberAdd/logEventToChannel.js b/events/scripts/guildMemberAdd/logEventToChannel.js index 9966320..bbfd5d1 100644 --- a/events/scripts/guildMemberAdd/logEventToChannel.js +++ b/events/scripts/guildMemberAdd/logEventToChannel.js @@ -6,8 +6,8 @@ module.exports = { try { const { doesGuildExist, logChannelId } = await getGuildFromDB(member); - if (existingGuildId) { - const logChannel = oldChannel.guild.channels.cache.get(logChannelId); + if (doesGuildExist) { + const logChannel = member.guild.channels.cache.get(logChannelId); const logEmbed = embedMessageSuccessColor( "Member joined", diff --git a/index.js b/index.js index dcf84f7..90a8f00 100755 --- a/index.js +++ b/index.js @@ -41,7 +41,10 @@ const client = new Client({ Partials.Reaction, Partials.ThreadMember, Partials.User, - ] + ], + // allowedMentions: { + // parse: ["everyone", "roles", "users"], + // }, }); //notifies owner on console if the app is ready From fb46768030286707229a38b6cc1a746680e21ca2 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 27 Oct 2024 22:59:10 +0100 Subject: [PATCH 043/100] added logging voiceStateUpdate events --- .../voiceStateUpdate/logEventToChannel.js | 59 +++++++++++++++++++ events/voiceStateUpdate.js | 14 ++--- 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/events/scripts/voiceStateUpdate/logEventToChannel.js b/events/scripts/voiceStateUpdate/logEventToChannel.js index e69de29..fdbb6e9 100644 --- a/events/scripts/voiceStateUpdate/logEventToChannel.js +++ b/events/scripts/voiceStateUpdate/logEventToChannel.js @@ -0,0 +1,59 @@ +const { getGuildFromDB } = require("../../../helpers/log-data-query"); +const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); + +module.exports = { + async sendLogInfo(oldState, newState) { + try { + const { doesGuildExist, logChannelId } = await getGuildFromDB(oldState); + + + const logEmbed = embedMessageFailureColor( + "Voice state updated", + `${oldState} \n ${newState}.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + + if (doesGuildExist) { + const logChannel = oldState.guild.channels.cache.get(logChannelId); + + const logEmbed = embedMessageFailureColor( + "Voice state updated", + `${oldState} \n ${newState}.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + + if (oldState.voiceChannel !== newState.voiceChannel) { + const logEmbed = embedMessageFailureColor( + "Voice state updated", + `<@${oldState.member.id}> has moved from <#${oldState.voiceChannel}> to <#${newState.voiceChannel}>.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + + if (oldState.selfMute !== newState.selfMute) { + const logEmbed = embedMessageFailureColor( + "Voice state updated", + `<@${oldState.member.id}> has muted themselves in <#${newState.channel.id}>.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + + if (oldState.selfDeaf !== newState.selfDeaf) { + const logEmbed = embedMessageFailureColor( + "Voice state updated", + `<@${oldState.member.id}> has deafened themselves in <#${newState.channel.id}>.`, + ); + + await logChannel.send({ embeds: [logEmbed] }); + } + } + } + catch(error) { + console.error(`Failed to send log info to target channel: ${error}`); + } + } +} \ No newline at end of file diff --git a/events/voiceStateUpdate.js b/events/voiceStateUpdate.js index 361972a..02040a8 100644 --- a/events/voiceStateUpdate.js +++ b/events/voiceStateUpdate.js @@ -1,8 +1,8 @@ -// const messageLogging = require("./scripts/voiceStateUpdate/messageLogging"); +const logEventToChannel = require("./scripts/channelUpdate/logEventToChannel"); -// module.exports = { -// name: "voiceStateUpdate", -// async execute(oldState, newState) { -// await messageLogging.logMessagesToLocalDatabase(oldState, newState); -// }, -// }; \ No newline at end of file +module.exports = { + name: "voiceStateUpdate", + async execute(oldState, newState) { + await logEventToChannel.sendLogInfo(oldState, newState); + }, +}; \ No newline at end of file From c0a4de063a3f77b6ecdc7b9d71b031105fd0b549 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 27 Oct 2024 23:01:12 +0100 Subject: [PATCH 044/100] updated event logging embed colors --- events/scripts/channelPinsUpdate/logEventToChannel.js | 4 ++-- events/scripts/channelUpdate/logEventToChannel.js | 10 +++++----- events/scripts/emojiUpdate/logEventToChannel.js | 4 ++-- events/scripts/messageUpdate/logEventToChannel.js | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/events/scripts/channelPinsUpdate/logEventToChannel.js b/events/scripts/channelPinsUpdate/logEventToChannel.js index 2b2f177..fcf6133 100644 --- a/events/scripts/channelPinsUpdate/logEventToChannel.js +++ b/events/scripts/channelPinsUpdate/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessagePrimaryColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageSuccessSecondaryColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(channel) { @@ -9,7 +9,7 @@ module.exports = { if (doesGuildExist) { const logChannel = channel.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessagePrimaryColor( + const logEmbed = embedMessageSuccessSecondaryColor( "Channel pins updated", `${channel.name} channel pins were updated.`, ); diff --git a/events/scripts/channelUpdate/logEventToChannel.js b/events/scripts/channelUpdate/logEventToChannel.js index 06087c4..cb0811d 100644 --- a/events/scripts/channelUpdate/logEventToChannel.js +++ b/events/scripts/channelUpdate/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageSuccessSecondaryColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(oldChannel, newChannel) { @@ -11,7 +11,7 @@ module.exports = { const changedChannelId = newChannel.id; if (oldChannel.nsfw !== newChannel.nsfw) { - const logEmbed = embedMessageSuccessColor( + const logEmbed = embedMessageSuccessSecondaryColor( "Channel Updated: NSFW status", `Channel NSFW status was changed to "**${newChannel.nsfw ? "NSFW" : "Not NSFW"}**" from "**${oldChannel.nsfw ? "NSFW" : "Not NSFW"}**" in <#${changedChannelId}>.`, ); @@ -20,7 +20,7 @@ module.exports = { } if (oldChannel.name !== newChannel.name) { - const logEmbed = embedMessageSuccessColor( + const logEmbed = embedMessageSuccessSecondaryColor( "Channel Updated: Name", `Channel name was changed to "**${newChannel.name}**" from "**${oldChannel.name}**" in <#${changedChannelId}>.`, ); @@ -29,7 +29,7 @@ module.exports = { } if (oldChannel.topic !== newChannel.topic) { - const logEmbed = embedMessageSuccessColor( + const logEmbed = embedMessageSuccessSecondaryColor( "Channel Updated: Topic", `Channel topic *(description)* was changed to "**${newChannel.topic == "" ? "*empty description*" : newChannel.topic}**" from "**${newChannel.topic == "" ? "*empty description*" : newChannel.topic}**" in <#${changedChannelId}>.`, ); @@ -38,7 +38,7 @@ module.exports = { } if (oldChannel.rateLimitPerUser !== newChannel.rateLimitPerUser) { - const logEmbed = embedMessageSuccessColor( + const logEmbed = embedMessageSuccessSecondaryColor( "Channel Updated: Slowmode", `Channel slowmode was changed to "**${newChannel.rateLimitPerUser}**" seconds from "**${oldChannel.rateLimitPerUser}**" seconds in <#${changedChannelId}>.`, ); diff --git a/events/scripts/emojiUpdate/logEventToChannel.js b/events/scripts/emojiUpdate/logEventToChannel.js index 2a8f8b4..af5dba9 100644 --- a/events/scripts/emojiUpdate/logEventToChannel.js +++ b/events/scripts/emojiUpdate/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageSuccessSecondaryColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(oldEmoji, newEmoji) { @@ -9,7 +9,7 @@ module.exports = { if (doesGuildExist) { const logChannel = oldEmoji.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageSuccessColor( + const logEmbed = embedMessageSuccessSecondaryColor( "Emoji updated", `${oldEmoji.name} emoji was updated.\n\nOld name: ${oldEmoji.name}\nNew name: ${newEmoji.name}`, ); diff --git a/events/scripts/messageUpdate/logEventToChannel.js b/events/scripts/messageUpdate/logEventToChannel.js index ff0ea0e..b7c6377 100644 --- a/events/scripts/messageUpdate/logEventToChannel.js +++ b/events/scripts/messageUpdate/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageWarningColor } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(oldMessage, newMessage) { @@ -9,7 +9,7 @@ module.exports = { if (doesGuildExist) { const logChannel = oldMessage.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageFailureColor( + const logEmbed = embedMessageWarningColor( "Message updated", `Message "**${oldMessage.content}**" from <@${oldMessage.author.id}> has been updated to "**${newMessage.content}**" in <#${oldMessage.channel.id}>.`, ); From cf95ef20d16b0b6b507ce299914347947dd69fc7 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Sun, 27 Oct 2024 23:15:14 +0100 Subject: [PATCH 045/100] added embed message helpers with fields --- helpers/embeds/embed-message.js | 117 +++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/helpers/embeds/embed-message.js b/helpers/embeds/embed-message.js index d71fd43..91bea91 100644 --- a/helpers/embeds/embed-message.js +++ b/helpers/embeds/embed-message.js @@ -98,11 +98,126 @@ function embedMessageWarningColor(title, description) { return embedReply; } +/** + * @param {color} color - Embed's sidebar HEX Color + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {fields} fields - Embed's fields + * @returns {embedReply} An embed message object + */ +function embedMessageWithFields(color, title, description, fields) { + const embedReply = new EmbedBuilder({ + color: parseInt(color), + title: title, + description: description, + fields: fields, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {fields} fields - Embed's fields + * @returns {embedReply} An embed message object + */ +function embedMessagePrimaryColorWithFields(title, description, fields) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.primary), + title: title, + description: description, + fields: fields, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {fields} fields - Embed's fields + * @returns {embedReply} An embed message object + */ +function embedMessageSuccessColorWithFields(title, description, fields) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.success), + title: title, + description: description, + fields: fields, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {fields} fields - Embed's fields + * @returns {embedReply} An embed message object + */ +function embedMessageSuccessSecondaryColorWithFields(title, description, fields) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.successSecondary), + title: title, + description: description, + fields: fields, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {fields} fields - Embed's fields + * @returns {embedReply} An embed message object + */ +function embedMessageFailureColorWithFields(title, description, fields) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.failure), + title: title, + description: description, + fields: fields, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + +/** + * @param {title} title - Embed's title + * @param {description} description - Embed's description + * @param {fields} fields - Embed's fields + * @returns {embedReply} An embed message object + */ +function embedMessageWarningColorWithFields(title, description, fields) { + const embedReply = new EmbedBuilder({ + color: parseInt(embedColors.warning), + title: title, + description: description, + fields: fields, + timestamp: new Date().toISOString() + }); + + return embedReply; +} + module.exports = { embedMessage, embedMessagePrimaryColor, embedMessageSuccessColor, embedMessageSuccessSecondaryColor, embedMessageFailureColor, - embedMessageWarningColor + embedMessageWarningColor, + embedMessageWithFields, + embedMessagePrimaryColorWithFields, + embedMessageSuccessColorWithFields, + embedMessageSuccessSecondaryColorWithFields, + embedMessageFailureColorWithFields, + embedMessageWarningColorWithFields } \ No newline at end of file From 8d0d4a9894f6043961e2c91492695736207700ac Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 28 Oct 2024 21:50:33 +0100 Subject: [PATCH 046/100] added channel type helper, updated channel creation logging --- .../scripts/channelCreate/logEventToChannel.js | 14 +++++++++++--- helpers/channel-types.js | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 helpers/channel-types.js diff --git a/events/scripts/channelCreate/logEventToChannel.js b/events/scripts/channelCreate/logEventToChannel.js index 3086d1d..df002c9 100644 --- a/events/scripts/channelCreate/logEventToChannel.js +++ b/events/scripts/channelCreate/logEventToChannel.js @@ -1,5 +1,6 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); +const { getChannelType } = require("../../../helpers/channel-types"); +const { embedMessageSuccessColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(channel) { @@ -9,9 +10,16 @@ module.exports = { if (doesGuildExist) { const logChannel = channel.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageSuccessColor( + const logEmbed = embedMessageSuccessColorWithFields( "Channel created", - `${channel.name} channel was created.`, + `Channel '<#${channel.id}>' was created.`, + [ + { name: "Name", value: `${channel.name}`, inline: true }, + { name: "Id", value: `${channel.id}`, inline: true }, + { name: "Category", value: `${channel.parent.name}` }, + { name: "Type", value: `${getChannelType(channel)}`, inline: true }, + { name: "NSFW?", value: `${channel.nsfw ? "Yes" : "No"}`, inline: true }, + ] ); await logChannel.send({ embeds: [logEmbed] }); diff --git a/helpers/channel-types.js b/helpers/channel-types.js new file mode 100644 index 0000000..7eee3d0 --- /dev/null +++ b/helpers/channel-types.js @@ -0,0 +1,16 @@ +module.exports = { + getChannelType(channel) { + switch (channel.type) { + case 0: + return "Text"; + case 2: + return "Voice"; + case 15: + return "Forum"; + case 5: + return "Announcement"; + case 13: + return "Stage"; + } + } +} \ No newline at end of file From f7f1e9926957e7c80605868900d30d607f9d5518 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 28 Oct 2024 21:51:28 +0100 Subject: [PATCH 047/100] updated channel delete logging --- events/scripts/channelDelete/logEventToChannel.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/events/scripts/channelDelete/logEventToChannel.js b/events/scripts/channelDelete/logEventToChannel.js index 2bb5a48..5eb0962 100644 --- a/events/scripts/channelDelete/logEventToChannel.js +++ b/events/scripts/channelDelete/logEventToChannel.js @@ -1,5 +1,6 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); +const { getChannelType } = require("../../../helpers/channel-types"); +const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(channel) { @@ -9,9 +10,16 @@ module.exports = { if (doesGuildExist) { const logChannel = channel.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageFailureColor( + const logEmbed = embedMessageFailureColorWithFields( "Channel deleted", - `${channel.name} channel was deleted.`, + `Channel '<#${channel.id}>' was deleted.`, + [ + { name: "Name", value: `${channel.name}`, inline: true }, + { name: "Id", value: `${channel.id}`, inline: true }, + { name: "Category", value: `${channel.parent.name}` }, + { name: "Type", value: `${getChannelType(channel)}`, inline: true }, + { name: "NSFW?", value: `${channel.nsfw ? "Yes" : "No"}`, inline: true }, + ] ); await logChannel.send({ embeds: [logEmbed] }); From 5ad15571ad5e6a94a3063882566e1e6593064a26 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 28 Oct 2024 22:52:12 +0100 Subject: [PATCH 048/100] updated channel pin logging & channel update logging --- .../channelPinsUpdate/logEventToChannel.js | 2 +- .../channelUpdate/logEventToChannel.js | 40 +++++++++++++++---- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/events/scripts/channelPinsUpdate/logEventToChannel.js b/events/scripts/channelPinsUpdate/logEventToChannel.js index fcf6133..fff23fc 100644 --- a/events/scripts/channelPinsUpdate/logEventToChannel.js +++ b/events/scripts/channelPinsUpdate/logEventToChannel.js @@ -11,7 +11,7 @@ module.exports = { const logEmbed = embedMessageSuccessSecondaryColor( "Channel pins updated", - `${channel.name} channel pins were updated.`, + `The channel pins were updated in <#${channel.id}>.`, ); await logChannel.send({ embeds: [logEmbed] }); diff --git a/events/scripts/channelUpdate/logEventToChannel.js b/events/scripts/channelUpdate/logEventToChannel.js index cb0811d..a3a33cb 100644 --- a/events/scripts/channelUpdate/logEventToChannel.js +++ b/events/scripts/channelUpdate/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageSuccessSecondaryColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageSuccessSecondaryColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(oldChannel, newChannel) { @@ -11,36 +11,60 @@ module.exports = { const changedChannelId = newChannel.id; if (oldChannel.nsfw !== newChannel.nsfw) { - const logEmbed = embedMessageSuccessSecondaryColor( + const logEmbed = embedMessageSuccessSecondaryColorWithFields( "Channel Updated: NSFW status", - `Channel NSFW status was changed to "**${newChannel.nsfw ? "NSFW" : "Not NSFW"}**" from "**${oldChannel.nsfw ? "NSFW" : "Not NSFW"}**" in <#${changedChannelId}>.`, + `Channel NSFW status was changed in <#${changedChannelId}>.`, + [ + { name: "Channel name", value: `${newChannel.name}`, inline: true }, + { name: "Channel Id", value: `${changedChannelId}`, inline: true }, + { name: "From", value: `**${oldChannel.nsfw ? "NSFW" : "Not NSFW"}**` }, + { name: "To", value: `**${newChannel.nsfw ? "NSFW" : "Not NSFW"}**` }, + ] ); await logChannel.send({ embeds: [logEmbed] }); } if (oldChannel.name !== newChannel.name) { - const logEmbed = embedMessageSuccessSecondaryColor( + const logEmbed = embedMessageSuccessSecondaryColorWithFields( "Channel Updated: Name", - `Channel name was changed to "**${newChannel.name}**" from "**${oldChannel.name}**" in <#${changedChannelId}>.`, + `Channel name was changed in <#${changedChannelId}>.`, + [ + { name: "Channel name", value: `${newChannel.name}`, inline: true }, + { name: "Channel Id", value: `${changedChannelId}`, inline: true }, + { name: "From", value: `**${oldChannel.name}**` }, + { name: "To", value: `**${newChannel.name}**` }, + ] ); await logChannel.send({ embeds: [logEmbed] }); } if (oldChannel.topic !== newChannel.topic) { - const logEmbed = embedMessageSuccessSecondaryColor( + const logEmbed = embedMessageSuccessSecondaryColorWithFields( "Channel Updated: Topic", - `Channel topic *(description)* was changed to "**${newChannel.topic == "" ? "*empty description*" : newChannel.topic}**" from "**${newChannel.topic == "" ? "*empty description*" : newChannel.topic}**" in <#${changedChannelId}>.`, + `Channel topic *(description)* was changed in <#${changedChannelId}>.`, + [ + { name: "Channel name", value: `${newChannel.name}`, inline: true }, + { name: "Channel Id", value: `${changedChannelId}`, inline: true }, + { name: "From", value: `**${oldChannel.topic == "" ? "*empty description*" : oldChannel.topic}**` }, + { name: "To", value: `**${newChannel.topic == "" ? "*empty description*" : newChannel.topic}**` }, + ] ); await logChannel.send({ embeds: [logEmbed] }); } if (oldChannel.rateLimitPerUser !== newChannel.rateLimitPerUser) { - const logEmbed = embedMessageSuccessSecondaryColor( + const logEmbed = embedMessageSuccessSecondaryColorWithFields( "Channel Updated: Slowmode", `Channel slowmode was changed to "**${newChannel.rateLimitPerUser}**" seconds from "**${oldChannel.rateLimitPerUser}**" seconds in <#${changedChannelId}>.`, + [ + { name: "Channel name", value: `${newChannel.name}`, inline: true }, + { name: "Channel Id", value: `${changedChannelId}`, inline: true }, + { name: "From", value: `**${oldChannel.rateLimitPerUser} seconds**` }, + { name: "To", value: `**${newChannel.rateLimitPerUser} seconds**` }, + ] ); await logChannel.send({ embeds: [logEmbed] }); From 9e1f6afdd697f093c8f8228788ba7f6fd3db8893 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 28 Oct 2024 23:07:33 +0100 Subject: [PATCH 049/100] updated other logging functions --- events/scripts/emojiCreate/logEventToChannel.js | 11 ++++++++--- events/scripts/emojiDelete/logEventToChannel.js | 11 ++++++++--- events/scripts/emojiUpdate/logEventToChannel.js | 12 +++++++++--- events/scripts/guildBanAdd/logEventToChannel.js | 11 ++++++++--- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/events/scripts/emojiCreate/logEventToChannel.js b/events/scripts/emojiCreate/logEventToChannel.js index c1210a6..523499b 100644 --- a/events/scripts/emojiCreate/logEventToChannel.js +++ b/events/scripts/emojiCreate/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageSuccessColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(emoji) { @@ -9,9 +9,14 @@ module.exports = { if (doesGuildExist) { const logChannel = emoji.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageSuccessColor( + const logEmbed = embedMessageSuccessColorWithFields( "Emoji created", - `${emoji.name} emoji was created.`, + `Emoji '<:${emoji.name}:${emoji.id}>' was created.`, + [ + { name: "Emoji name", value: `${emoji.name}` }, + { name: "Emoji Id", value: `${emoji.id}` }, + { name: "Animated?", value: `${emoji.animated ? "Yes" : "No"}` }, + ] ); await logChannel.send({ embeds: [logEmbed] }); diff --git a/events/scripts/emojiDelete/logEventToChannel.js b/events/scripts/emojiDelete/logEventToChannel.js index c55c78b..5c4e99c 100644 --- a/events/scripts/emojiDelete/logEventToChannel.js +++ b/events/scripts/emojiDelete/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(emoji) { @@ -9,9 +9,14 @@ module.exports = { if (doesGuildExist) { const logChannel = emoji.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageFailureColor( + const logEmbed = embedMessageFailureColorWithFields( "Emoji deleted", - `${emoji.name} emoji was deleted.`, + `Emoji '${emoji.name}' was deleted.`, + [ + { name: "Emoji name", value: `${emoji.name}` }, + { name: "Emoji Id", value: `${emoji.id}` }, + { name: "Animated?", value: `${emoji.animated ? "Yes" : "No"}` }, + ] ); await logChannel.send({ embeds: [logEmbed] }); diff --git a/events/scripts/emojiUpdate/logEventToChannel.js b/events/scripts/emojiUpdate/logEventToChannel.js index af5dba9..325f80c 100644 --- a/events/scripts/emojiUpdate/logEventToChannel.js +++ b/events/scripts/emojiUpdate/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageSuccessSecondaryColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageSuccessSecondaryColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(oldEmoji, newEmoji) { @@ -9,9 +9,15 @@ module.exports = { if (doesGuildExist) { const logChannel = oldEmoji.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageSuccessSecondaryColor( + const logEmbed = embedMessageSuccessSecondaryColorWithFields( "Emoji updated", - `${oldEmoji.name} emoji was updated.\n\nOld name: ${oldEmoji.name}\nNew name: ${newEmoji.name}`, + `${oldEmoji.name} emoji was updated.`, + [ + { name: "Emoji Id", value: `${oldEmoji.id}`, inline: true }, + { name: "Animated?", value: `${oldEmoji.animated ? "Yes" : "No"}`, inline: true }, + { name: "Old name", value: `${oldEmoji.name}` }, + { name: "New name", value: `${newEmoji.name}` }, + ] ); await logChannel.send({ embeds: [logEmbed] }); diff --git a/events/scripts/guildBanAdd/logEventToChannel.js b/events/scripts/guildBanAdd/logEventToChannel.js index d3ad418..4306b95 100644 --- a/events/scripts/guildBanAdd/logEventToChannel.js +++ b/events/scripts/guildBanAdd/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(member, reason) { @@ -9,9 +9,14 @@ module.exports = { if (doesGuildExist) { const logChannel = member.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageFailureColor( + const logEmbed = embedMessageFailureColorWithFields( "Member banned", - `${member.user.tag} was banned from the server.\nReason: ${reason}`, + `<@${member.user.id}> was banned from the server.`, + [ + { name: "Username", value: `${member.user.username}`, inline: true }, + { name: "User Id", value: `${member.user.id}`, inline: true }, + { name: "Reason", value: `${reason}` }, + ] ); await logChannel.send({ embeds: [logEmbed] }); From b3d8a09b069db115d854a01d080d34eac0ff3875 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 28 Oct 2024 23:28:35 +0100 Subject: [PATCH 050/100] updated more logging functions --- .../scripts/guildBanRemove/logEventToChannel.js | 12 ++++++++---- .../scripts/guildMemberAdd/logEventToChannel.js | 10 +++++++--- .../guildMemberRemove/logEventToChannel.js | 10 +++++++--- .../scripts/messageDelete/logEventToChannel.js | 15 ++++++++++++--- .../scripts/messageUpdate/logEventToChannel.js | 16 +++++++++++++--- 5 files changed, 47 insertions(+), 16 deletions(-) diff --git a/events/scripts/guildBanRemove/logEventToChannel.js b/events/scripts/guildBanRemove/logEventToChannel.js index 617cf7d..dfa0d97 100644 --- a/events/scripts/guildBanRemove/logEventToChannel.js +++ b/events/scripts/guildBanRemove/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageSuccessColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(member) { @@ -8,10 +8,14 @@ module.exports = { if (doesGuildExist) { const logChannel = member.guild.channels.cache.get(logChannelId); - - const logEmbed = embedMessageSuccessColor( + + const logEmbed = embedMessageFailureColorWithFields( "Member unbanned", - `${member.user.tag} has been unbanned from the server.`, + `<@${member.user.id}> was unbanned from the server.`, + [ + { name: "Username", value: `${member.user.username}` }, + { name: "User Id", value: `${member.user.id}` }, + ] ); await logChannel.send({ embeds: [logEmbed] }); diff --git a/events/scripts/guildMemberAdd/logEventToChannel.js b/events/scripts/guildMemberAdd/logEventToChannel.js index bbfd5d1..f354999 100644 --- a/events/scripts/guildMemberAdd/logEventToChannel.js +++ b/events/scripts/guildMemberAdd/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageSuccessColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageSuccessColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(member) { @@ -9,9 +9,13 @@ module.exports = { if (doesGuildExist) { const logChannel = member.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageSuccessColor( + const logEmbed = embedMessageSuccessColorWithFields( "Member joined", - `${member.user.tag} joined the server.`, + `<@${member.user.id}> joined the server.`, + [ + { name: "Username", value: `${member.user.username}` }, + { name: "User Id", value: `${member.user.id}` }, + ] ); await logChannel.send({ embeds: [logEmbed] }); diff --git a/events/scripts/guildMemberRemove/logEventToChannel.js b/events/scripts/guildMemberRemove/logEventToChannel.js index 8ed5c4e..75b8755 100644 --- a/events/scripts/guildMemberRemove/logEventToChannel.js +++ b/events/scripts/guildMemberRemove/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(member) { @@ -8,10 +8,14 @@ module.exports = { if (doesGuildExist) { const logChannel = member.guild.channels.cache.get(logChannelId); - - const logEmbed = embedMessageFailureColor( + + const logEmbed = embedMessageFailureColorWithFields( "Member left", `<@${member.user.id}> has left the server.`, + [ + { name: "Username", value: `${member.user.username}` }, + { name: "User Id", value: `${member.user.id}` }, + ] ); await logChannel.send({ embeds: [logEmbed] }); diff --git a/events/scripts/messageDelete/logEventToChannel.js b/events/scripts/messageDelete/logEventToChannel.js index c9a93af..4f9e7d8 100644 --- a/events/scripts/messageDelete/logEventToChannel.js +++ b/events/scripts/messageDelete/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(message) { @@ -9,9 +9,18 @@ module.exports = { if (doesGuildExist) { const logChannel = message.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageFailureColor( + const logEmbed = embedMessageFailureColorWithFields( "Message deleted", - `Message "**${message.content}**" from <@${message.author.id}> has been deleted from <#${message.channel.id}>.`, + "A message was deleted.", + [ + { name: "Content", value: `${message.content}` }, + { name: "Channel", value: `<#${message.channel.id}>` }, + { name: "Author", value: `<@${message.author.id}>` }, + { name: "Message Id", value: `${message.id}`, inline: true }, + { name: "Channel Id", value: `${oldMessage.channel.id}`, inline: true }, + { name: "Author Id", value: `${message.author.id}`, inline: true }, + { name: "Author Username", value: `${message.author.username}`, inline: true }, + ] ); await logChannel.send({ embeds: [logEmbed] }); diff --git a/events/scripts/messageUpdate/logEventToChannel.js b/events/scripts/messageUpdate/logEventToChannel.js index b7c6377..d3c4d81 100644 --- a/events/scripts/messageUpdate/logEventToChannel.js +++ b/events/scripts/messageUpdate/logEventToChannel.js @@ -1,5 +1,5 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageWarningColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageWarningColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(oldMessage, newMessage) { @@ -9,9 +9,19 @@ module.exports = { if (doesGuildExist) { const logChannel = oldMessage.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageWarningColor( + const logEmbed = embedMessageWarningColorWithFields( "Message updated", - `Message "**${oldMessage.content}**" from <@${oldMessage.author.id}> has been updated to "**${newMessage.content}**" in <#${oldMessage.channel.id}>.`, + `A message was updated.`, + [ + { name: "From", value: `${oldMessage.content}` }, + { name: "To", value: `${newMessage.content}` }, + { name: "Channel", value: `<#${oldMessage.channel.id}>` }, + { name: "Author", value: `<@${oldMessage.author.id}>` }, + { name: "Message Id", value: `${oldMessage.id}`, inline: true }, + { name: "Channel Id", value: `${oldMessage.channel.id}`, inline: true }, + { name: "Author Id", value: `${oldMessage.author.id}`, inline: true }, + { name: "Author Username", value: `${oldMessage.author.username}`, inline: true }, + ] ); await logChannel.send({ embeds: [logEmbed] }); From f2d063928caae7b3ff9b0934b2b08f97d291fbdf Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 28 Oct 2024 23:47:17 +0100 Subject: [PATCH 051/100] updated voice logging function --- .../voiceStateUpdate/logEventToChannel.js | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/events/scripts/voiceStateUpdate/logEventToChannel.js b/events/scripts/voiceStateUpdate/logEventToChannel.js index fdbb6e9..dadc2dd 100644 --- a/events/scripts/voiceStateUpdate/logEventToChannel.js +++ b/events/scripts/voiceStateUpdate/logEventToChannel.js @@ -1,33 +1,23 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); -const { embedMessageFailureColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessageFailureColor, embedMessageFailureColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendLogInfo(oldState, newState) { try { const { doesGuildExist, logChannelId } = await getGuildFromDB(oldState); - - const logEmbed = embedMessageFailureColor( - "Voice state updated", - `${oldState} \n ${newState}.`, - ); - - await logChannel.send({ embeds: [logEmbed] }); - if (doesGuildExist) { const logChannel = oldState.guild.channels.cache.get(logChannelId); - - const logEmbed = embedMessageFailureColor( - "Voice state updated", - `${oldState} \n ${newState}.`, - ); - - await logChannel.send({ embeds: [logEmbed] }); if (oldState.voiceChannel !== newState.voiceChannel) { - const logEmbed = embedMessageFailureColor( + const logEmbed = embedMessageFailureColorWithFields( "Voice state updated", - `<@${oldState.member.id}> has moved from <#${oldState.voiceChannel}> to <#${newState.voiceChannel}>.`, + `A member has switched channels.`, + [ + { name: "Member", value: `<@${oldState.member.id}>` }, + { name: "From", value: `<#${oldState.channel.id}>`, inline: true }, + { name: "To", value: `<#${newState.channel.id}>`, inline: true }, + ] ); await logChannel.send({ embeds: [logEmbed] }); From 326b9b6716fb99a4938d221afe2ee86721179c29 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Mon, 28 Oct 2024 23:50:08 +0100 Subject: [PATCH 052/100] added content check to messageupdate logging --- .../messageUpdate/logEventToChannel.js | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/events/scripts/messageUpdate/logEventToChannel.js b/events/scripts/messageUpdate/logEventToChannel.js index d3c4d81..2de1599 100644 --- a/events/scripts/messageUpdate/logEventToChannel.js +++ b/events/scripts/messageUpdate/logEventToChannel.js @@ -7,24 +7,26 @@ module.exports = { const { doesGuildExist, logChannelId } = await getGuildFromDB(oldMessage); if (doesGuildExist) { - const logChannel = oldMessage.guild.channels.cache.get(logChannelId); + if (oldMessage.content !== newMessage.content) { + const logChannel = oldMessage.guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageWarningColorWithFields( - "Message updated", - `A message was updated.`, - [ - { name: "From", value: `${oldMessage.content}` }, - { name: "To", value: `${newMessage.content}` }, - { name: "Channel", value: `<#${oldMessage.channel.id}>` }, - { name: "Author", value: `<@${oldMessage.author.id}>` }, - { name: "Message Id", value: `${oldMessage.id}`, inline: true }, - { name: "Channel Id", value: `${oldMessage.channel.id}`, inline: true }, - { name: "Author Id", value: `${oldMessage.author.id}`, inline: true }, - { name: "Author Username", value: `${oldMessage.author.username}`, inline: true }, - ] - ); - - await logChannel.send({ embeds: [logEmbed] }); + const logEmbed = embedMessageWarningColorWithFields( + "Message updated", + `A message was updated.`, + [ + { name: "From", value: `${oldMessage.content}` }, + { name: "To", value: `${newMessage.content}` }, + { name: "Channel", value: `<#${oldMessage.channel.id}>` }, + { name: "Author", value: `<@${oldMessage.author.id}>` }, + { name: "Message Id", value: `${oldMessage.id}`, inline: true }, + { name: "Channel Id", value: `${oldMessage.channel.id}`, inline: true }, + { name: "Author Id", value: `${oldMessage.author.id}`, inline: true }, + { name: "Author Username", value: `${oldMessage.author.username}`, inline: true }, + ] + ); + + await logChannel.send({ embeds: [logEmbed] }); + } } } catch(error) { From 91953ab5d0f0cbb2a2d98b7601b7b3925a8c0437 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Tue, 29 Oct 2024 16:58:27 +0100 Subject: [PATCH 053/100] added logging commands to /help --- commands/utility/help.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands/utility/help.js b/commands/utility/help.js index 188f560..68c158c 100755 --- a/commands/utility/help.js +++ b/commands/utility/help.js @@ -71,6 +71,8 @@ module.exports = { "`/autorole-disable` - Disables the autorole feature. New members won't get the specified role automatically on join anymore.\n" + "`/welcome-configure` - Sets / modifies the welcome messages feature. When a new member joins the server, the bot send a specified welcome message.\n" + "`/welcome-disable` - Disables the welcome messages feature. The bot won't send a welcome message on join anymore.\n" + + "`/logging-configure` - Sets / modifies the channel where event on the server will get logged.\n" + + "`/logging-disable` - Disables the logging feature. The bot won't log the events on the server anymore.\n" + "`/rename` - Renames a specified user to a specified nickname in the current server." }; From c01896a3515e85f0300a7c452aa87736a2c9537b Mon Sep 17 00:00:00 2001 From: vb2007 Date: Tue, 29 Oct 2024 21:54:55 +0100 Subject: [PATCH 054/100] added missing word to security --- SECURITY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SECURITY.md b/SECURITY.md index 10f53c1..682784f 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -17,4 +17,4 @@ I don't maintain any version that's not the latest. You can report a vulnerability on the [repository's security page](https://github.com/vb2007/discordbot/security). -When reporting, please explain the with as much details as possible. \ No newline at end of file +When reporting, please explain the vulnerability with as much details as possible. \ No newline at end of file From 050418ccd0a78487b82edc6399d77fa2e267ceae Mon Sep 17 00:00:00 2001 From: vb2007 Date: Tue, 29 Oct 2024 21:56:11 +0100 Subject: [PATCH 055/100] added /bridge-configure and /bridge-disable commands --- commands/administration/bridge-configure.js | 0 commands/administration/bridge-disable.js | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 commands/administration/bridge-configure.js create mode 100644 commands/administration/bridge-disable.js diff --git a/commands/administration/bridge-configure.js b/commands/administration/bridge-configure.js new file mode 100644 index 0000000..e69de29 diff --git a/commands/administration/bridge-disable.js b/commands/administration/bridge-disable.js new file mode 100644 index 0000000..e69de29 From 36e0e91a031d22908a74ae97f03c138f791a8597 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Tue, 29 Oct 2024 22:01:52 +0100 Subject: [PATCH 056/100] added slash command documentation for /bridge-configure --- commands/administration/bridge-configure.js | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/commands/administration/bridge-configure.js b/commands/administration/bridge-configure.js index e69de29..199850e 100644 --- a/commands/administration/bridge-configure.js +++ b/commands/administration/bridge-configure.js @@ -0,0 +1,28 @@ +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); +const { logToFileAndDatabase } = require("../../helpers/logger"); +const db = require("../../helpers/db"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("bridge-configure") + .setDescription("Sets up bridging between a source channel on another server and a destination channel on the current one.") + .addStringOption(option => + option + .setName("source-channel-id") + .setDescription("The ID of the source channel on another server.") + .setRequired(true) + ) + .addChannelOption(option => + option + .setName("destination-channel") + .setDescription("A channel where the bot will send the bridged messages.") + .addChannelTypes(0) + .setRequired(true) + ) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .setDMPermission(false), + async execute(interaction) { + + } +} \ No newline at end of file From 32bed788b3781f7f205ba19c17ac579b60d1fb3d Mon Sep 17 00:00:00 2001 From: vb2007 Date: Tue, 29 Oct 2024 22:16:33 +0100 Subject: [PATCH 057/100] added slash command documentation for /bridge-disable --- commands/administration/bridge-disable.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/commands/administration/bridge-disable.js b/commands/administration/bridge-disable.js index e69de29..045a77f 100644 --- a/commands/administration/bridge-disable.js +++ b/commands/administration/bridge-disable.js @@ -0,0 +1,21 @@ +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); +const { logToFileAndDatabase } = require("../../helpers/logger"); +const db = require("../../helpers/db"); + +module.exports = { + data: new SlashCommandBuilder() + .setName("bridge-disable") + .setDescription("Disables bridging from a source channel on another server.") + .addStringOption(option => + option + .setName("source-channel-id") + .setDescription("The ID of the source channel you want to disable the briding for on another server.") + .setRequired(true) + ) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .setDMPermission(false), + async execute(interaction) { + + } +} \ No newline at end of file From 89004c1fc5ce4f2df344f27c4f9844e5edeee77e Mon Sep 17 00:00:00 2001 From: vb2007 Date: Tue, 29 Oct 2024 22:26:12 +0100 Subject: [PATCH 058/100] changed autorole table name --- commands/administration/autorole-configure.js | 4 ++-- commands/administration/autorole-disable.js | 4 ++-- events/scripts/guildMemberAdd/autorole.js | 2 +- sql/{autorole => configAutorole}/table.sql | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) rename sql/{autorole => configAutorole}/table.sql (73%) diff --git a/commands/administration/autorole-configure.js b/commands/administration/autorole-configure.js index c23107e..48d892d 100755 --- a/commands/administration/autorole-configure.js +++ b/commands/administration/autorole-configure.js @@ -39,7 +39,7 @@ module.exports = { const adderId = interaction.user.id; const guildId = interaction.guild.id; - const query = await db.query("SELECT guildId, roleId FROM autorole WHERE guildId = ?", [guildId]); + const query = await db.query("SELECT guildId, roleId FROM configAutorole WHERE guildId = ?", [guildId]); const autoRoleGuildId = query[0]?.guildId || null; const autoRoleRoleId = query[0]?.roleId || null; @@ -71,7 +71,7 @@ module.exports = { ); } - 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]); + await db.query("INSERT INTO configAutorole (guildId, roleId, adderId, adderUsername) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE roleId = ?, adderId = ?, adderUsername = ?", [guildId, targetRole, adderId, adderUsername, targetRole, adderId, adderUsername]); } } catch (error) { diff --git a/commands/administration/autorole-disable.js b/commands/administration/autorole-disable.js index 833d49b..980edeb 100755 --- a/commands/administration/autorole-disable.js +++ b/commands/administration/autorole-disable.js @@ -31,11 +31,11 @@ module.exports = { try { const currentGuildId = interaction.guild.id; //we need rows, because the query gives back a messed up array - const query = await db.query("SELECT guildId FROM autorole WHERE guildId = ?", [currentGuildId]); + const query = await db.query("SELECT guildId FROM configAutorole WHERE guildId = ?", [currentGuildId]); const autoroleGuildId = query[0]?.guildId || null; if (autoroleGuildId) { - await db.query("DELETE FROM autorole WHERE guildId = ?", [autoroleGuildId]); + await db.query("DELETE FROM configAutorole WHERE guildId = ?", [autoroleGuildId]); var localEmbedResponse = embedReply( embedColors.success, diff --git a/events/scripts/guildMemberAdd/autorole.js b/events/scripts/guildMemberAdd/autorole.js index bb34afd..4a91530 100644 --- a/events/scripts/guildMemberAdd/autorole.js +++ b/events/scripts/guildMemberAdd/autorole.js @@ -8,7 +8,7 @@ module.exports = { const userTag = member.user.tag; try { - const rows = await db.query("SELECT roleId FROM autorole WHERE guildId = ?", [guildId]); + const rows = await db.query("SELECT roleId FROM configAutorole WHERE guildId = ?", [guildId]); const roleId = rows[0]?.roleId; if (roleId) { diff --git a/sql/autorole/table.sql b/sql/configAutorole/table.sql similarity index 73% rename from sql/autorole/table.sql rename to sql/configAutorole/table.sql index 5f63ba3..c9f168d 100755 --- a/sql/autorole/table.sql +++ b/sql/configAutorole/table.sql @@ -1,6 +1,6 @@ --- discordbot.autorole definition +-- discordbot.configAutorole definition -CREATE TABLE IF NOT EXISTS `autorole` ( +CREATE TABLE IF NOT EXISTS `configAutorole` ( `guildId` varchar(50) NOT NULL, `roleId` text DEFAULT NULL, `addedAt` timestamp NOT NULL DEFAULT current_timestamp(), From 86474dbd6fc14a5124939c7ae7cb0f3f7267d749 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Tue, 29 Oct 2024 22:36:57 +0100 Subject: [PATCH 059/100] updated welcome table name --- commands/administration/welcome-configure.js | 4 ++-- commands/administration/welcome-disable.js | 4 ++-- events/scripts/guildMemberAdd/welcome.js | 2 +- sql/{welcome => configWelcome}/table.sql | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) rename sql/{welcome => configWelcome}/table.sql (80%) diff --git a/commands/administration/welcome-configure.js b/commands/administration/welcome-configure.js index cdab2cd..4251bc5 100644 --- a/commands/administration/welcome-configure.js +++ b/commands/administration/welcome-configure.js @@ -61,7 +61,7 @@ module.exports = { const adderId = interaction.user.id; const adderUsername = interaction.user.username; - const query = await db.query("SELECT channelId, message, isEmbed, embedColor FROM welcome WHERE guildId = ?", [guildId]); + const query = await db.query("SELECT channelId, message, isEmbed, embedColor FROM configWelcome WHERE guildId = ?", [guildId]); const existingChannelId = query[0]?.channelId || null; const existingWelcomeMessage = query[0]?.message || null; const existingIsEmbed = query[0]?.isEmbed || 0; @@ -116,7 +116,7 @@ module.exports = { } } - await db.query("INSERT INTO welcome (guildId, channelId, message, isEmbed, embedColor, adderId, adderUsername) VALUES (?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE channelId = ?, message = ?, adderId = ?, adderUsername = ?, isEmbed = ?, embedColor = ?", + await db.query("INSERT INTO configWelcome (guildId, channelId, message, isEmbed, embedColor, adderId, adderUsername) VALUES (?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE channelId = ?, message = ?, adderId = ?, adderUsername = ?, isEmbed = ?, embedColor = ?", [guildId, channelId, welcomeMessage, isEmbed, embedColor, adderId, adderUsername, channelId, welcomeMessage, adderId, adderUsername, isEmbed, embedColor] ); } diff --git a/commands/administration/welcome-disable.js b/commands/administration/welcome-disable.js index 923b46a..d97bae4 100644 --- a/commands/administration/welcome-disable.js +++ b/commands/administration/welcome-disable.js @@ -27,11 +27,11 @@ module.exports = { else { try { const currentGuildId = interaction.guild.id; - const query = await db.query("SELECT guildId FROM welcome WHERE guildId = ?", [currentGuildId]); + const query = await db.query("SELECT guildId FROM configWelcome WHERE guildId = ?", [currentGuildId]); const welcomeGuildId = query[0]?.guildId || null; if (welcomeGuildId) { - await db.query("DELETE FROM welcome WHERE guildId = ?", [welcomeGuildId]); + await db.query("DELETE FROM configWelcome WHERE guildId = ?", [welcomeGuildId]); var embedReply = embedReplySuccessColor( "Welcome Disable: Success", diff --git a/events/scripts/guildMemberAdd/welcome.js b/events/scripts/guildMemberAdd/welcome.js index ace5d86..345816f 100644 --- a/events/scripts/guildMemberAdd/welcome.js +++ b/events/scripts/guildMemberAdd/welcome.js @@ -11,7 +11,7 @@ module.exports = { const userId = member.user.id; try { - const rows = await db.query("SELECT channelId, message, isEmbed, embedColor FROM welcome WHERE guildId = ?", [guildId]); + const rows = await db.query("SELECT channelId, message, isEmbed, embedColor FROM configWelcome WHERE guildId = ?", [guildId]); const channelId = rows[0]?.channelId; let message = rows[0]?.message; const isEmbed = rows[0]?.isEmbed; diff --git a/sql/welcome/table.sql b/sql/configWelcome/table.sql similarity index 80% rename from sql/welcome/table.sql rename to sql/configWelcome/table.sql index 7ab889f..1df333b 100644 --- a/sql/welcome/table.sql +++ b/sql/configWelcome/table.sql @@ -1,6 +1,6 @@ --- discordbot.welcome definition +-- discordbot.configWelcome definition -CREATE TABLE IF NOT EXISTS `welcome` ( +CREATE TABLE IF NOT EXISTS `configWelcome` ( `guildId` varchar(50) NOT NULL, `channelId` text DEFAULT NULL, `message` text DEFAULT NULL, From f579c6c9b43501dbaa2f26cac507aa0ca913ac9b Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 30 Oct 2024 10:46:49 +0100 Subject: [PATCH 060/100] added some action handling to /bridge-configure --- commands/administration/bridge-configure.js | 36 ++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/commands/administration/bridge-configure.js b/commands/administration/bridge-configure.js index 199850e..fa8a931 100644 --- a/commands/administration/bridge-configure.js +++ b/commands/administration/bridge-configure.js @@ -23,6 +23,40 @@ module.exports = { .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) .setDMPermission(false), async execute(interaction) { - + if (!interaction.inGuild()) { + var embedReply = embedReplyFailureColor( + "Bridge Configure: Error", + "You can only set up bridging in a server.", + interaction + ); + } + else { + try { + const sourceChannelId = interaction.options.getString("source-channel-id"); + const targetChannel = interaction.options.getChannel("destination-channel"); + + const interactionUserId = interaction.user.id; + const interactionUsername = interaction.user.username; + const targetChannelId = targetChannel.id; + const targetChannelName = targetChannel.name; + const guildId = interaction.guild.id; + + const query = await db.query("SELECT guildId, sourceChannelId, destinationChannelId FROM configBridging WHERE sourceChannelId = ?", [sourceChannelId]); + } + catch (error) { + console.error(`Failed to configure bridging: ${error}`); + var embedReply = embedReplyFailureColor( + "Bridge Configure: Error", + "Failed to configure bridging. Please try again.", + interaction + ); + } + } + + await interaction.reply({ embeds: [embedReply] }); + + //logging + const response = JSON.stringify(embedReply.toJSON()); + await logToFileAndDatabase(interaction, response); } } \ No newline at end of file From cfe375e3759ba78fbb9867fd4d881f4f433abf4c Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 30 Oct 2024 10:54:34 +0100 Subject: [PATCH 061/100] added configBridge table --- sql/configBridge/table.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 sql/configBridge/table.sql diff --git a/sql/configBridge/table.sql b/sql/configBridge/table.sql new file mode 100644 index 0000000..e57cc0a --- /dev/null +++ b/sql/configBridge/table.sql @@ -0,0 +1,17 @@ +-- discordbot.configBridge definition + +CREATE TABLE IF NOT EXISTS `configBridge` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `sourceChannelId` varchar(50) NOT NULL, + `destinationGuildId` varchar(50) NOT NULL, + `destinationGuildName` varchar(50) NOT NULL, + `destinationChannelId` varchar(50) NOT NULL, + `destinationChannelName` varchar(50) NOT NULL, + `modifiedAt` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `modifierId` varchar(50) DEFAULT NULL, + `modifierUsername` varchar(50) DEFAULT NULL, + `addedAt` timestamp NOT NULL DEFAULT current_timestamp(), + `adderId` varchar(50) DEFAULT NULL, + `adderUsername` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`) +); \ No newline at end of file From 088f34c9143ff9b054e1dc02af98a95181e5d2e6 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 30 Oct 2024 10:57:52 +0100 Subject: [PATCH 062/100] updated modifiedAt column defaults --- sql/configBridge/table.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/configBridge/table.sql b/sql/configBridge/table.sql index e57cc0a..b9d1431 100644 --- a/sql/configBridge/table.sql +++ b/sql/configBridge/table.sql @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS `configBridge` ( `destinationGuildName` varchar(50) NOT NULL, `destinationChannelId` varchar(50) NOT NULL, `destinationChannelName` varchar(50) NOT NULL, - `modifiedAt` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `modifiedAt` timestamp DEFAULT NULL ON UPDATE current_timestamp(), `modifierId` varchar(50) DEFAULT NULL, `modifierUsername` varchar(50) DEFAULT NULL, `addedAt` timestamp NOT NULL DEFAULT current_timestamp(), From 4db051bb98520cb9e071f5f43bf4690b54b9af40 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 30 Oct 2024 11:32:30 +0100 Subject: [PATCH 063/100] added first insert query --- commands/administration/bridge-configure.js | 32 ++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/commands/administration/bridge-configure.js b/commands/administration/bridge-configure.js index fa8a931..ad2a570 100644 --- a/commands/administration/bridge-configure.js +++ b/commands/administration/bridge-configure.js @@ -35,13 +35,37 @@ module.exports = { const sourceChannelId = interaction.options.getString("source-channel-id"); const targetChannel = interaction.options.getChannel("destination-channel"); - const interactionUserId = interaction.user.id; - const interactionUsername = interaction.user.username; + const guildId = interaction.guild.id; + const guildName = interaction.guild.name; const targetChannelId = targetChannel.id; const targetChannelName = targetChannel.name; - const guildId = interaction.guild.id; + const interactionUserId = interaction.user.id; + const interactionUsername = interaction.user.username; + + const query = await db.query("SELECT sourceChannelId, destinationChannelId FROM configBridging WHERE sourceChannelId = ? AND destinationChannelId = ?", [sourceChannelId, targetChannelId]); + const existingSourceChannelId = query[0]?.sourceChannelId || null; + const existingDestinationChannelId = query[0]?.destinationChannelId || null; - const query = await db.query("SELECT guildId, sourceChannelId, destinationChannelId FROM configBridging WHERE sourceChannelId = ?", [sourceChannelId]); + if (existingSourceChannelId == sourceChannelId && existingDestinationChannelId == targetChannelId) { + var embedReply = embedReplyFailureColor( + "Bridge Configure: Error", + `Bridging has already been configured for the channel <#\`${sourceChannelId}\`> (\`${sourceChannelId}\`). :x:\n`, + interaction + ); + } + else { + await db.query("INSERT INTO configBridging (sourceChannelId, destinationGuildId, destinationGuildName, destinationChannelId, destinationChannelName, adderId, adderUsername) VALUES (?, ?, ?, ?, ?, ?, ?)", + [ + sourceChannelId, + guildId, + guildName, + targetChannelId, + targetChannelName, + interactionUserId, + interactionUsername + ] + ); + } } catch (error) { console.error(`Failed to configure bridging: ${error}`); From e10eb2702f6841404f0182eac0b2a5dbc81bff78 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 30 Oct 2024 11:40:31 +0100 Subject: [PATCH 064/100] added successful config case to /bridge-configure --- commands/administration/bridge-configure.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/commands/administration/bridge-configure.js b/commands/administration/bridge-configure.js index ad2a570..483b3b5 100644 --- a/commands/administration/bridge-configure.js +++ b/commands/administration/bridge-configure.js @@ -49,11 +49,16 @@ module.exports = { if (existingSourceChannelId == sourceChannelId && existingDestinationChannelId == targetChannelId) { var embedReply = embedReplyFailureColor( "Bridge Configure: Error", - `Bridging has already been configured for the channel <#\`${sourceChannelId}\`> (\`${sourceChannelId}\`). :x:\n`, + `Bridging has already been configured for the channel <#${sourceChannelId}> (\`${sourceChannelId}\`). :x:\n`, interaction ); } else { + var embedReply = embedReplySuccessColor( + "Bridge Configure: Success", + `Bridging has been successfully configured. :white_check_mark:\nMessages from <#${sourceChannelId}> (\`${sourceChannelId}\`) will now get bridged to <#${targetChannelId}>.`, + ); + await db.query("INSERT INTO configBridging (sourceChannelId, destinationGuildId, destinationGuildName, destinationChannelId, destinationChannelName, adderId, adderUsername) VALUES (?, ?, ?, ?, ?, ?, ?)", [ sourceChannelId, @@ -68,7 +73,7 @@ module.exports = { } } catch (error) { - console.error(`Failed to configure bridging: ${error}`); + // console.error(`Failed to configure bridging: ${error}`); var embedReply = embedReplyFailureColor( "Bridge Configure: Error", "Failed to configure bridging. Please try again.", From 1596fc03a7f59cf68ed492cdd6ae4592957cef7b Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 30 Oct 2024 17:28:18 +0100 Subject: [PATCH 065/100] added another column to the query --- commands/administration/bridge-configure.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands/administration/bridge-configure.js b/commands/administration/bridge-configure.js index 483b3b5..2115595 100644 --- a/commands/administration/bridge-configure.js +++ b/commands/administration/bridge-configure.js @@ -42,7 +42,8 @@ module.exports = { const interactionUserId = interaction.user.id; const interactionUsername = interaction.user.username; - const query = await db.query("SELECT sourceChannelId, destinationChannelId FROM configBridging WHERE sourceChannelId = ? AND destinationChannelId = ?", [sourceChannelId, targetChannelId]); + const query = await db.query("SELECT destinationChannelId, sourceChannelId, destinationGuildId FROM configBridging WHERE sourceChannelId = ? AND destinationChannelId = ?", [sourceChannelId, targetChannelId]); + const destinationGuildId = query[0]?.destinationGuildId || null; const existingSourceChannelId = query[0]?.sourceChannelId || null; const existingDestinationChannelId = query[0]?.destinationChannelId || null; From df3ce40e833309b867957bbad4fb7309c0a99833 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 30 Oct 2024 18:11:14 +0100 Subject: [PATCH 066/100] updated /bridge-configure with relevant checks and db updates --- commands/administration/bridge-configure.js | 53 +++++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/commands/administration/bridge-configure.js b/commands/administration/bridge-configure.js index 2115595..cf6be8e 100644 --- a/commands/administration/bridge-configure.js +++ b/commands/administration/bridge-configure.js @@ -1,5 +1,5 @@ const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); -const { embedReplySuccessColor, embedReplyFailureColor } = require("../../helpers/embeds/embed-reply"); +const { embedReplySuccessColor, embedReplyFailureColor, embedReplySuccessSecondaryColor } = require("../../helpers/embeds/embed-reply"); const { logToFileAndDatabase } = require("../../helpers/logger"); const db = require("../../helpers/db"); @@ -33,31 +33,66 @@ module.exports = { else { try { const sourceChannelId = interaction.options.getString("source-channel-id"); - const targetChannel = interaction.options.getChannel("destination-channel"); + const destinationChannel = interaction.options.getChannel("destination-channel"); const guildId = interaction.guild.id; const guildName = interaction.guild.name; - const targetChannelId = targetChannel.id; - const targetChannelName = targetChannel.name; + const destinationChannelId = destinationChannel.id; + const destinationChannelName = destinationChannel.name; const interactionUserId = interaction.user.id; const interactionUsername = interaction.user.username; - const query = await db.query("SELECT destinationChannelId, sourceChannelId, destinationGuildId FROM configBridging WHERE sourceChannelId = ? AND destinationChannelId = ?", [sourceChannelId, targetChannelId]); + const query = await db.query("SELECT destinationChannelId, sourceChannelId, destinationGuildId FROM configBridging WHERE sourceChannelId = ? AND destinationChannelId = ?", [sourceChannelId, destinationChannelId]); const destinationGuildId = query[0]?.destinationGuildId || null; const existingSourceChannelId = query[0]?.sourceChannelId || null; const existingDestinationChannelId = query[0]?.destinationChannelId || null; - if (existingSourceChannelId == sourceChannelId && existingDestinationChannelId == targetChannelId) { + if (existingSourceChannelId == sourceChannelId && existingDestinationChannelId == destinationChannelId && destinationGuildId == guildId) { var embedReply = embedReplyFailureColor( "Bridge Configure: Error", `Bridging has already been configured for the channel <#${sourceChannelId}> (\`${sourceChannelId}\`). :x:\n`, interaction ); } + else if (existingSourceChannelId == sourceChannelId && destinationGuildId == guildId) { + var embedReply = embedReplySuccessSecondaryColor( + "Bridge Configure: Configuration Modified", + `The destination channel for <#${sourceChannelId}> (\`${sourceChannelId}\`) has been updated to <#${destinationChannelId}>. :white_check_mark:\nRun this command again to modify the channel.`, + ); + + await db.query("UPDATE configBridging SET destinationChannelId = ?, destinationChannelName = ?, adderId = ?, adderUsername = ? WHERE sourceChannelId = ? AND destinationChannelId = ?", + [ + destinationChannelId, + destinationChannelName, + interactionUserId, + interactionUsername, + sourceChannelId, + destinationChannelId + ] + ); + } + else if (existingSourceChannelId != sourceChannelId && destinationGuildId == guildId) { + var embedReply = embedReplySuccessColor( + "Bridge Configure: Success", + `Another channel has been added to bridging successfully. :white_check_mark:\nMessages from <#${sourceChannelId}> (\`${sourceChannelId}\`) will now get bridged to <#${destinationChannelId}>.`, + ); + + await db.query("INSERT INTO configBridging (sourceChannelId, destinationGuildId, destinationGuildName, destinationChannelId, destinationChannelName, adderId, adderUsername) VALUES (?, ?, ?, ?, ?, ?, ?)", + [ + sourceChannelId, + guildId, + guildName, + destinationChannelId, + destinationChannelName, + interactionUserId, + interactionUsername + ] + ); + } else { var embedReply = embedReplySuccessColor( "Bridge Configure: Success", - `Bridging has been successfully configured. :white_check_mark:\nMessages from <#${sourceChannelId}> (\`${sourceChannelId}\`) will now get bridged to <#${targetChannelId}>.`, + `Bridging has been successfully configured. :white_check_mark:\nMessages from <#${sourceChannelId}> (\`${sourceChannelId}\`) will now get bridged to <#${destinationChannelId}>.`, ); await db.query("INSERT INTO configBridging (sourceChannelId, destinationGuildId, destinationGuildName, destinationChannelId, destinationChannelName, adderId, adderUsername) VALUES (?, ?, ?, ?, ?, ?, ?)", @@ -65,8 +100,8 @@ module.exports = { sourceChannelId, guildId, guildName, - targetChannelId, - targetChannelName, + destinationChannelId, + destinationChannelName, interactionUserId, interactionUsername ] From 9a08f0441322119cbb8f5e788749f1619a0f3880 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Wed, 30 Oct 2024 22:52:52 +0100 Subject: [PATCH 067/100] whitespace fix --- commands/fun/911-countdown.js | 2 +- commands/fun/randomfeet.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/fun/911-countdown.js b/commands/fun/911-countdown.js index 3890ec2..18947f9 100644 --- a/commands/fun/911-countdown.js +++ b/commands/fun/911-countdown.js @@ -114,7 +114,7 @@ module.exports = { } } - await interaction.reply({ embeds: [embedReply] });4 + await interaction.reply({ embeds: [embedReply] }); //logging const response = JSON.stringify(embedReply.toJSON()); diff --git a/commands/fun/randomfeet.js b/commands/fun/randomfeet.js index d6f3a35..1950807 100755 --- a/commands/fun/randomfeet.js +++ b/commands/fun/randomfeet.js @@ -70,7 +70,7 @@ module.exports = { interaction ); } - else{ + else { var embedReply = embedReplyPrimaryColorImg( "Randomfeet.", "Here is a random feetpic:", From 262e9c88ca92064115e8ef2d79be557e349abb85 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 31 Oct 2024 10:19:39 +0100 Subject: [PATCH 068/100] added base concept for /bridge-disable --- commands/administration/bridge-disable.js | 42 +++++++++++++++++++++- commands/administration/logging-disable.js | 2 +- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/commands/administration/bridge-disable.js b/commands/administration/bridge-disable.js index 045a77f..c998430 100644 --- a/commands/administration/bridge-disable.js +++ b/commands/administration/bridge-disable.js @@ -16,6 +16,46 @@ module.exports = { .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) .setDMPermission(false), async execute(interaction) { - + if (!interaction.inGuild()) { + var embedReply = embedReplyFailureColor( + "Bridge Disable: Error", + "You can only disable bridging in a server.", + interaction + ); + } + else { + try { + const sourceChannelId = interaction.options.getString("source-channel-id"); + const guildId = interaction.guild.id; + + const query = await db.query("SELECT sourceChannelId FROM configBridging WHERE sourceChannelId = ? AND destinationGuildId = ?", [sourceChannelId, guildId]); + const existingGuildId = query[0]?.guildId || null; + const existingSourceChannelId = query[0]?.sourceChannelId || null; + + if (existingSourceChannelId && existingGuildId) { + await db.query("DELETE FROM configBridging WHERE sourceChannelId = ? AND destinationGuildId = ?", [sourceChannelId, guildId]); + var embedReply = embedReplySuccessColor( + "Bridge Disable: Success", + `Bridging has been disabled for the channel <#${sourceChannelId}> (\`${sourceChannelId}\`). :white_check_mark:\nYou can re-enable this feature with \`/bridge-configure\`.`, + interaction + ); + } + else { + var embedReply = embedReplyFailureColor( + "Bridge Disable: Error", + `Bridging has not been configured for the channel <#${sourceChannelId}> (\`${sourceChannelId}\`). :x:\nTherefore, you can't disable it.\nYou can enable this feature with \`/bridge-configure\`.`, + interaction + ); + } + } + catch (error) { + console.error(`Error while disabling bridging: ${error}`); + var embedReply = embedReplyFailureColor( + "Bridge Disable: Error", + "An error occurred while disabling the bridging feature.\nPlease try again.", + interaction + ); + } + } } } \ No newline at end of file diff --git a/commands/administration/logging-disable.js b/commands/administration/logging-disable.js index 63b8c41..80e5bdf 100644 --- a/commands/administration/logging-disable.js +++ b/commands/administration/logging-disable.js @@ -50,7 +50,7 @@ module.exports = { console.error(`Error while disabling logging: ${error}`); var embedReply = embedReplyFailureColor( "Logging Disable: Error", - "An error occurred while disabling the logging feature.", + "An error occurred while disabling the logging feature.\nPlease try again.", interaction ); } From fc35940ea36258809546bb50d59d69886cba2714 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 31 Oct 2024 10:31:14 +0100 Subject: [PATCH 069/100] fixed command desc length --- commands/administration/bridge-configure.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/administration/bridge-configure.js b/commands/administration/bridge-configure.js index cf6be8e..31fe9ac 100644 --- a/commands/administration/bridge-configure.js +++ b/commands/administration/bridge-configure.js @@ -6,7 +6,7 @@ const db = require("../../helpers/db"); module.exports = { data: new SlashCommandBuilder() .setName("bridge-configure") - .setDescription("Sets up bridging between a source channel on another server and a destination channel on the current one.") + .setDescription("Sets up bridging between a source channel on another server and a destination channel.") //...on the current one. [discord character limit] .addStringOption(option => option .setName("source-channel-id") From 4e7dad1ac63ec996bd69969ae70a0b16c5b3f843 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 31 Oct 2024 11:31:20 +0100 Subject: [PATCH 070/100] fixed table name --- sql/configBridge/table.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/configBridge/table.sql b/sql/configBridge/table.sql index b9d1431..40f975a 100644 --- a/sql/configBridge/table.sql +++ b/sql/configBridge/table.sql @@ -1,6 +1,6 @@ -- discordbot.configBridge definition -CREATE TABLE IF NOT EXISTS `configBridge` ( +CREATE TABLE IF NOT EXISTS `configBridging` ( `id` bigint NOT NULL AUTO_INCREMENT, `sourceChannelId` varchar(50) NOT NULL, `destinationGuildId` varchar(50) NOT NULL, From 6405f1a3bc811e66341c5a821f5aa21beefe3ba4 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 31 Oct 2024 11:31:37 +0100 Subject: [PATCH 071/100] fixed other typos in configure / disable commands --- commands/administration/bridge-configure.js | 3 ++- commands/administration/bridge-disable.js | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/commands/administration/bridge-configure.js b/commands/administration/bridge-configure.js index 31fe9ac..c00d14f 100644 --- a/commands/administration/bridge-configure.js +++ b/commands/administration/bridge-configure.js @@ -93,6 +93,7 @@ module.exports = { var embedReply = embedReplySuccessColor( "Bridge Configure: Success", `Bridging has been successfully configured. :white_check_mark:\nMessages from <#${sourceChannelId}> (\`${sourceChannelId}\`) will now get bridged to <#${destinationChannelId}>.`, + interaction ); await db.query("INSERT INTO configBridging (sourceChannelId, destinationGuildId, destinationGuildName, destinationChannelId, destinationChannelName, adderId, adderUsername) VALUES (?, ?, ?, ?, ?, ?, ?)", @@ -109,7 +110,7 @@ module.exports = { } } catch (error) { - // console.error(`Failed to configure bridging: ${error}`); + console.error(`Failed to configure bridging: ${error.message}\n${error.stack}`); var embedReply = embedReplyFailureColor( "Bridge Configure: Error", "Failed to configure bridging. Please try again.", diff --git a/commands/administration/bridge-disable.js b/commands/administration/bridge-disable.js index c998430..65e12ea 100644 --- a/commands/administration/bridge-disable.js +++ b/commands/administration/bridge-disable.js @@ -28,9 +28,10 @@ module.exports = { const sourceChannelId = interaction.options.getString("source-channel-id"); const guildId = interaction.guild.id; - const query = await db.query("SELECT sourceChannelId FROM configBridging WHERE sourceChannelId = ? AND destinationGuildId = ?", [sourceChannelId, guildId]); - const existingGuildId = query[0]?.guildId || null; + const query = await db.query("SELECT sourceChannelId, destinationGuildId FROM configBridging WHERE sourceChannelId = ? AND destinationGuildId = ?", [sourceChannelId, guildId]); + const existingGuildId = query[0]?.destinationGuildId || null; const existingSourceChannelId = query[0]?.sourceChannelId || null; + console.log(existingGuildId, existingSourceChannelId); if (existingSourceChannelId && existingGuildId) { await db.query("DELETE FROM configBridging WHERE sourceChannelId = ? AND destinationGuildId = ?", [sourceChannelId, guildId]); @@ -57,5 +58,7 @@ module.exports = { ); } } + + await interaction.reply({ embeds: [embedReply] }); } } \ No newline at end of file From cc864aec8d09622374f321ee6f6ef1b225cb2dc2 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 31 Oct 2024 11:59:42 +0100 Subject: [PATCH 072/100] added bridge event script --- events/scripts/messageCreate/bridge.js | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 events/scripts/messageCreate/bridge.js diff --git a/events/scripts/messageCreate/bridge.js b/events/scripts/messageCreate/bridge.js new file mode 100644 index 0000000..4a7eeb4 --- /dev/null +++ b/events/scripts/messageCreate/bridge.js @@ -0,0 +1,32 @@ +const db = require("../../../helpers/db"); +const { embedMessagePrimaryColor } = require("../../../helpers/embeds/embed-message"); +const { client } = require("../../../index"); + +module.exports = { + async sendMessageToDestinationChannel(message) { + // const serverId = message.guild.id; + // const channelId = message.channel.id; + const messageContent = message.content; + const senderUserName = message.author.username; + const senderUserId = message.author.id; + const serverName = message.guild.name; + // const channelName = message.channel.name; + + try { + const query = await db.query("SELECT sourceChannelId, destinationChannelId, destinationGuildId FROM configBridging"); + const sourceChannelId = query[0]?.sourceChannelId || null; + const destinationChannelId = query[0]?.destinationChannelId || null; + const destinationGuildId = query[0]?.destinationGuildId || null; + + if (sourceChannelId == message.channel.id) { + const destinationGuild = await client.guilds.fetch(destinationGuildId); + const destinationChannel = await destinationGuild.channels.cache.get(destinationChannelId); + + await destinationChannel.send("lol"); + } + } + catch (error) { + console.error(`Failed to bridge message: ${error}`); + } + } +} \ No newline at end of file From 2c47e688681a776605860162bb7c74a1eae8d81a Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 31 Oct 2024 12:00:23 +0100 Subject: [PATCH 073/100] added script to messageCreate event --- events/messageCreate.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/events/messageCreate.js b/events/messageCreate.js index 2c39c44..81597fb 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -1,8 +1,10 @@ const messageLogging = require("./scripts/messageCreate/messageLogging"); +const bridge = require("./scripts/messageCreate/bridge"); module.exports = { name: "messageCreate", async execute(message) { await messageLogging.logMessagesToLocalDatabase(message); + await bridge.sendMessageToDestinationChannel(message); }, }; \ No newline at end of file From 7b9c958d79f62dbbf150361dfeb9bddaa5a60680 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 31 Oct 2024 12:11:54 +0100 Subject: [PATCH 074/100] added client instance for fetching channel id on messagecreate event --- events/messageCreate.js | 4 ++-- events/scripts/messageCreate/bridge.js | 7 +++---- index.js | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/events/messageCreate.js b/events/messageCreate.js index 81597fb..e1f5c09 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -3,8 +3,8 @@ const bridge = require("./scripts/messageCreate/bridge"); module.exports = { name: "messageCreate", - async execute(message) { + async execute(client, message) { await messageLogging.logMessagesToLocalDatabase(message); - await bridge.sendMessageToDestinationChannel(message); + await bridge.sendMessageToDestinationChannel(client, message); }, }; \ No newline at end of file diff --git a/events/scripts/messageCreate/bridge.js b/events/scripts/messageCreate/bridge.js index 4a7eeb4..2f3816b 100644 --- a/events/scripts/messageCreate/bridge.js +++ b/events/scripts/messageCreate/bridge.js @@ -1,9 +1,8 @@ const db = require("../../../helpers/db"); const { embedMessagePrimaryColor } = require("../../../helpers/embeds/embed-message"); -const { client } = require("../../../index"); module.exports = { - async sendMessageToDestinationChannel(message) { + async sendMessageToDestinationChannel(client, message) { // const serverId = message.guild.id; // const channelId = message.channel.id; const messageContent = message.content; @@ -19,8 +18,8 @@ module.exports = { const destinationGuildId = query[0]?.destinationGuildId || null; if (sourceChannelId == message.channel.id) { - const destinationGuild = await client.guilds.fetch(destinationGuildId); - const destinationChannel = await destinationGuild.channels.cache.get(destinationChannelId); + const destinationChannel = await client.channels.fetch(destinationChannelId); + // const destinationChannel = await destinationGuild.channels.cache.get(destinationChannelId); await destinationChannel.send("lol"); } diff --git a/index.js b/index.js index 90a8f00..2709ce2 100755 --- a/index.js +++ b/index.js @@ -86,10 +86,10 @@ for (const file of eventFiles) { const event = require(filePath); if (event.once) { - client.once(event.name, (...args) => event.execute(...args)); + client.once(event.name, (...args) => event.execute(client, ...args)); } else { - client.on(event.name, (...args) => event.execute(...args)); + client.on(event.name, (...args) => event.execute(client, ...args)); } } From 1572b4954db9af0015863b8a0ff8d713ced4fe28 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 31 Oct 2024 12:12:16 +0100 Subject: [PATCH 075/100] removed logging --- commands/administration/bridge-disable.js | 1 - 1 file changed, 1 deletion(-) diff --git a/commands/administration/bridge-disable.js b/commands/administration/bridge-disable.js index 65e12ea..577ac29 100644 --- a/commands/administration/bridge-disable.js +++ b/commands/administration/bridge-disable.js @@ -31,7 +31,6 @@ module.exports = { const query = await db.query("SELECT sourceChannelId, destinationGuildId FROM configBridging WHERE sourceChannelId = ? AND destinationGuildId = ?", [sourceChannelId, guildId]); const existingGuildId = query[0]?.destinationGuildId || null; const existingSourceChannelId = query[0]?.sourceChannelId || null; - console.log(existingGuildId, existingSourceChannelId); if (existingSourceChannelId && existingGuildId) { await db.query("DELETE FROM configBridging WHERE sourceChannelId = ? AND destinationGuildId = ?", [sourceChannelId, guildId]); From e612476c39b9151e29890c24caab9f5a9b08412e Mon Sep 17 00:00:00 2001 From: vb2007 Date: Thu, 31 Oct 2024 13:24:00 +0100 Subject: [PATCH 076/100] added normal embed message to the bridge event script --- events/scripts/messageCreate/bridge.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/events/scripts/messageCreate/bridge.js b/events/scripts/messageCreate/bridge.js index 2f3816b..4eb4f5e 100644 --- a/events/scripts/messageCreate/bridge.js +++ b/events/scripts/messageCreate/bridge.js @@ -1,10 +1,10 @@ const db = require("../../../helpers/db"); -const { embedMessagePrimaryColor } = require("../../../helpers/embeds/embed-message"); +const { embedMessagePrimaryColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { async sendMessageToDestinationChannel(client, message) { // const serverId = message.guild.id; - // const channelId = message.channel.id; + const channelId = message.channel.id; const messageContent = message.content; const senderUserName = message.author.username; const senderUserId = message.author.id; @@ -21,7 +21,17 @@ module.exports = { const destinationChannel = await client.channels.fetch(destinationChannelId); // const destinationChannel = await destinationGuild.channels.cache.get(destinationChannelId); - await destinationChannel.send("lol"); + const embedMessage = embedMessagePrimaryColorWithFields( + "Bridged Message", + `Message successfully bridged from <#${channelId}>.`, + [ + { name: "Sender username", value: senderUserName, inline: true }, + { name: "Server name", value: serverName, inline: true }, + { name: "Message", value: messageContent } + ] + ); + + await destinationChannel.send({ embeds: [embedMessage] }); } } catch (error) { From 450f4b6d3418c3066398ec7ff221cdb11e21ffa4 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Tue, 12 Nov 2024 18:00:18 +0100 Subject: [PATCH 077/100] fixed function name --- commands/economy/work.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/economy/work.js b/commands/economy/work.js index c8bbb5c..d853efe 100644 --- a/commands/economy/work.js +++ b/commands/economy/work.js @@ -55,7 +55,7 @@ module.exports = { ] ); - var embedReply = embedSuccessColor( + var embedReply = embedReplySuccessColor( "Working.", `You've worked and succesfully earned \`$${amount}\` dollars.`, interaction From 28908ad2a9b9022b3924bd91764c0920cad97c1e Mon Sep 17 00:00:00 2001 From: vb2007 Date: Tue, 12 Nov 2024 20:31:23 +0100 Subject: [PATCH 078/100] tried fixing shit, it didn't worked --- events/scripts/messageDelete/logEventToChannel.js | 14 +++++++++----- events/scripts/messageUpdate/logEventToChannel.js | 2 +- helpers/log-data-query.js | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/events/scripts/messageDelete/logEventToChannel.js b/events/scripts/messageDelete/logEventToChannel.js index 4f9e7d8..f960f5c 100644 --- a/events/scripts/messageDelete/logEventToChannel.js +++ b/events/scripts/messageDelete/logEventToChannel.js @@ -4,9 +4,13 @@ const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/ module.exports = { async sendLogInfo(message) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(message); + console.log(message); + const doesGuildExist = true; + const logChannelId = "669982904058773515"; + // const { doesGuildExist, logChannelId } = await getGuildFromDB(message); + console.log(doesGuildExist, logChannelId); - if (doesGuildExist) { + // if (doesGuildExist) { const logChannel = message.guild.channels.cache.get(logChannelId); const logEmbed = embedMessageFailureColorWithFields( @@ -17,17 +21,17 @@ module.exports = { { name: "Channel", value: `<#${message.channel.id}>` }, { name: "Author", value: `<@${message.author.id}>` }, { name: "Message Id", value: `${message.id}`, inline: true }, - { name: "Channel Id", value: `${oldMessage.channel.id}`, inline: true }, + { name: "Channel Id", value: `${message.channel.id}`, inline: true }, { name: "Author Id", value: `${message.author.id}`, inline: true }, { name: "Author Username", value: `${message.author.username}`, inline: true }, ] ); await logChannel.send({ embeds: [logEmbed] }); - } + // } } catch(error) { - console.error(`Failed to send log info to target channel: ${error}`); + console.error(`Failed to send log info to target channel: ${error.stack}`); } } } \ No newline at end of file diff --git a/events/scripts/messageUpdate/logEventToChannel.js b/events/scripts/messageUpdate/logEventToChannel.js index 2de1599..7a975fe 100644 --- a/events/scripts/messageUpdate/logEventToChannel.js +++ b/events/scripts/messageUpdate/logEventToChannel.js @@ -30,7 +30,7 @@ module.exports = { } } catch(error) { - console.error(`Failed to send log info to target channel: ${error}`); + console.error(`Failed to send log info to target channel: ${error.stack}`); } } } \ No newline at end of file diff --git a/helpers/log-data-query.js b/helpers/log-data-query.js index d50a6c8..6970c92 100644 --- a/helpers/log-data-query.js +++ b/helpers/log-data-query.js @@ -8,9 +8,11 @@ module.exports = { */ async getGuildFromDB(object) { const guildId = object.guild.id; - + + console.log(guildId); const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); const logChannelId = query[0]?.logChannelId; + console.log(query); const doesGuildExist = logChannelId ? true : false; From 7fda6192bf2b6d4ee7ee1112f8fb21633bf609c2 Mon Sep 17 00:00:00 2001 From: vb2007 Date: Tue, 12 Nov 2024 20:31:56 +0100 Subject: [PATCH 079/100] updated packages --- package-lock.json | 241 ++++++++++++++-------------------------------- 1 file changed, 73 insertions(+), 168 deletions(-) diff --git a/package-lock.json b/package-lock.json index 28a2a27..023cfc2 100755 --- a/package-lock.json +++ b/package-lock.json @@ -39,12 +39,13 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.25.9.tgz", - "integrity": "sha512-z88xeGxnzehn2sqZ8UdGQEvYErF1odv2CftxInpSYJt6uHuPe9YjahKZITGs3l5LeI9d2ROG+obuDAoSlqbNfQ==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz", + "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==", "dev": true, "dependencies": { - "@babel/highlight": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9", + "js-tokens": "^4.0.0", "picocolors": "^1.0.0" }, "engines": { @@ -52,30 +53,30 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.9.tgz", - "integrity": "sha512-yD+hEuJ/+wAJ4Ox2/rpNv5HIuPG82x3ZlQvYVn8iYCprdxzE7P1udpGF1jyjQVBU4dgznN+k2h103vxZ7NdPyw==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.2.tgz", + "integrity": "sha512-Z0WgzSEa+aUcdiJuCIqgujCshpMWgUpgOxXotrYPSA53hA3qopNaqcJpyr0hVb1FeWdnqFA35/fUtXgBK8srQg==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.9.tgz", - "integrity": "sha512-WYvQviPw+Qyib0v92AwNIrdLISTp7RfDkM7bPqBvpbnhY4wq8HvHBZREVdYDXk98C8BkOIVnHAY3yvj7AVISxQ==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.26.0.tgz", + "integrity": "sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.25.9", - "@babel/generator": "^7.25.9", + "@babel/code-frame": "^7.26.0", + "@babel/generator": "^7.26.0", "@babel/helper-compilation-targets": "^7.25.9", - "@babel/helper-module-transforms": "^7.25.9", - "@babel/helpers": "^7.25.9", - "@babel/parser": "^7.25.9", + "@babel/helper-module-transforms": "^7.26.0", + "@babel/helpers": "^7.26.0", + "@babel/parser": "^7.26.0", "@babel/template": "^7.25.9", "@babel/traverse": "^7.25.9", - "@babel/types": "^7.25.9", + "@babel/types": "^7.26.0", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -91,12 +92,13 @@ } }, "node_modules/@babel/generator": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.9.tgz", - "integrity": "sha512-omlUGkr5EaoIJrhLf9CJ0TvjBRpd9+AXRG//0GEQ9THSo8wPiTlbpy1/Ow8ZTrbXpjd9FHXfbFQx32I04ht0FA==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.2.tgz", + "integrity": "sha512-zevQbhbau95nkoxSq3f/DC/SC+EEOUZd3DYqfSkMhY2/wfSeaHV1Ew4vk8e+x8lja31IbyuUa2uQ3JONqKbysw==", "dev": true, "dependencies": { - "@babel/types": "^7.25.9", + "@babel/parser": "^7.26.2", + "@babel/types": "^7.26.0", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^3.0.2" @@ -135,13 +137,12 @@ } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.9.tgz", - "integrity": "sha512-TvLZY/F3+GvdRYFZFyxMvnsKi+4oJdgZzU3BoGN9Uc2d9C6zfNwJcKKhjqLAhK8i46mv93jsO74fDh3ih6rpHA==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.26.0.tgz", + "integrity": "sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==", "dev": true, "dependencies": { "@babel/helper-module-imports": "^7.25.9", - "@babel/helper-simple-access": "^7.25.9", "@babel/helper-validator-identifier": "^7.25.9", "@babel/traverse": "^7.25.9" }, @@ -161,19 +162,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-simple-access": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.25.9.tgz", - "integrity": "sha512-c6WHXuiaRsJTyHYLJV75t9IqsmTbItYfdj99PnzYGQZkYKvan5/2jKJ7gu31J3/BJ/A18grImSPModuyG/Eo0Q==", - "dev": true, - "dependencies": { - "@babel/traverse": "^7.25.9", - "@babel/types": "^7.25.9" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-string-parser": { "version": "7.25.9", "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", @@ -202,111 +190,25 @@ } }, "node_modules/@babel/helpers": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.9.tgz", - "integrity": "sha512-oKWp3+usOJSzDZOucZUAMayhPz/xVjzymyDzUN8dk0Wd3RWMlGLXi07UCQ/CgQVb8LvXx3XBajJH4XGgkt7H7g==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.0.tgz", + "integrity": "sha512-tbhNuIxNcVb21pInl3ZSjksLCvgdZy9KwJ8brv993QtIVKJBBkYXz4q4ZbAv31GdnC+R90np23L5FbEBlthAEw==", "dev": true, "dependencies": { "@babel/template": "^7.25.9", - "@babel/types": "^7.25.9" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.25.9.tgz", - "integrity": "sha512-llL88JShoCsth8fF8R4SJnIn+WLvR6ccFxu1H3FlMhDontdcmZWf2HgIZ7AIqV3Xcck1idlohrN4EUBQz6klbw==", - "dev": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.25.9", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0", - "picocolors": "^1.0.0" + "@babel/types": "^7.26.0" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/@babel/highlight/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", - "dev": true - }, - "node_modules/@babel/highlight/node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/@babel/highlight/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/@babel/parser": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.9.tgz", - "integrity": "sha512-aI3jjAAO1fh7vY/pBGsn1i9LDbRP43+asrRlkPuTXW5yHXtd1NgTEMudbBoDDxrf1daEEfPJqR+JBMakzrR4Dg==", + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.2.tgz", + "integrity": "sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==", "dev": true, "dependencies": { - "@babel/types": "^7.25.9" + "@babel/types": "^7.26.0" }, "bin": { "parser": "bin/babel-parser.js" @@ -367,9 +269,9 @@ } }, "node_modules/@babel/plugin-syntax-import-attributes": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.25.9.tgz", - "integrity": "sha512-u3EN9ub8LyYvgTnrgp8gboElouayiwPdnM7x5tcnW3iSt09/lQYPwMNK40I9IUxo7QOZhAsPHCmmuO7EPdruqg==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.26.0.tgz", + "integrity": "sha512-e2dttdsJ1ZTpi3B9UYGLw41hifAubg19AtCu/2I/F1QNVclOBr1dYpTdmdyZ84Xiz43BS/tCUkMAZNLv12Pi+A==", "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.25.9" @@ -570,9 +472,9 @@ } }, "node_modules/@babel/types": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.9.tgz", - "integrity": "sha512-OwS2CM5KocvQ/k7dFJa8i5bNGJP0hXWfVCfDkqRFP1IreH1JDC7wG6eCYCi0+McbfT8OR/kNqsI0UU0xP9H6PQ==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.0.tgz", + "integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.25.9", @@ -1087,9 +989,9 @@ } }, "node_modules/@sapphire/async-queue": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.3.tgz", - "integrity": "sha512-x7zadcfJGxFka1Q3f8gCts1F0xMwCKbZweM85xECGI0hBTeIZJGGCrHgLggihBoprlQ/hBmDR5LKfIPqnmHM3w==", + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.5.tgz", + "integrity": "sha512-cvGzxbba6sav2zZkH8GPf2oGk9yYoD5qrNWdu9fRehifgnFZJMV+nuy2nON2roRO4yQQ+v7MK/Pktl/HgfsUXg==", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" @@ -1220,11 +1122,11 @@ } }, "node_modules/@types/node": { - "version": "22.7.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.9.tgz", - "integrity": "sha512-jrTfRC7FM6nChvU7X2KqcrgquofrWLFDeYC1hKfwNWomVvrn7JIksqf344WN2X/y8xrgqBd2dJATZV4GbatBfg==", + "version": "22.9.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.0.tgz", + "integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==", "dependencies": { - "undici-types": "~6.19.2" + "undici-types": "~6.19.8" } }, "node_modules/@types/stack-utils": { @@ -1234,9 +1136,9 @@ "dev": true }, "node_modules/@types/ws": { - "version": "8.5.12", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", - "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==", + "version": "8.5.13", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.13.tgz", + "integrity": "sha512-osM/gWBTPKgHV8XkTunnegTRIsvF6owmf5w+JtAfOw472dptdm0dlGv4xCt6GwQRcC2XVOvvRE/0bAoQcL2QkA==", "dependencies": { "@types/node": "*" } @@ -1626,9 +1528,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001669", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001669.tgz", - "integrity": "sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w==", + "version": "1.0.30001680", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001680.tgz", + "integrity": "sha512-rPQy70G6AGUMnbwS1z6Xg+RkHYPAi18ihs47GH0jcxIG7wArmPgY3XbS2sRdBbxJljp3thdT8BIqv9ccCypiPA==", "dev": true, "funding": [ { @@ -1861,9 +1763,9 @@ } }, "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==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", + "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", "dev": true, "dependencies": { "path-key": "^3.1.0", @@ -2106,9 +2008,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.45", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.45.tgz", - "integrity": "sha512-vOzZS6uZwhhbkZbcRyiy99Wg+pYFV5hk+5YaECvx0+Z31NR3Tt5zS6dze2OepT6PCTzVzT0dIJItti+uAW5zmw==", + "version": "1.5.56", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.56.tgz", + "integrity": "sha512-7lXb9dAvimCFdvUMTyucD4mnIndt/xhRKFAlky0CyFogdnNmdPQNoHI23msF/2V4mpTxMzgMdjK4+YRlFlRQZw==", "dev": true }, "node_modules/emittery": { @@ -3641,9 +3543,9 @@ } }, "node_modules/mariadb": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/mariadb/-/mariadb-3.3.2.tgz", - "integrity": "sha512-kZvRy00thfFxEksfbDWq+77nB2M520PIZ26LLuHbOvyeZ5XQ3OCY/YsDDu+ifYNHIcs+7UCmjm50GiPdogc24w==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/mariadb/-/mariadb-3.4.0.tgz", + "integrity": "sha512-hdRPcAzs+MTxK5VG1thBW18gGTlw6yWBe9YnLB65GLo7q0fO5DWsgomIevV/pXSaWRmD3qi6ka4oSFRTExRiEQ==", "dependencies": { "@types/geojson": "^7946.0.14", "@types/node": "^22.5.4", @@ -3976,9 +3878,9 @@ } }, "node_modules/parse5": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.2.0.tgz", - "integrity": "sha512-ZkDsAOcxsUMZ4Lz5fVciOehNcJ+Gb8gTzcA4yl3wnc273BAybYWrQ+Ks/OjCjSEpjvQkDSeZbybK9qj2VHHdGA==", + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.2.1.tgz", + "integrity": "sha512-BuBYQYlv1ckiPdQi/ohiivi9Sagc9JG+Ozs0r7b/0iK3sKmrb0b9FdWdBbOdx6hBCM/F9Ir82ofnBhtZOjCRPQ==", "dependencies": { "entities": "^4.5.0" }, @@ -4127,9 +4029,12 @@ } }, "node_modules/psl": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", - "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.10.0.tgz", + "integrity": "sha512-KSKHEbjAnpUuAUserOq0FxGXCUrzC3WniuSJhvdbs102rL55266ZcHBqLWOsG30spQMlPdpy7icATiAQehg/iA==", + "dependencies": { + "punycode": "^2.3.1" + } }, "node_modules/pstree.remy": { "version": "1.1.8", @@ -4638,9 +4543,9 @@ "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==" }, "node_modules/tslib": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz", - "integrity": "sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==" + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==" }, "node_modules/tunnel-agent": { "version": "0.6.0", From 7013f2b68d01b246df5da9bcc5631cbb8f030580 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 12 Dec 2024 23:05:42 +0100 Subject: [PATCH 080/100] fixed shit somehow --- events/messageDelete.js | 4 +-- .../messageDelete/logEventToChannel.js | 29 +++++++++---------- helpers/log-data-query.js | 11 +++---- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/events/messageDelete.js b/events/messageDelete.js index 342f4be..486e6ee 100644 --- a/events/messageDelete.js +++ b/events/messageDelete.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/messageDelete/logEventToChannel"); module.exports = { name: "messageDelete", - async execute(message) { - await logEventToChannel.sendLogInfo(message); + async execute(client, message) { + await logEventToChannel.sendLogInfo(client, message); }, } \ No newline at end of file diff --git a/events/scripts/messageDelete/logEventToChannel.js b/events/scripts/messageDelete/logEventToChannel.js index f960f5c..a7184db 100644 --- a/events/scripts/messageDelete/logEventToChannel.js +++ b/events/scripts/messageDelete/logEventToChannel.js @@ -2,33 +2,30 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(message) { + async sendLogInfo(client, message) { try { - console.log(message); - const doesGuildExist = true; - const logChannelId = "669982904058773515"; - // const { doesGuildExist, logChannelId } = await getGuildFromDB(message); - console.log(doesGuildExist, logChannelId); + const guild = await client.guilds.fetch(message.guildId); + const { doesGuildExist, logChannelId } = await getGuildFromDB(message.guildId); - // if (doesGuildExist) { - const logChannel = message.guild.channels.cache.get(logChannelId); + if (doesGuildExist) { + const logChannel = guild.channels.cache.get(logChannelId); const logEmbed = embedMessageFailureColorWithFields( "Message deleted", "A message was deleted.", [ - { name: "Content", value: `${message.content}` }, - { name: "Channel", value: `<#${message.channel.id}>` }, - { name: "Author", value: `<@${message.author.id}>` }, - { name: "Message Id", value: `${message.id}`, inline: true }, - { name: "Channel Id", value: `${message.channel.id}`, inline: true }, - { name: "Author Id", value: `${message.author.id}`, inline: true }, - { name: "Author Username", value: `${message.author.username}`, inline: true }, + { name: "Content", value: message.content || 'No content available' }, + { name: "Channel", value: `<#${message.channelId}>` }, + { name: "Author", value: message.author ? `<@${message.author.id}>` : 'Unknown' }, + { name: "Message Id", value: message.id || 'Unknown', inline: true }, + { name: "Channel Id", value: message.channelId || 'Unknown', inline: true }, + { name: "Author Id", value: message.author?.id || 'Unknown', inline: true }, + { name: "Author Username", value: message.author?.username || 'Unknown', inline: true }, ] ); await logChannel.send({ embeds: [logEmbed] }); - // } + } } catch(error) { console.error(`Failed to send log info to target channel: ${error.stack}`); diff --git a/helpers/log-data-query.js b/helpers/log-data-query.js index 6970c92..609538b 100644 --- a/helpers/log-data-query.js +++ b/helpers/log-data-query.js @@ -6,16 +6,13 @@ module.exports = { * @returns {doesGuildExist} A boolean value indicating if the guild exists in the database * @returns {logChannelId} A log channel ID from the database based on the guild ID (if configured) */ - async getGuildFromDB(object) { - const guildId = object.guild.id; - - console.log(guildId); + async getGuildFromDB(guildId) { + if (!guildId) return { doesGuildExist: false, logChannelId: null }; + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); const logChannelId = query[0]?.logChannelId; - console.log(query); - + const doesGuildExist = logChannelId ? true : false; - return { doesGuildExist, logChannelId }; } } \ No newline at end of file From 9df1cf7cc316424a5d567ad7f800e8f1cd630406 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 12 Dec 2024 23:06:25 +0100 Subject: [PATCH 081/100] updated packages --- package-lock.json | 133 ++++++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 65 deletions(-) diff --git a/package-lock.json b/package-lock.json index 023cfc2..fee1074 100755 --- a/package-lock.json +++ b/package-lock.json @@ -53,9 +53,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.26.2", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.2.tgz", - "integrity": "sha512-Z0WgzSEa+aUcdiJuCIqgujCshpMWgUpgOxXotrYPSA53hA3qopNaqcJpyr0hVb1FeWdnqFA35/fUtXgBK8srQg==", + "version": "7.26.3", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.3.tgz", + "integrity": "sha512-nHIxvKPniQXpmQLb0vhY3VaFb3S0YrTAwpOWJZh1wn3oJPjJk9Asva204PsBdmAE8vpzfHudT8DB0scYvy9q0g==", "dev": true, "engines": { "node": ">=6.9.0" @@ -92,13 +92,13 @@ } }, "node_modules/@babel/generator": { - "version": "7.26.2", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.2.tgz", - "integrity": "sha512-zevQbhbau95nkoxSq3f/DC/SC+EEOUZd3DYqfSkMhY2/wfSeaHV1Ew4vk8e+x8lja31IbyuUa2uQ3JONqKbysw==", + "version": "7.26.3", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.3.tgz", + "integrity": "sha512-6FF/urZvD0sTeO7k6/B15pMLC4CHUv1426lzr3N01aHJTl046uCAh9LXW/fzeXXjPNCJ6iABW5XaWOsIZB93aQ==", "dev": true, "dependencies": { - "@babel/parser": "^7.26.2", - "@babel/types": "^7.26.0", + "@babel/parser": "^7.26.3", + "@babel/types": "^7.26.3", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^3.0.2" @@ -203,12 +203,12 @@ } }, "node_modules/@babel/parser": { - "version": "7.26.2", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.2.tgz", - "integrity": "sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==", + "version": "7.26.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.3.tgz", + "integrity": "sha512-WJ/CvmY8Mea8iDXo6a7RK2wbmJITT5fN3BEkRuFlxVyNx8jOKIIhmC4fSkTcPcf8JyavbBwIe6OpiCOBXt/IcA==", "dev": true, "dependencies": { - "@babel/types": "^7.26.0" + "@babel/types": "^7.26.3" }, "bin": { "parser": "bin/babel-parser.js" @@ -454,16 +454,16 @@ } }, "node_modules/@babel/traverse": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.9.tgz", - "integrity": "sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw==", + "version": "7.26.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.26.4.tgz", + "integrity": "sha512-fH+b7Y4p3yqvApJALCPJcwb0/XaOSgtK4pzV6WVjPR5GLFQBRI7pfoX2V2iM48NXvX07NUxxm1Vw98YjqTcU5w==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.25.9", - "@babel/generator": "^7.25.9", - "@babel/parser": "^7.25.9", + "@babel/code-frame": "^7.26.2", + "@babel/generator": "^7.26.3", + "@babel/parser": "^7.26.3", "@babel/template": "^7.25.9", - "@babel/types": "^7.25.9", + "@babel/types": "^7.26.3", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -472,9 +472,9 @@ } }, "node_modules/@babel/types": { - "version": "7.26.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.0.tgz", - "integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==", + "version": "7.26.3", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.3.tgz", + "integrity": "sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.25.9", @@ -941,9 +941,9 @@ } }, "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", - "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", "dev": true, "dependencies": { "@jridgewell/set-array": "^1.2.1", @@ -1084,9 +1084,9 @@ } }, "node_modules/@types/geojson": { - "version": "7946.0.14", - "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.14.tgz", - "integrity": "sha512-WCfD5Ht3ZesJUsONdhvm84dmzWOiOzOAqOncN0++w0lBw1o8OuDNJF2McvvCef/yBqb/HYRahp1BYtODFQ8bRg==" + "version": "7946.0.15", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.15.tgz", + "integrity": "sha512-9oSxFzDCT2Rj6DfcHF8G++jxBKS7mBqXl5xrRW+Kbvjry6Uduya2iiwqHPhVXpasAVMBYKkEPGgKhd3+/HZ6xA==" }, "node_modules/@types/graceful-fs": { "version": "4.1.9", @@ -1122,11 +1122,11 @@ } }, "node_modules/@types/node": { - "version": "22.9.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.0.tgz", - "integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==", + "version": "22.10.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.2.tgz", + "integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==", "dependencies": { - "undici-types": "~6.19.8" + "undici-types": "~6.20.0" } }, "node_modules/@types/stack-utils": { @@ -1528,9 +1528,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001680", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001680.tgz", - "integrity": "sha512-rPQy70G6AGUMnbwS1z6Xg+RkHYPAi18ihs47GH0jcxIG7wArmPgY3XbS2sRdBbxJljp3thdT8BIqv9ccCypiPA==", + "version": "1.0.30001688", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001688.tgz", + "integrity": "sha512-Nmqpru91cuABu/DTCXbM2NSRHzM2uVHfPnhJ/1zEAJx/ILBRVmz3pzH4N7DZqbdG0gWClsCC05Oj0mJ/1AWMbA==", "dev": true, "funding": [ { @@ -1763,9 +1763,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", - "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "dependencies": { "path-key": "^3.1.0", @@ -1823,9 +1823,9 @@ } }, "node_modules/debug": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", - "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "dev": true, "dependencies": { "ms": "^2.1.3" @@ -1987,9 +1987,9 @@ } }, "node_modules/dotenv": { - "version": "16.4.5", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", - "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", "engines": { "node": ">=12" }, @@ -2008,9 +2008,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.56", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.56.tgz", - "integrity": "sha512-7lXb9dAvimCFdvUMTyucD4mnIndt/xhRKFAlky0CyFogdnNmdPQNoHI23msF/2V4mpTxMzgMdjK4+YRlFlRQZw==", + "version": "1.5.73", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.73.tgz", + "integrity": "sha512-8wGNxG9tAG5KhGd3eeA0o6ixhiNdgr0DcHWm85XPCphwZgD1lIEoi6t3VERayWao7SF7AAZTw6oARGJeVjH8Kg==", "dev": true }, "node_modules/emittery": { @@ -3385,9 +3385,9 @@ "peer": true }, "node_modules/jsesc": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", - "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", "dev": true, "bin": { "jsesc": "bin/jsesc" @@ -3677,9 +3677,9 @@ "dev": true }, "node_modules/node-releases": { - "version": "2.0.18", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", - "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.19.tgz", + "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==", "dev": true }, "node_modules/nodemon": { @@ -4029,11 +4029,14 @@ } }, "node_modules/psl": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.10.0.tgz", - "integrity": "sha512-KSKHEbjAnpUuAUserOq0FxGXCUrzC3WniuSJhvdbs102rL55266ZcHBqLWOsG30spQMlPdpy7icATiAQehg/iA==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.15.0.tgz", + "integrity": "sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==", "dependencies": { "punycode": "^2.3.1" + }, + "funding": { + "url": "https://github.com/sponsors/lupomontero" } }, "node_modules/pstree.remy": { @@ -4213,9 +4216,9 @@ } }, "node_modules/resolve.exports": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", - "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.3.tgz", + "integrity": "sha512-OcXjMsGdhL4XnbShKpAcSqPMzQoYkYyhbEaeSko47MjRP9NfEQMhZkXL1DoFlt9LWQn4YttrdnV6X2OiyzBi+A==", "dev": true, "engines": { "node": ">=10" @@ -4593,17 +4596,17 @@ "dev": true }, "node_modules/undici": { - "version": "6.20.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.20.1.tgz", - "integrity": "sha512-AjQF1QsmqfJys+LXfGTNum+qw4S88CojRInG/6t31W/1fk6G59s92bnAvGz5Cmur+kQv2SURXEvvudLmbrE8QA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.21.0.tgz", + "integrity": "sha512-BUgJXc752Kou3oOIuU1i+yZZypyZRqNPW0vqoMPl8VaoalSfeR0D8/t4iAS3yirs79SSMTxTag+ZC86uswv+Cw==", "engines": { "node": ">=18.17" } }, "node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==" }, "node_modules/update-browserslist-db": { "version": "1.1.1", From 4bc9b9491d6513e02793bce15178ae13cb38cd15 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 13 Dec 2024 22:09:53 +0100 Subject: [PATCH 082/100] fixed messageUpdate event --- events/messageUpdate.js | 4 ++-- .../messageDelete/logEventToChannel.js | 12 +++++----- .../messageUpdate/logEventToChannel.js | 23 ++++++++++--------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/events/messageUpdate.js b/events/messageUpdate.js index efafbc3..69b60f6 100644 --- a/events/messageUpdate.js +++ b/events/messageUpdate.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/messageUpdate/logEventToChannel"); module.exports = { name: "messageUpdate", - async execute(oldMessage, newMessage) { - await logEventToChannel.sendLogInfo(oldMessage, newMessage); + async execute(client, oldMessage, newMessage) { + await logEventToChannel.sendLogInfo(client, oldMessage, newMessage); }, } \ No newline at end of file diff --git a/events/scripts/messageDelete/logEventToChannel.js b/events/scripts/messageDelete/logEventToChannel.js index a7184db..fcb5d93 100644 --- a/events/scripts/messageDelete/logEventToChannel.js +++ b/events/scripts/messageDelete/logEventToChannel.js @@ -14,13 +14,13 @@ module.exports = { "Message deleted", "A message was deleted.", [ - { name: "Content", value: message.content || 'No content available' }, + { name: "Content", value: message.content || "No content available" }, { name: "Channel", value: `<#${message.channelId}>` }, - { name: "Author", value: message.author ? `<@${message.author.id}>` : 'Unknown' }, - { name: "Message Id", value: message.id || 'Unknown', inline: true }, - { name: "Channel Id", value: message.channelId || 'Unknown', inline: true }, - { name: "Author Id", value: message.author?.id || 'Unknown', inline: true }, - { name: "Author Username", value: message.author?.username || 'Unknown', inline: true }, + { name: "Author", value: message.author ? `<@${message.author.id}>` : "Unknown" }, + { name: "Message Id", value: message.id || "Unknown", inline: true }, + { name: "Channel Id", value: message.channelId || "Unknown", inline: true }, + { name: "Author Id", value: message.author?.id || "Unknown", inline: true }, + { name: "Author Username", value: message.author?.username || "Unknown", inline: true }, ] ); diff --git a/events/scripts/messageUpdate/logEventToChannel.js b/events/scripts/messageUpdate/logEventToChannel.js index 7a975fe..6eb8276 100644 --- a/events/scripts/messageUpdate/logEventToChannel.js +++ b/events/scripts/messageUpdate/logEventToChannel.js @@ -2,26 +2,27 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageWarningColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(oldMessage, newMessage) { + async sendLogInfo(client, oldMessage, newMessage) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(oldMessage); + const guild = await client.guilds.fetch(oldMessage.guildId); + const { doesGuildExist, logChannelId } = await getGuildFromDB(oldMessage.guildId); if (doesGuildExist) { if (oldMessage.content !== newMessage.content) { - const logChannel = oldMessage.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); const logEmbed = embedMessageWarningColorWithFields( "Message updated", `A message was updated.`, [ - { name: "From", value: `${oldMessage.content}` }, - { name: "To", value: `${newMessage.content}` }, - { name: "Channel", value: `<#${oldMessage.channel.id}>` }, - { name: "Author", value: `<@${oldMessage.author.id}>` }, - { name: "Message Id", value: `${oldMessage.id}`, inline: true }, - { name: "Channel Id", value: `${oldMessage.channel.id}`, inline: true }, - { name: "Author Id", value: `${oldMessage.author.id}`, inline: true }, - { name: "Author Username", value: `${oldMessage.author.username}`, inline: true }, + { name: "From", value: `${oldMessage.content}` || "Unknown" }, + { name: "To", value: `${newMessage.content}` || "Unknown" }, + { name: "Channel", value: `<#${oldMessage.channel.id}>` || "Unknown" }, + { name: "Author", value: `<@${oldMessage.author.id}>` || "Unknown" }, + { name: "Message Id", value: `${oldMessage.id}` || "Unknown", inline: true }, + { name: "Channel Id", value: `${oldMessage.channel.id}` || "Unknown", inline: true }, + { name: "Author Id", value: `${oldMessage.author.id}` || "Unknown", inline: true }, + { name: "Author Username", value: `${oldMessage.author.username}` || "Unknown", inline: true }, ] ); From 1068656d621b821dd6e1d53d41c100c53c0187ca Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 13 Dec 2024 22:12:44 +0100 Subject: [PATCH 083/100] added empty message check to message logging --- events/scripts/messageCreate/messageLogging.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/events/scripts/messageCreate/messageLogging.js b/events/scripts/messageCreate/messageLogging.js index 8698511..5f99ff0 100644 --- a/events/scripts/messageCreate/messageLogging.js +++ b/events/scripts/messageCreate/messageLogging.js @@ -13,12 +13,15 @@ module.exports = { const channelId = message.channel.id; try { - await db.query("INSERT INTO messageLog (messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId) VALUES (?, ?, ?, ?, ?, ?, ?)", - [ - messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId - ] - ); - console.log(`Logged message "${message.content}" to database from ${senderUserName} in ${serverName}.`); + if (senderUserName !== "") { + await db.query("INSERT INTO messageLog (messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId) VALUES (?, ?, ?, ?, ?, ?, ?)", + [ + messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId + ] + ); + + console.log(`Logged message "${message.content}" to database from ${senderUserName} in ${serverName}.`); + } } catch (error) { console.error(`Failed to log message: ${error}`); From 2a5fe98e9eb6214d471c34c3b1d6fc36c418e40f Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 13 Dec 2024 22:14:06 +0100 Subject: [PATCH 084/100] fixed typo --- events/scripts/messageCreate/messageLogging.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/events/scripts/messageCreate/messageLogging.js b/events/scripts/messageCreate/messageLogging.js index 5f99ff0..2f075c1 100644 --- a/events/scripts/messageCreate/messageLogging.js +++ b/events/scripts/messageCreate/messageLogging.js @@ -13,13 +13,13 @@ module.exports = { const channelId = message.channel.id; try { - if (senderUserName !== "") { + if (messageContent !== "") { await db.query("INSERT INTO messageLog (messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId) VALUES (?, ?, ?, ?, ?, ?, ?)", [ messageContent, senderUserName, senderUserId, serverName, serverId, channelName, channelId ] ); - + console.log(`Logged message "${message.content}" to database from ${senderUserName} in ${serverName}.`); } } From 2cfb0071a4c746ebf05c8fd779db4ad46f16a304 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 13 Dec 2024 22:25:05 +0100 Subject: [PATCH 085/100] fixed channelCreate event --- events/channelCreate.js | 4 ++-- .../scripts/channelCreate/logEventToChannel.js | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/events/channelCreate.js b/events/channelCreate.js index f8b8960..775cf39 100644 --- a/events/channelCreate.js +++ b/events/channelCreate.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/channelCreate/logEventToChannel"); module.exports = { name: "channelCreate", - async execute(channel) { - await logEventToChannel.sendLogInfo(channel); + async execute(client, channel) { + await logEventToChannel.sendLogInfo(client, channel); }, }; \ No newline at end of file diff --git a/events/scripts/channelCreate/logEventToChannel.js b/events/scripts/channelCreate/logEventToChannel.js index df002c9..9480c9e 100644 --- a/events/scripts/channelCreate/logEventToChannel.js +++ b/events/scripts/channelCreate/logEventToChannel.js @@ -3,22 +3,23 @@ const { getChannelType } = require("../../../helpers/channel-types"); const { embedMessageSuccessColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(channel) { + async sendLogInfo(client, channel) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(channel); + const guild = await client.guilds.fetch(channel.guildId); + const { doesGuildExist, logChannelId } = await getGuildFromDB(channel.guildId); if (doesGuildExist) { - const logChannel = channel.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); const logEmbed = embedMessageSuccessColorWithFields( "Channel created", `Channel '<#${channel.id}>' was created.`, [ - { name: "Name", value: `${channel.name}`, inline: true }, - { name: "Id", value: `${channel.id}`, inline: true }, - { name: "Category", value: `${channel.parent.name}` }, - { name: "Type", value: `${getChannelType(channel)}`, inline: true }, - { name: "NSFW?", value: `${channel.nsfw ? "Yes" : "No"}`, inline: true }, + { name: "Name", value: `${channel.name}` || "Unknown", inline: true }, + { name: "Id", value: `${channel.id}` || "Unknown", inline: true }, + { name: "Category", value: `${channel.parent.name}` || "Unknown" }, + { name: "Type", value: `${getChannelType(channel)}` || "Unknown", inline: true }, + { name: "NSFW?", value: `${channel.nsfw ? "Yes" : "No"}` || "Unknown", inline: true }, ] ); From 89586a73a6f0aaa10b704ff0e875dbb74ea8d33f Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 13 Dec 2024 22:27:51 +0100 Subject: [PATCH 086/100] fixed channelDelete event --- events/channelDelete.js | 4 ++-- .../channelDelete/logEventToChannel.js | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/events/channelDelete.js b/events/channelDelete.js index c59b483..306c8b4 100644 --- a/events/channelDelete.js +++ b/events/channelDelete.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/channelDelete/logEventToChannel"); module.exports = { name: "channelDelete", - async execute(channel) { - await logEventToChannel.sendLogInfo(channel); + async execute(client, channel) { + await logEventToChannel.sendLogInfo(client, channel); }, }; \ No newline at end of file diff --git a/events/scripts/channelDelete/logEventToChannel.js b/events/scripts/channelDelete/logEventToChannel.js index 5eb0962..145c21e 100644 --- a/events/scripts/channelDelete/logEventToChannel.js +++ b/events/scripts/channelDelete/logEventToChannel.js @@ -3,22 +3,23 @@ const { getChannelType } = require("../../../helpers/channel-types"); const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(channel) { + async sendLogInfo(client, channel) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(channel); + const guild = await client.guilds.fetch(channel.guildId); + const { doesGuildExist, logChannelId } = await getGuildFromDB(channel.guildId); if (doesGuildExist) { - const logChannel = channel.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); const logEmbed = embedMessageFailureColorWithFields( "Channel deleted", - `Channel '<#${channel.id}>' was deleted.`, + `Channel "<#${channel.id}>" was deleted.`, [ - { name: "Name", value: `${channel.name}`, inline: true }, - { name: "Id", value: `${channel.id}`, inline: true }, - { name: "Category", value: `${channel.parent.name}` }, - { name: "Type", value: `${getChannelType(channel)}`, inline: true }, - { name: "NSFW?", value: `${channel.nsfw ? "Yes" : "No"}`, inline: true }, + { name: "Name", value: `${channel.name}` || "Unknown", inline: true }, + { name: "Id", value: `${channel.id}` || "Unknown", inline: true }, + { name: "Category", value: `${channel.parent?.name}` || "Unknown" }, + { name: "Type", value: `${getChannelType(channel)}` || "Unknown", inline: true }, + { name: "NSFW?", value: `${channel.nsfw ? "Yes" : "No"}` || "Unknown", inline: true }, ] ); From c1dc743b3c4899946393ca206605909f11b9c3f9 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 13 Dec 2024 22:31:46 +0100 Subject: [PATCH 087/100] fixed channelPinsUpdate event --- events/channelPinsUpdate.js | 4 ++-- events/scripts/channelPinsUpdate/logEventToChannel.js | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/events/channelPinsUpdate.js b/events/channelPinsUpdate.js index 602f10f..8e14484 100644 --- a/events/channelPinsUpdate.js +++ b/events/channelPinsUpdate.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/channelPinsUpdate/logEventToChannel module.exports = { name: "channelPinsUpdate", - async execute(channel) { - await logEventToChannel.sendLogInfo(channel); + async execute(client, channel) { + await logEventToChannel.sendLogInfo(client, channel); }, } \ No newline at end of file diff --git a/events/scripts/channelPinsUpdate/logEventToChannel.js b/events/scripts/channelPinsUpdate/logEventToChannel.js index fff23fc..ed05ec6 100644 --- a/events/scripts/channelPinsUpdate/logEventToChannel.js +++ b/events/scripts/channelPinsUpdate/logEventToChannel.js @@ -2,12 +2,13 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessSecondaryColor } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(channel) { + async sendLogInfo(client, channel) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(channel); + const guild = await client.guilds.fetch(channel.guildId); + const { doesGuildExist, logChannelId } = await getGuildFromDB(channel.guildId); if (doesGuildExist) { - const logChannel = channel.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); const logEmbed = embedMessageSuccessSecondaryColor( "Channel pins updated", From 19df2ae9e5387dc69ae59feafa10d00adb459459 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 14 Dec 2024 23:53:53 +0100 Subject: [PATCH 088/100] partially fixed channelUpdate event --- events/channelUpdate.js | 4 +- .../channelUpdate/logEventToChannel.js | 39 ++++++++++--------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/events/channelUpdate.js b/events/channelUpdate.js index 5136dac..05c071a 100644 --- a/events/channelUpdate.js +++ b/events/channelUpdate.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/channelUpdate/logEventToChannel"); module.exports = { name: "channelUpdate", - async execute(oldChannel, newChannel) { - await logEventToChannel.sendLogInfo(oldChannel, newChannel); + async execute(client, oldChannel, newChannel) { + await logEventToChannel.sendLogInfo(client, oldChannel, newChannel); }, } \ No newline at end of file diff --git a/events/scripts/channelUpdate/logEventToChannel.js b/events/scripts/channelUpdate/logEventToChannel.js index a3a33cb..e1f5543 100644 --- a/events/scripts/channelUpdate/logEventToChannel.js +++ b/events/scripts/channelUpdate/logEventToChannel.js @@ -2,12 +2,13 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessSecondaryColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(oldChannel, newChannel) { + async sendLogInfo(client, oldChannel, newChannel) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(oldChannel); + const guild = await client.guilds.fetch(oldChannel.guildId); + const { doesGuildExist, logChannelId } = await getGuildFromDB(oldChannel.guildId); if (doesGuildExist) { - const logChannel = oldChannel.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); const changedChannelId = newChannel.id; if (oldChannel.nsfw !== newChannel.nsfw) { @@ -15,10 +16,10 @@ module.exports = { "Channel Updated: NSFW status", `Channel NSFW status was changed in <#${changedChannelId}>.`, [ - { name: "Channel name", value: `${newChannel.name}`, inline: true }, - { name: "Channel Id", value: `${changedChannelId}`, inline: true }, - { name: "From", value: `**${oldChannel.nsfw ? "NSFW" : "Not NSFW"}**` }, - { name: "To", value: `**${newChannel.nsfw ? "NSFW" : "Not NSFW"}**` }, + { name: "Channel name", value: `${newChannel.name}` || "Unknown", inline: true }, + { name: "Channel Id", value: `${changedChannelId}` || "Unknown", inline: true }, + { name: "From", value: `**${oldChannel.nsfw ? "NSFW" : "Not NSFW"}**` || "Unknown" }, + { name: "To", value: `**${newChannel.nsfw ? "NSFW" : "Not NSFW"}**` || "Unknown" }, ] ); @@ -30,10 +31,10 @@ module.exports = { "Channel Updated: Name", `Channel name was changed in <#${changedChannelId}>.`, [ - { name: "Channel name", value: `${newChannel.name}`, inline: true }, - { name: "Channel Id", value: `${changedChannelId}`, inline: true }, - { name: "From", value: `**${oldChannel.name}**` }, - { name: "To", value: `**${newChannel.name}**` }, + { name: "Channel name", value: `${newChannel.name}` || "Unknown", inline: true }, + { name: "Channel Id", value: `${changedChannelId}` || "Unknown", inline: true }, + { name: "From", value: `**${oldChannel.name}**` || "Unknown" }, + { name: "To", value: `**${newChannel.name}**` || "Unknown" }, ] ); @@ -45,10 +46,10 @@ module.exports = { "Channel Updated: Topic", `Channel topic *(description)* was changed in <#${changedChannelId}>.`, [ - { name: "Channel name", value: `${newChannel.name}`, inline: true }, - { name: "Channel Id", value: `${changedChannelId}`, inline: true }, - { name: "From", value: `**${oldChannel.topic == "" ? "*empty description*" : oldChannel.topic}**` }, - { name: "To", value: `**${newChannel.topic == "" ? "*empty description*" : newChannel.topic}**` }, + { name: "Channel name", value: `${newChannel.name}` || "Unknown", inline: true }, + { name: "Channel Id", value: `${changedChannelId}` || "Unknown", inline: true }, + { name: "From", value: `**${oldChannel.topic == "" ? "*empty description*" : oldChannel.topic}**` || "Unknown" }, + { name: "To", value: `**${newChannel.topic == "" ? "*empty description*" : newChannel.topic}**` || "Unknown" }, ] ); @@ -60,10 +61,10 @@ module.exports = { "Channel Updated: Slowmode", `Channel slowmode was changed to "**${newChannel.rateLimitPerUser}**" seconds from "**${oldChannel.rateLimitPerUser}**" seconds in <#${changedChannelId}>.`, [ - { name: "Channel name", value: `${newChannel.name}`, inline: true }, - { name: "Channel Id", value: `${changedChannelId}`, inline: true }, - { name: "From", value: `**${oldChannel.rateLimitPerUser} seconds**` }, - { name: "To", value: `**${newChannel.rateLimitPerUser} seconds**` }, + { name: "Channel name", value: `${newChannel.name}` || "Unknown", inline: true }, + { name: "Channel Id", value: `${changedChannelId}` || "Unknown", inline: true }, + { name: "From", value: `**${oldChannel.rateLimitPerUser} seconds**` || "Unknown" }, + { name: "To", value: `**${newChannel.rateLimitPerUser} seconds**` || "Unknown" }, ] ); From d888543cc23e30d48174361618da8514de952239 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 15 Dec 2024 00:06:53 +0100 Subject: [PATCH 089/100] fixed emojiCreate event --- events/emojiCreate.js | 4 ++-- events/scripts/emojiCreate/logEventToChannel.js | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/events/emojiCreate.js b/events/emojiCreate.js index da6a35b..2f3db56 100644 --- a/events/emojiCreate.js +++ b/events/emojiCreate.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/emojiCreate/logEventToChannel"); module.exports = { name: "emojiCreate", - async execute(emoji) { - await logEventToChannel.sendLogInfo(emoji); + async execute(client, emoji) { + await logEventToChannel.sendLogInfo(client, emoji); }, }; \ No newline at end of file diff --git a/events/scripts/emojiCreate/logEventToChannel.js b/events/scripts/emojiCreate/logEventToChannel.js index 523499b..bc6875f 100644 --- a/events/scripts/emojiCreate/logEventToChannel.js +++ b/events/scripts/emojiCreate/logEventToChannel.js @@ -2,20 +2,21 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(emoji) { + async sendLogInfo(client, emoji) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(emoji); + const guild = await client.guilds.fetch(emoji.guild.id); + const { doesGuildExist, logChannelId } = await getGuildFromDB(emoji.guild.id); if (doesGuildExist) { - const logChannel = emoji.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); const logEmbed = embedMessageSuccessColorWithFields( "Emoji created", `Emoji '<:${emoji.name}:${emoji.id}>' was created.`, [ - { name: "Emoji name", value: `${emoji.name}` }, - { name: "Emoji Id", value: `${emoji.id}` }, - { name: "Animated?", value: `${emoji.animated ? "Yes" : "No"}` }, + { name: "Emoji name", value: `${emoji.name}` || "Unknown" }, + { name: "Emoji Id", value: `${emoji.id}` || "Unknown" }, + { name: "Animated?", value: `${emoji.animated ? "Yes" : "No"}` || "Unknown" }, ] ); From 46f1b20b1c149a9d2bc7200d0c678b1ccabf23fd Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 15 Dec 2024 00:08:55 +0100 Subject: [PATCH 090/100] fixed emojiDelete event --- events/emojiDelete.js | 4 ++-- events/scripts/emojiDelete/logEventToChannel.js | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/events/emojiDelete.js b/events/emojiDelete.js index 843bfcb..2b89b36 100644 --- a/events/emojiDelete.js +++ b/events/emojiDelete.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/emojiDelete/logEventToChannel"); module.exports = { name: "emojiDelete", - async execute(emoji) { - await logEventToChannel.sendLogInfo(emoji); + async execute(client, emoji) { + await logEventToChannel.sendLogInfo(client, emoji); }, } \ No newline at end of file diff --git a/events/scripts/emojiDelete/logEventToChannel.js b/events/scripts/emojiDelete/logEventToChannel.js index 5c4e99c..c1f8d37 100644 --- a/events/scripts/emojiDelete/logEventToChannel.js +++ b/events/scripts/emojiDelete/logEventToChannel.js @@ -2,20 +2,21 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(emoji) { + async sendLogInfo(client, emoji) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(emoji); + const guild = await client.guilds.fetch(emoji.guild.id); + const { doesGuildExist, logChannelId } = await getGuildFromDB(emoji.guild.id); if (doesGuildExist) { - const logChannel = emoji.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); const logEmbed = embedMessageFailureColorWithFields( "Emoji deleted", `Emoji '${emoji.name}' was deleted.`, [ - { name: "Emoji name", value: `${emoji.name}` }, - { name: "Emoji Id", value: `${emoji.id}` }, - { name: "Animated?", value: `${emoji.animated ? "Yes" : "No"}` }, + { name: "Emoji name", value: `${emoji.name}`|| "Unknown" }, + { name: "Emoji Id", value: `${emoji.id}`|| "Unknown" }, + { name: "Animated?", value: `${emoji.animated ? "Yes" : "No"}`|| "Unknown" }, ] ); From 309381e64c80871134a5e59d3cd39684828b9ed2 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 15 Dec 2024 00:16:17 +0100 Subject: [PATCH 091/100] fixed emojiUpdate event --- events/emojiUpdate.js | 4 ++-- events/scripts/emojiUpdate/logEventToChannel.js | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/events/emojiUpdate.js b/events/emojiUpdate.js index 347e9a6..3276b76 100644 --- a/events/emojiUpdate.js +++ b/events/emojiUpdate.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/emojiUpdate/logEventToChannel"); module.exports = { name: "emojiUpdate", - async execute(oldEmoji, newEmoji) { - await logEventToChannel.sendLogInfo(oldEmoji, newEmoji); + async execute(client, oldEmoji, newEmoji) { + await logEventToChannel.sendLogInfo(client, oldEmoji, newEmoji); }, } \ No newline at end of file diff --git a/events/scripts/emojiUpdate/logEventToChannel.js b/events/scripts/emojiUpdate/logEventToChannel.js index 325f80c..a46cd95 100644 --- a/events/scripts/emojiUpdate/logEventToChannel.js +++ b/events/scripts/emojiUpdate/logEventToChannel.js @@ -2,21 +2,22 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessSecondaryColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(oldEmoji, newEmoji) { + async sendLogInfo(client, oldEmoji, newEmoji) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(oldEmoji); + const guild = await client.guilds.fetch(oldEmoji.guild.id); + const { doesGuildExist, logChannelId } = await getGuildFromDB(oldEmoji.guild.id); if (doesGuildExist) { - const logChannel = oldEmoji.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); const logEmbed = embedMessageSuccessSecondaryColorWithFields( "Emoji updated", `${oldEmoji.name} emoji was updated.`, [ - { name: "Emoji Id", value: `${oldEmoji.id}`, inline: true }, - { name: "Animated?", value: `${oldEmoji.animated ? "Yes" : "No"}`, inline: true }, - { name: "Old name", value: `${oldEmoji.name}` }, - { name: "New name", value: `${newEmoji.name}` }, + { name: "Emoji Id", value: `${oldEmoji.id}`|| "Unknown", inline: true }, + { name: "Animated?", value: `${oldEmoji.animated ? "Yes" : "No"}`|| "Unknown", inline: true }, + { name: "Old name", value: `${oldEmoji.name}`|| "Unknown" }, + { name: "New name", value: `${newEmoji.name}`|| "Unknown" }, ] ); From 40b41a706e59ef72c31e0b8420a5c7fcbb113f9f Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 15 Dec 2024 00:21:43 +0100 Subject: [PATCH 092/100] probably fixed guildBanAdd event --- events/guildBanAdd.js | 4 ++-- events/scripts/guildBanAdd/logEventToChannel.js | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/events/guildBanAdd.js b/events/guildBanAdd.js index 3298b26..c554d07 100644 --- a/events/guildBanAdd.js +++ b/events/guildBanAdd.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/guildBanAdd/logEventToChannel"); module.exports = { name: "guildBanAdd", - async execute(member, reason) { - await logEventToChannel.sendLogInfo(member, reason); + async execute(client, member, reason) { + await logEventToChannel.sendLogInfo(client, member, reason); }, } \ No newline at end of file diff --git a/events/scripts/guildBanAdd/logEventToChannel.js b/events/scripts/guildBanAdd/logEventToChannel.js index 4306b95..39776ee 100644 --- a/events/scripts/guildBanAdd/logEventToChannel.js +++ b/events/scripts/guildBanAdd/logEventToChannel.js @@ -2,20 +2,21 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(member, reason) { + async sendLogInfo(client, member, reason) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(member); + const guild = await client.guilds.fetch(message.guildId); + const { doesGuildExist, logChannelId } = await getGuildFromDB(member.guildId); if (doesGuildExist) { - const logChannel = member.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); const logEmbed = embedMessageFailureColorWithFields( "Member banned", `<@${member.user.id}> was banned from the server.`, [ - { name: "Username", value: `${member.user.username}`, inline: true }, - { name: "User Id", value: `${member.user.id}`, inline: true }, - { name: "Reason", value: `${reason}` }, + { name: "Username", value: `${member.user.username}`|| "Unknown", inline: true }, + { name: "User Id", value: `${member.user.id}`|| "Unknown", inline: true }, + { name: "Reason", value: `${reason}`|| "Unknown" }, ] ); From c46de2ea894855b93acdabc672c933458e5d7bab Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 15 Dec 2024 00:39:55 +0100 Subject: [PATCH 093/100] fixed event parameters --- events/guildBanAdd.js | 4 ++-- events/guildMemberAdd.js | 4 ++-- events/guildMemberRemove.js | 4 ++-- events/voiceStateUpdate.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/events/guildBanAdd.js b/events/guildBanAdd.js index c554d07..8e2bbda 100644 --- a/events/guildBanAdd.js +++ b/events/guildBanAdd.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/guildBanAdd/logEventToChannel"); module.exports = { name: "guildBanAdd", - async execute(client, member, reason) { - await logEventToChannel.sendLogInfo(client, member, reason); + async execute(client, ban) { + await logEventToChannel.sendLogInfo(client, ban); }, } \ No newline at end of file diff --git a/events/guildMemberAdd.js b/events/guildMemberAdd.js index e140583..48b66e7 100755 --- a/events/guildMemberAdd.js +++ b/events/guildMemberAdd.js @@ -4,8 +4,8 @@ const welcome = require("./scripts/guildMemberAdd/welcome"); module.exports = { name: "guildMemberAdd", - async execute(member) { - await logEventToChannel.sendLogInfo(member); + async execute(client, member) { + await logEventToChannel.sendLogInfo(client, member); await autorole.assignRole(member); await welcome.sendWelcomeMessage(member); }, diff --git a/events/guildMemberRemove.js b/events/guildMemberRemove.js index 59fcacd..f5e6905 100644 --- a/events/guildMemberRemove.js +++ b/events/guildMemberRemove.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/guildMemberRemove/logEventToChannel module.exports = { name: "guildMemberRemove", - async execute(member) { - await logEventToChannel.sendLogInfo(member); + async execute(client, member) { + await logEventToChannel.sendLogInfo(client, member); }, } \ No newline at end of file diff --git a/events/voiceStateUpdate.js b/events/voiceStateUpdate.js index 02040a8..ccf9b76 100644 --- a/events/voiceStateUpdate.js +++ b/events/voiceStateUpdate.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/channelUpdate/logEventToChannel"); module.exports = { name: "voiceStateUpdate", - async execute(oldState, newState) { - await logEventToChannel.sendLogInfo(oldState, newState); + async execute(client, oldState, newState) { + await logEventToChannel.sendLogInfo(client, oldState, newState); }, }; \ No newline at end of file From 06b06b029b2df60f9cc1f7c33981b10577754b43 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 15 Dec 2024 16:20:07 +0100 Subject: [PATCH 094/100] fixed the rest of the logging events --- events/guildBanRemove.js | 4 ++-- events/scripts/guildBanAdd/logEventToChannel.js | 6 ++++-- events/scripts/guildBanRemove/logEventToChannel.js | 9 +++++---- events/scripts/guildMemberAdd/logEventToChannel.js | 11 ++++++----- events/scripts/guildMemberRemove/logEventToChannel.js | 11 ++++++----- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/events/guildBanRemove.js b/events/guildBanRemove.js index 55ce227..12e23f7 100644 --- a/events/guildBanRemove.js +++ b/events/guildBanRemove.js @@ -2,7 +2,7 @@ const logEventToChannel = require("./scripts/guildBanRemove/logEventToChannel"); module.exports = { name: "guildBanRemove", - async execute(member) { - await logEventToChannel.sendLogInfo(member); + async execute(client, member) { + await logEventToChannel.sendLogInfo(client, member); }, } \ No newline at end of file diff --git a/events/scripts/guildBanAdd/logEventToChannel.js b/events/scripts/guildBanAdd/logEventToChannel.js index 39776ee..99fc8ef 100644 --- a/events/scripts/guildBanAdd/logEventToChannel.js +++ b/events/scripts/guildBanAdd/logEventToChannel.js @@ -4,8 +4,10 @@ const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/ module.exports = { async sendLogInfo(client, member, reason) { try { - const guild = await client.guilds.fetch(message.guildId); - const { doesGuildExist, logChannelId } = await getGuildFromDB(member.guildId); + const guild = await client.guilds.fetch(message.guild.id); + console.log(member.guild.id); + console.log(member.guildId); + const { doesGuildExist, logChannelId } = await getGuildFromDB(member.guild.id); if (doesGuildExist) { const logChannel = guild.channels.cache.get(logChannelId); diff --git a/events/scripts/guildBanRemove/logEventToChannel.js b/events/scripts/guildBanRemove/logEventToChannel.js index dfa0d97..87f7725 100644 --- a/events/scripts/guildBanRemove/logEventToChannel.js +++ b/events/scripts/guildBanRemove/logEventToChannel.js @@ -2,14 +2,15 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(member) { + async sendLogInfo(client, member) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(member); + const guild = await client.guilds.fetch(member.guild.id); + const { doesGuildExist, logChannelId } = await getGuildFromDB(member.guild.id); if (doesGuildExist) { - const logChannel = member.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); - const logEmbed = embedMessageFailureColorWithFields( + const logEmbed = embedMessageSuccessColorWithFields( "Member unbanned", `<@${member.user.id}> was unbanned from the server.`, [ diff --git a/events/scripts/guildMemberAdd/logEventToChannel.js b/events/scripts/guildMemberAdd/logEventToChannel.js index f354999..acf9fa5 100644 --- a/events/scripts/guildMemberAdd/logEventToChannel.js +++ b/events/scripts/guildMemberAdd/logEventToChannel.js @@ -2,19 +2,20 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageSuccessColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(member) { + async sendLogInfo(client, member) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(member); + const guild = await client.guilds.fetch(message.guild.id); + const { doesGuildExist, logChannelId } = await getGuildFromDB(member.guild.id); if (doesGuildExist) { - const logChannel = member.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); const logEmbed = embedMessageSuccessColorWithFields( "Member joined", `<@${member.user.id}> joined the server.`, [ - { name: "Username", value: `${member.user.username}` }, - { name: "User Id", value: `${member.user.id}` }, + { name: "Username", value: `${member.user.username}` || "Unknown" }, + { name: "User Id", value: `${member.user.id}` || "Unknown" }, ] ); diff --git a/events/scripts/guildMemberRemove/logEventToChannel.js b/events/scripts/guildMemberRemove/logEventToChannel.js index 75b8755..ace55bd 100644 --- a/events/scripts/guildMemberRemove/logEventToChannel.js +++ b/events/scripts/guildMemberRemove/logEventToChannel.js @@ -2,19 +2,20 @@ const { getGuildFromDB } = require("../../../helpers/log-data-query"); const { embedMessageFailureColorWithFields } = require("../../../helpers/embeds/embed-message"); module.exports = { - async sendLogInfo(member) { + async sendLogInfo(client, member) { try { - const { doesGuildExist, logChannelId } = await getGuildFromDB(member); + const guild = await client.guilds.fetch(member.guild.id); + const { doesGuildExist, logChannelId } = await getGuildFromDB(member.guild.id); if (doesGuildExist) { - const logChannel = member.guild.channels.cache.get(logChannelId); + const logChannel = guild.channels.cache.get(logChannelId); const logEmbed = embedMessageFailureColorWithFields( "Member left", `<@${member.user.id}> has left the server.`, [ - { name: "Username", value: `${member.user.username}` }, - { name: "User Id", value: `${member.user.id}` }, + { name: "Username", value: `${member.user.username}`|| "Unknown" }, + { name: "User Id", value: `${member.user.id}`|| "Unknown" }, ] ); From 41292ce60bb419f5139665dd9880f25247eed133 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 15 Dec 2024 16:22:25 +0100 Subject: [PATCH 095/100] added trycatch to prevent fatal errors in runtime --- helpers/log-data-query.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/helpers/log-data-query.js b/helpers/log-data-query.js index 609538b..48b6701 100644 --- a/helpers/log-data-query.js +++ b/helpers/log-data-query.js @@ -7,12 +7,17 @@ module.exports = { * @returns {logChannelId} A log channel ID from the database based on the guild ID (if configured) */ async getGuildFromDB(guildId) { - if (!guildId) return { doesGuildExist: false, logChannelId: null }; - - const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); - const logChannelId = query[0]?.logChannelId; - - const doesGuildExist = logChannelId ? true : false; - return { doesGuildExist, logChannelId }; + try { + if (!guildId) return { doesGuildExist: false, logChannelId: null }; + + const query = await db.query("SELECT guildId, logChannelId FROM configLogging WHERE guildId = ?", [guildId]); + const logChannelId = query[0]?.logChannelId; + + const doesGuildExist = logChannelId ? true : false; + return { doesGuildExist, logChannelId }; + } catch (error) { + console.error(`Failed to get logging config data from the database: ${error}`); + return { doesGuildExist, logChannelId }; + } } } \ No newline at end of file From eddee249401f5d6af3b29c3a589abe48fb2cbf7c Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 15 Dec 2024 16:27:16 +0100 Subject: [PATCH 096/100] removed duplicate data logging --- events/scripts/channelUpdate/logEventToChannel.js | 2 +- helpers/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/events/scripts/channelUpdate/logEventToChannel.js b/events/scripts/channelUpdate/logEventToChannel.js index e1f5543..5b86307 100644 --- a/events/scripts/channelUpdate/logEventToChannel.js +++ b/events/scripts/channelUpdate/logEventToChannel.js @@ -59,7 +59,7 @@ module.exports = { if (oldChannel.rateLimitPerUser !== newChannel.rateLimitPerUser) { const logEmbed = embedMessageSuccessSecondaryColorWithFields( "Channel Updated: Slowmode", - `Channel slowmode was changed to "**${newChannel.rateLimitPerUser}**" seconds from "**${oldChannel.rateLimitPerUser}**" seconds in <#${changedChannelId}>.`, + `Channel slowmode was in <#${changedChannelId}>.`, [ { name: "Channel name", value: `${newChannel.name}` || "Unknown", inline: true }, { name: "Channel Id", value: `${changedChannelId}` || "Unknown", inline: true }, diff --git a/helpers/README.md b/helpers/README.md index 8ee3376..d173eca 100644 --- a/helpers/README.md +++ b/helpers/README.md @@ -1,3 +1,3 @@ # Helpers -Helpers are used across all scripts in the whole project to avoid code duplication. \ No newline at end of file +Helpers are used across all scripts in the whole project to avoid duplicate code. From 2f9efe8844264ccd8cdef6936c3e0e9bf727e14e Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 15 Dec 2024 16:31:21 +0100 Subject: [PATCH 097/100] fixed minor issues in events --- events/scripts/channelUpdate/logEventToChannel.js | 2 +- events/scripts/guildMemberAdd/logEventToChannel.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/events/scripts/channelUpdate/logEventToChannel.js b/events/scripts/channelUpdate/logEventToChannel.js index 5b86307..5967f2f 100644 --- a/events/scripts/channelUpdate/logEventToChannel.js +++ b/events/scripts/channelUpdate/logEventToChannel.js @@ -59,7 +59,7 @@ module.exports = { if (oldChannel.rateLimitPerUser !== newChannel.rateLimitPerUser) { const logEmbed = embedMessageSuccessSecondaryColorWithFields( "Channel Updated: Slowmode", - `Channel slowmode was in <#${changedChannelId}>.`, + `Channel slowmode was changed in <#${changedChannelId}>.`, [ { name: "Channel name", value: `${newChannel.name}` || "Unknown", inline: true }, { name: "Channel Id", value: `${changedChannelId}` || "Unknown", inline: true }, diff --git a/events/scripts/guildMemberAdd/logEventToChannel.js b/events/scripts/guildMemberAdd/logEventToChannel.js index acf9fa5..6e3d408 100644 --- a/events/scripts/guildMemberAdd/logEventToChannel.js +++ b/events/scripts/guildMemberAdd/logEventToChannel.js @@ -4,7 +4,7 @@ const { embedMessageSuccessColorWithFields } = require("../../../helpers/embeds/ module.exports = { async sendLogInfo(client, member) { try { - const guild = await client.guilds.fetch(message.guild.id); + const guild = await client.guilds.fetch(member.guild.id); const { doesGuildExist, logChannelId } = await getGuildFromDB(member.guild.id); if (doesGuildExist) { From 9ef62c52c2c058a58a98e6a96b0beb487221ce86 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 15 Dec 2024 16:34:33 +0100 Subject: [PATCH 098/100] changed embed looks of messageDelete event logging --- events/scripts/messageDelete/logEventToChannel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/events/scripts/messageDelete/logEventToChannel.js b/events/scripts/messageDelete/logEventToChannel.js index fcb5d93..66ef20f 100644 --- a/events/scripts/messageDelete/logEventToChannel.js +++ b/events/scripts/messageDelete/logEventToChannel.js @@ -15,12 +15,12 @@ module.exports = { "A message was deleted.", [ { name: "Content", value: message.content || "No content available" }, + { name: "Author", value: message.author ? `<@${message.author.id}>` : "Unknown", inline: true }, + { name: "Author Username", value: message.author?.username || "Unknown", inline: true }, { name: "Channel", value: `<#${message.channelId}>` }, - { name: "Author", value: message.author ? `<@${message.author.id}>` : "Unknown" }, { name: "Message Id", value: message.id || "Unknown", inline: true }, { name: "Channel Id", value: message.channelId || "Unknown", inline: true }, { name: "Author Id", value: message.author?.id || "Unknown", inline: true }, - { name: "Author Username", value: message.author?.username || "Unknown", inline: true }, ] ); From c91e4dae9036c965bfdd5a0be9bdc7e59f91b321 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 15 Dec 2024 19:19:54 +0100 Subject: [PATCH 099/100] renamed sql query folder after the table --- sql/{configBridge => configBridging}/table.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sql/{configBridge => configBridging}/table.sql (100%) diff --git a/sql/configBridge/table.sql b/sql/configBridging/table.sql similarity index 100% rename from sql/configBridge/table.sql rename to sql/configBridging/table.sql From a1a4d0b45f7b9dc82cac0b5220895146033dd4d1 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Tue, 17 Dec 2024 20:46:04 +0100 Subject: [PATCH 100/100] added bridge commands to /help --- commands/utility/help.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands/utility/help.js b/commands/utility/help.js index 68c158c..66b85ed 100755 --- a/commands/utility/help.js +++ b/commands/utility/help.js @@ -73,6 +73,8 @@ module.exports = { "`/welcome-disable` - Disables the welcome messages feature. The bot won't send a welcome message on join anymore.\n" + "`/logging-configure` - Sets / modifies the channel where event on the server will get logged.\n" + "`/logging-disable` - Disables the logging feature. The bot won't log the events on the server anymore.\n" + + "`/bridge-configure` - Bridges all messages from one channel to another.\n" + + "`/bridge-disable` - Disables briding for a target channel.\n" + "`/rename` - Renames a specified user to a specified nickname in the current server." };