From 1ca24d6e5335122b604dc0961dbb936ca141f0a7 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Mon, 10 Nov 2025 14:33:22 +0100 Subject: [PATCH 01/43] updated packages --- package-lock.json | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index c995ab14..75d2e4de 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "discordbot", - "version": "4.0.1", + "version": "4.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "discordbot", - "version": "4.0.1", + "version": "4.1.1", "license": "AGPL-3.0-only", "dependencies": { "ajv": "^8.17.1", @@ -1176,9 +1176,9 @@ } }, "node_modules/@types/node": { - "version": "24.9.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.1.tgz", - "integrity": "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==", + "version": "24.10.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.0.tgz", + "integrity": "sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A==", "license": "MIT", "dependencies": { "undici-types": "~7.16.0" @@ -1438,9 +1438,9 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.8.20", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.20.tgz", - "integrity": "sha512-JMWsdF+O8Orq3EMukbUN1QfbLK9mX2CkUmQBcW2T0s8OmdAUL5LLM/6wFwSrqXzlXB13yhyK9gTKS1rIizOduQ==", + "version": "2.8.25", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.25.tgz", + "integrity": "sha512-2NovHVesVF5TXefsGX1yzx1xgr7+m9JQenvz6FQY3qd+YXkKkYiv+vTCc7OriP9mcDZpTC5mAOYN4ocd29+erA==", "dev": true, "license": "Apache-2.0", "bin": { @@ -1550,9 +1550,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001751", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001751.tgz", - "integrity": "sha512-A0QJhug0Ly64Ii3eIqHu5X51ebln3k4yTUkY1j8drqpWHVreg/VLijN48cZ1bYPiqOQuqpkIKnzr/Ul8V+p6Cw==", + "version": "1.0.30001754", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001754.tgz", + "integrity": "sha512-x6OeBXueoAceOmotzx3PO4Zpt4rzpeIFsSr6AAePTZxSkXiYDUmpypEl7e2+8NCd9bD7bXjqyef8CJYPC1jfxg==", "dev": true, "funding": [ { @@ -1883,18 +1883,18 @@ } }, "node_modules/discord-api-types": { - "version": "0.38.31", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.31.tgz", - "integrity": "sha512-kC94ANsk8ackj8ENTuO8joTNEL0KtymVhHy9dyEC/s4QAZ7GCx40dYEzQaadyo8w+oP0X8QydE/nzAWRylTGtQ==", + "version": "0.38.33", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.33.tgz", + "integrity": "sha512-oau1V7OzrNX8yNi+DfQpoLZCNCv7cTFmvPKwHfMrA/tewsO6iQKrMTzA7pa3iBSj0fED6NlklJ/1B/cC1kI08Q==", "license": "MIT", "workspaces": [ "scripts/actions/documentation" ] }, "node_modules/discord.js": { - "version": "14.24.0", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.24.0.tgz", - "integrity": "sha512-KNq/ekT8bsmT3ZAfVre8cPbl+DfVYSdlLnDmGZPoz7Cw21LYeWHllRA9MivqNq5b1GPGAxGvyUN1vxbTb/PQWw==", + "version": "14.24.2", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.24.2.tgz", + "integrity": "sha512-VMEDbmguRdX/EeMaTsf9Mb0IQA90WdYF2cn4QDfslQFXgQ6LFtmlPn0FSotnS0kcFbFp+JBSIxtnF+bnAHG/hQ==", "license": "Apache-2.0", "dependencies": { "@discordjs/builders": "^1.13.0", @@ -1995,9 +1995,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.240", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.240.tgz", - "integrity": "sha512-OBwbZjWgrCOH+g6uJsA2/7Twpas2OlepS9uvByJjR2datRDuKGYeD+nP8lBBks2qnB7bGJNHDUx7c/YLaT3QMQ==", + "version": "1.5.249", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.249.tgz", + "integrity": "sha512-5vcfL3BBe++qZ5kuFhD/p8WOM1N9m3nwvJPULJx+4xf2usSlZFJ0qoNYO2fOX4hi3ocuDcmDobtA+5SFr4OmBg==", "dev": true, "license": "ISC" }, @@ -3476,9 +3476,9 @@ "license": "MIT" }, "node_modules/node-releases": { - "version": "2.0.26", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.26.tgz", - "integrity": "sha512-S2M9YimhSjBSvYnlr5/+umAnPHE++ODwt5e2Ij6FoX45HA/s4vHdkDx1eax2pAPeAOqu4s9b7ppahsyEFdVqQA==", + "version": "2.0.27", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.27.tgz", + "integrity": "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==", "dev": true, "license": "MIT" }, From 3ad40c3e2ceddd2f208f9697ceb000dfdea0c1a5 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Mon, 10 Nov 2025 19:33:02 +0100 Subject: [PATCH 02/43] created darwin-random command --- src/commands/fun/darwin-random.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/commands/fun/darwin-random.js diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js new file mode 100644 index 00000000..440467fa --- /dev/null +++ b/src/commands/fun/darwin-random.js @@ -0,0 +1,14 @@ +import { SlashCommandBuilder } from "discord.js"; +import { query } from "../../helpers/db.js"; + +export default { + data: new SlashCommandBuilder() + .setName("darwin-random") + .setDescription("Sends back a random streamable video from Darwin's database.") + .setNSFW(false) + .setDMPermission(true), + async execute(interaction) { + const randomVideo = query("SELECT * COUNT FROM darwinCache"); + console.log(randomVideo); + }, +}; From f81cb0f5a042ccd88714a401642235106dc240dc Mon Sep 17 00:00:00 2001 From: VB2007 Date: Tue, 11 Nov 2025 09:22:55 +0100 Subject: [PATCH 03/43] created base logic to reply helper --- src/commands/fun/darwin-random.js | 20 ++++++++++++++++++-- src/helpers/reply.js | 9 +++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js index 440467fa..79327ef3 100644 --- a/src/commands/fun/darwin-random.js +++ b/src/commands/fun/darwin-random.js @@ -1,5 +1,7 @@ import { SlashCommandBuilder } from "discord.js"; import { query } from "../../helpers/db.js"; +import { embedReplyPrimaryColorWithFields } from "../../helpers/embeds/embed-reply.js"; +import { replyAndLogWithEmbedAndDescription } from "../../helpers/reply.js"; export default { data: new SlashCommandBuilder() @@ -8,7 +10,21 @@ export default { .setNSFW(false) .setDMPermission(true), async execute(interaction) { - const randomVideo = query("SELECT * COUNT FROM darwinCache"); - console.log(randomVideo); + const randomVideo = query( + "SELECT videoId, processedAt FROM darwinCache ORDER BY RAND() LIMIT 1;" + ); + + const embedReply = embedReplyPrimaryColorWithFields( + "Random video from Darwin's database", + "", + [ + { name: "Title", value: "", inline: false }, + { name: "Processed at", value: "", inline: true }, + { name: "Size", value: "", inline: true }, + ], + interaction + ); + + await replyAndLogWithEmbedAndDescription(interaction, embedReply, "a"); }, }; diff --git a/src/helpers/reply.js b/src/helpers/reply.js index d298ff8c..46e03cf8 100644 --- a/src/helpers/reply.js +++ b/src/helpers/reply.js @@ -4,3 +4,12 @@ export const replyAndLog = async (interaction, embedReply) => { await interaction.reply({ embeds: [embedReply] }); await logToFileAndDatabase(interaction, JSON.stringify(embedReply.toJSON())); }; + +export const replyAndLogWithEmbedAndDescription = async ( + interaction, + embedReply, + messageContent +) => { + await interaction.reply(messageContent, { embeds: [embedReply] }); + await logToFileAndDatabase(interaction, messageContent); +}; From 9f7060917ab7b0636adb85fe168a0f281b39cb1a Mon Sep 17 00:00:00 2001 From: VB2007 Date: Wed, 12 Nov 2025 18:54:39 +0100 Subject: [PATCH 04/43] updated cdn url in example config json --- config.json.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json.example b/config.json.example index 73425cb6..575393b8 100644 --- a/config.json.example +++ b/config.json.example @@ -38,6 +38,6 @@ "maxDownloadSize" : 50, "targetDir" : "/path/to/videos/folder", "tempDir" : "/path/to/videos/folder/transcodes", - "cdnUrl" : "https://cdn.vb2007.hu/darwin/" + "cdnUrl" : "https://cdn.vb2007.hu/darwin" } } From 55d597f2e3563ced4cf14708f8cd67b3883aabc0 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 13 Nov 2025 17:59:41 +0100 Subject: [PATCH 05/43] updated reply helper, started formatting message --- src/commands/fun/darwin-random.js | 12 ++++++++++-- src/helpers/reply.js | 8 ++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js index 79327ef3..71c618b6 100644 --- a/src/commands/fun/darwin-random.js +++ b/src/commands/fun/darwin-random.js @@ -1,7 +1,10 @@ import { SlashCommandBuilder } from "discord.js"; import { query } from "../../helpers/db.js"; import { embedReplyPrimaryColorWithFields } from "../../helpers/embeds/embed-reply.js"; -import { replyAndLogWithEmbedAndDescription } from "../../helpers/reply.js"; +import { baseReplyAndLog } from "../../helpers/reply.js"; + +import config from "../../../config.json" with { type: "json" }; +const darwinConfig = config.darwin; export default { data: new SlashCommandBuilder() @@ -14,6 +17,11 @@ export default { "SELECT videoId, processedAt FROM darwinCache ORDER BY RAND() LIMIT 1;" ); + const videoId = randomVideo[0].videoId; + const directStreamLink = `${darwinConfig.cdnUrl}/${videoId}.mp4`; + + const messageContent = `[[ STREAMING & DOWNLOAD ]](${directStreamLink}) - [[ FORUM POST ]](<${comments}>)\nTitle: {}\nProcessed at: {}\nSize: {}`; + const embedReply = embedReplyPrimaryColorWithFields( "Random video from Darwin's database", "", @@ -25,6 +33,6 @@ export default { interaction ); - await replyAndLogWithEmbedAndDescription(interaction, embedReply, "a"); + await baseReplyAndLog(messageContent, embedReply, "a"); }, }; diff --git a/src/helpers/reply.js b/src/helpers/reply.js index 46e03cf8..0b47be86 100644 --- a/src/helpers/reply.js +++ b/src/helpers/reply.js @@ -5,11 +5,7 @@ export const replyAndLog = async (interaction, embedReply) => { await logToFileAndDatabase(interaction, JSON.stringify(embedReply.toJSON())); }; -export const replyAndLogWithEmbedAndDescription = async ( - interaction, - embedReply, - messageContent -) => { - await interaction.reply(messageContent, { embeds: [embedReply] }); +export const baseReplyAndLog = async (interaction, message) => { + await interaction.reply(messageContent); await logToFileAndDatabase(interaction, messageContent); }; From d65820923adc64ed42fdbead665c3550b87398a2 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 13 Nov 2025 20:48:09 +0100 Subject: [PATCH 06/43] renamed, added columns to darwinCache table --- src/sql/darwinCache/table.sql | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sql/darwinCache/table.sql b/src/sql/darwinCache/table.sql index 1f1a396d..d26ebd63 100644 --- a/src/sql/darwinCache/table.sql +++ b/src/sql/darwinCache/table.sql @@ -2,9 +2,13 @@ CREATE TABLE IF NOT EXISTS `darwinCache` ( `id` INT AUTO_INCREMENT PRIMARY KEY, - `videoUrl` VARCHAR(255) NOT NULL, + `originalFileUrl` VARCHAR(255) NOT NULL, + `forumPostUrl` VARCHAR(255) NOT NULL, `videoId` VARCHAR(100) NOT NULL, + `videoTitle` VARCHAR(180) NOT NULL, + `originalFileSize` DECIMAL NOT NULL, + `processedFileSize` DECIMAL DEFAULT NULL, `processedAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY (`videoUrl`), UNIQUE KEY (`videoId`) -); \ No newline at end of file +); From 618dc45e8350676a671495a1180987eed7d8771b Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 19:21:00 +0100 Subject: [PATCH 07/43] created word-leaderboard.js command file --- src/commands/fun/word-leaderboard.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/commands/fun/word-leaderboard.js diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js new file mode 100644 index 00000000..9cbd5490 --- /dev/null +++ b/src/commands/fun/word-leaderboard.js @@ -0,0 +1,7 @@ +import { SlashCommandBuilder } from "discord.js"; +import { query } from "../../helpers/db.js"; + +export default { + data: new SlashCommandBuilder(), + async execute(interaction) {}, +}; From b0d96aa6571a631d08d4ca86ff7220d93c7bdd2f Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 19:23:28 +0100 Subject: [PATCH 08/43] created command builder for new command --- src/commands/fun/word-leaderboard.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index 9cbd5490..3653dd9c 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -2,6 +2,19 @@ import { SlashCommandBuilder } from "discord.js"; import { query } from "../../helpers/db.js"; export default { - data: new SlashCommandBuilder(), + data: new SlashCommandBuilder() + .setName("word-leaderboard") + .setDescription( + "Counts a specified word in the current server and sends back a leaderboard with the users who used that word the most." + ) + .addStringOption((option) => + option + .setName("word") + .setDescription("The word that will get counted.") + .setRequired(true) + .setMinLength(2) + .setMaxLength(12) + ) + .setDMPermission(false), async execute(interaction) {}, }; From ad00c9b3980ce528b6d0017f6a8499427d809982 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 19:24:56 +0100 Subject: [PATCH 09/43] added guild check --- src/commands/fun/word-leaderboard.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index 3653dd9c..9c8b6d42 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -1,4 +1,5 @@ import { SlashCommandBuilder } from "discord.js"; +import { embedReplyPrimaryColor } from "../../helpers/embeds/embed-reply.js"; import { query } from "../../helpers/db.js"; export default { @@ -16,5 +17,12 @@ export default { .setMaxLength(12) ) .setDMPermission(false), - async execute(interaction) {}, + async execute(interaction) { + const guildCheck = checkIfNotInGuild(commandName, interaction); + if (guildCheck) { + return await replyAndLog(interaction, guildCheck); + } + + const targetWord = interaction.options.getString("word"); + }, }; From d394b82b011507e7dd007674a64ec65adb83401d Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 19:25:07 +0100 Subject: [PATCH 10/43] updated packages --- package-lock.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 34701662..1d77c292 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "discordbot", - "version": "4.1.1", + "version": "4.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "discordbot", - "version": "4.1.1", + "version": "4.2.0", "license": "AGPL-3.0-only", "dependencies": { "ajv": "^8.17.1", @@ -1441,9 +1441,9 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.8.29", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.29.tgz", - "integrity": "sha512-sXdt2elaVnhpDNRDz+1BDx1JQoJRuNk7oVlAlbGiFkLikHCAQiccexF/9e91zVi6RCgqspl04aP+6Cnl9zRLrA==", + "version": "2.8.30", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.30.tgz", + "integrity": "sha512-aTUKW4ptQhS64+v2d6IkPzymEzzhw+G0bA1g3uBRV3+ntkH+svttKseW5IOR4Ed6NUVKqnY7qT3dKvzQ7io4AA==", "dev": true, "license": "Apache-2.0", "bin": { @@ -1553,9 +1553,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001755", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001755.tgz", - "integrity": "sha512-44V+Jm6ctPj7R52Na4TLi3Zri4dWUljJd+RDm+j8LtNCc/ihLCT+X1TzoOAkRETEWqjuLnh9581Tl80FvK7jVA==", + "version": "1.0.30001756", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001756.tgz", + "integrity": "sha512-4HnCNKbMLkLdhJz3TToeVWHSnfJvPaq6vu/eRP0Ahub/07n484XHhBF5AJoSGHdVrS8tKFauUQz8Bp9P7LVx7A==", "dev": true, "funding": [ { @@ -1998,9 +1998,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.256", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.256.tgz", - "integrity": "sha512-uqYq1IQhpXXLX+HgiXdyOZml7spy4xfy42yPxcCCRjswp0fYM2X+JwCON07lqnpLEGVCj739B7Yr+FngmHBMEQ==", + "version": "1.5.258", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.258.tgz", + "integrity": "sha512-rHUggNV5jKQ0sSdWwlaRDkFc3/rRJIVnOSe9yR4zrR07m3ZxhP4N27Hlg8VeJGGYgFTxK5NqDmWI4DSH72vIJg==", "dev": true, "license": "ISC" }, From d2af3193127fecfabee4a0077ff3d27369013f95 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 20:27:58 +0100 Subject: [PATCH 11/43] started implementation with query, added missing import --- src/commands/fun/word-leaderboard.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index 9c8b6d42..e5a2b054 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -1,12 +1,14 @@ import { SlashCommandBuilder } from "discord.js"; +import { checkIfNotInGuild } from "../../helpers/command-validation/general.js"; import { embedReplyPrimaryColor } from "../../helpers/embeds/embed-reply.js"; import { query } from "../../helpers/db.js"; export default { data: new SlashCommandBuilder() .setName("word-leaderboard") + // Counts a specified word in the current server and sends back a leaderboard with the users who used that word the most. .setDescription( - "Counts a specified word in the current server and sends back a leaderboard with the users who used that word the most." + "Gives back a word count leaderboard with the top users who used that word the most." ) .addStringOption((option) => option @@ -24,5 +26,12 @@ export default { } const targetWord = interaction.options.getString("word"); + const currentServerId = interaction.guild.id; + + const usersQuery = await db.query( + `SELECT COUNT(DISTINCT senderUserId), senderUserName FROM messageLog WHERE serverId = ${currentServerId} AND messageContent LIKE %${targetWord}%` + ); + + console.log(usersQuery); }, }; From 8003525a105d8f7f98ccc3e90dce9e7135859e51 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 20:29:55 +0100 Subject: [PATCH 12/43] commented out other debug darwin logs --- src/helpers/darwin/darwinCache.js | 4 ++-- src/index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/helpers/darwin/darwinCache.js b/src/helpers/darwin/darwinCache.js index d3b8ca10..b462fe7e 100644 --- a/src/helpers/darwin/darwinCache.js +++ b/src/helpers/darwin/darwinCache.js @@ -32,7 +32,7 @@ export const addToCache = async (directVideoUrl, forumPostUrl, videoTitle) => { try { const exists = await isInCache(directVideoUrl); if (exists) { - console.log(`URL already in cache: ${directVideoUrl}`); + // console.log(`URL already in cache: ${directVideoUrl}`); return true; } @@ -76,7 +76,7 @@ export const addToCache = async (directVideoUrl, forumPostUrl, videoTitle) => { export const isInCache = async (url) => { try { const videoId = extractVideoId(url); - console.log(`Checking "${url}" (ID: ${videoId}) in Darwin's cache`); + // console.log(`Checking "${url}" (ID: ${videoId}) in Darwin's cache`); const result = await query( "SELECT directVideoUrl FROM darwinCache WHERE directVideoUrl = ? OR videoId = ?", diff --git a/src/index.js b/src/index.js index b50936d9..b44fb321 100644 --- a/src/index.js +++ b/src/index.js @@ -79,7 +79,7 @@ client.once(Events.ClientReady, (readyClient) => { setInterval(() => { if (darwinProcessRunning) { - console.log("Darwin process already running, skipping this execution"); + // console.log("Darwin process already running, skipping this execution"); return; } From aab83c07c806ca3abc4b5fb083f173acf4fde664 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 20:31:21 +0100 Subject: [PATCH 13/43] fixed errors in new command --- src/commands/fun/word-leaderboard.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index e5a2b054..45ec7851 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -3,9 +3,11 @@ import { checkIfNotInGuild } from "../../helpers/command-validation/general.js"; import { embedReplyPrimaryColor } from "../../helpers/embeds/embed-reply.js"; import { query } from "../../helpers/db.js"; +const commandName = "word-leaderboard"; + export default { data: new SlashCommandBuilder() - .setName("word-leaderboard") + .setName(commandName) // Counts a specified word in the current server and sends back a leaderboard with the users who used that word the most. .setDescription( "Gives back a word count leaderboard with the top users who used that word the most." @@ -28,7 +30,7 @@ export default { const targetWord = interaction.options.getString("word"); const currentServerId = interaction.guild.id; - const usersQuery = await db.query( + const usersQuery = await query( `SELECT COUNT(DISTINCT senderUserId), senderUserName FROM messageLog WHERE serverId = ${currentServerId} AND messageContent LIKE %${targetWord}%` ); From f803002144e482ae24ff815ce9fef31d06b2f9d7 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 21:04:22 +0100 Subject: [PATCH 14/43] fixed sql query --- src/commands/fun/word-leaderboard.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index 45ec7851..c90b1f9c 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -31,7 +31,13 @@ export default { const currentServerId = interaction.guild.id; const usersQuery = await query( - `SELECT COUNT(DISTINCT senderUserId), senderUserName FROM messageLog WHERE serverId = ${currentServerId} AND messageContent LIKE %${targetWord}%` + `SELECT senderUserId, senderUserName, COUNT(*) as wordCount + FROM messageLog + WHERE serverId = ? AND messageContent LIKE ? + GROUP BY senderUserId + ORDER BY wordCount DESC + LIMIT 10`, + [currentServerId, `%${targetWord}%`] ); console.log(usersQuery); From 796a3e71bb646b4bc9666e48c5cccd58352c680f Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 21:11:36 +0100 Subject: [PATCH 15/43] updated imports, started writing embed reply --- src/commands/fun/word-leaderboard.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index c90b1f9c..7725fd30 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -1,7 +1,8 @@ import { SlashCommandBuilder } from "discord.js"; -import { checkIfNotInGuild } from "../../helpers/command-validation/general.js"; import { embedReplyPrimaryColor } from "../../helpers/embeds/embed-reply.js"; import { query } from "../../helpers/db.js"; +import { checkIfNotInGuild } from "../../helpers/command-validation/general.js"; +import { replyAndLog } from "../../helpers/reply.js"; const commandName = "word-leaderboard"; @@ -39,7 +40,10 @@ export default { LIMIT 10`, [currentServerId, `%${targetWord}%`] ); - console.log(usersQuery); + + const embedReply = embedReplyPrimaryColor(`Word Leaderboard: "${targetWord}"`, "", interaction); + + return replyAndLog(interaction, embedReply); }, }; From 457acd09dfb5724c5deb0970654dd0339c75ea2c Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 21:30:16 +0100 Subject: [PATCH 16/43] commented out messageCreate console logs --- src/events/scripts/messageCreate/messageLogging.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/events/scripts/messageCreate/messageLogging.js b/src/events/scripts/messageCreate/messageLogging.js index 01c9bca3..52b52804 100644 --- a/src/events/scripts/messageCreate/messageLogging.js +++ b/src/events/scripts/messageCreate/messageLogging.js @@ -29,9 +29,9 @@ export const logToDB = async (message) => { ] ); - console.log( - `Logged message "${message.content}" to database from ${senderUserName} in ${serverName}.` - ); + // console.log( + // `Logged message "${message.content}" to database from ${senderUserName} in ${serverName}.` + // ); } } } catch (error) { From f8699b96a5fd11a0a3ce45087fed86dd03e04530 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 21:36:45 +0100 Subject: [PATCH 17/43] added 1st part of the description to embed builder --- src/commands/fun/word-leaderboard.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index 7725fd30..618a5a2a 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -42,7 +42,11 @@ export default { ); console.log(usersQuery); - const embedReply = embedReplyPrimaryColor(`Word Leaderboard: "${targetWord}"`, "", interaction); + const embedReply = embedReplyPrimaryColor( + `Word Leaderboard: "${targetWord}"`, + `${usersQuery.length !== 0 ? `Leaderboard of users whose messages contained the word "${targetWord}" the most:` : `No user has used the word "${targetWord}" in their messages so far.`}`, + interaction + ); return replyAndLog(interaction, embedReply); }, From 31a85b0a2712202aa66a8336af63e622c57fe6b4 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 20 Nov 2025 21:37:32 +0100 Subject: [PATCH 18/43] updated embed description formatting --- src/commands/fun/word-leaderboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index 618a5a2a..abcb2798 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -44,7 +44,7 @@ export default { const embedReply = embedReplyPrimaryColor( `Word Leaderboard: "${targetWord}"`, - `${usersQuery.length !== 0 ? `Leaderboard of users whose messages contained the word "${targetWord}" the most:` : `No user has used the word "${targetWord}" in their messages so far.`}`, + `${usersQuery.length !== 0 ? `Leaderboard of users whose messages contained the word **${targetWord}** the most:` : `No user has used the word **${targetWord}** in their messages so far.`}`, interaction ); From a893529198d5916f5818858392ed8d010157f261 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 00:06:47 +0100 Subject: [PATCH 19/43] deleted already executed migration script --- src/sql/darwinCache/migrate-to-new-schema.sql | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 src/sql/darwinCache/migrate-to-new-schema.sql diff --git a/src/sql/darwinCache/migrate-to-new-schema.sql b/src/sql/darwinCache/migrate-to-new-schema.sql deleted file mode 100644 index 22c9bb2a..00000000 --- a/src/sql/darwinCache/migrate-to-new-schema.sql +++ /dev/null @@ -1,14 +0,0 @@ -ALTER TABLE `darwinCache` -CHANGE COLUMN `videoUrl` `directVideoUrl` VARCHAR(255) NOT NULL; - -ALTER TABLE `darwinCache` -ADD COLUMN `forumPostUrl` VARCHAR(255) NOT NULL DEFAULT '' AFTER `directVideoUrl`, -ADD COLUMN `videoTitle` VARCHAR(180) NOT NULL DEFAULT '' AFTER `videoId`; - -ALTER TABLE `darwinCache` -DROP INDEX `videoUrl`; - -ALTER TABLE `darwinCache` -ADD UNIQUE KEY `directVideoUrl` (`directVideoUrl`); - -DESCRIBE `darwinCache`; From 69e303576a0215f4e2052890b6b2da4aa84722c4 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 00:15:32 +0100 Subject: [PATCH 20/43] added logic for displaying leaderboard --- src/commands/fun/word-leaderboard.js | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index abcb2798..b449c788 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -42,9 +42,37 @@ export default { ); console.log(usersQuery); + let leaderboardContent; + const positionEmojis = { + 1: ":first_place:", + 2: ":second_place:", + 3: ":third_place:", + 4: ":number_4:", + 5: ":number_5:", + 6: ":number_6:", + 7: ":number_7:", + 8: ":number_8:", + 9: ":number_9:", + 10: ":number_10:", + }; + + for (let i = 0; i < usersQuery.length; i++) { + const userResult = usersQuery[i]; + const emoji = positionEmojis[i + 1]; + + const username = + (await interaction.guild.members.fetch(userResult.senderUserId).user.username) || + userResult.senderUserName || + "Unkown username"; + + leaderboardContent += `${emoji} <@${userResult.senderUserId}> (${username}): **#${userResult.wordCount}**\n`; + } + const embedReply = embedReplyPrimaryColor( `Word Leaderboard: "${targetWord}"`, - `${usersQuery.length !== 0 ? `Leaderboard of users whose messages contained the word **${targetWord}** the most:` : `No user has used the word **${targetWord}** in their messages so far.`}`, + usersQuery.length !== 0 + ? `Leaderboard of users whose messages contained the word **${targetWord}** the most:\n\n${leaderboardContent}` + : `No user has used the word **${targetWord}** in their messages so far.`, interaction ); From 47962d3b6e837ba94621c38eb44b51238a4d6fb2 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 00:15:47 +0100 Subject: [PATCH 21/43] fixed promise error --- src/commands/fun/word-leaderboard.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index b449c788..363dbe28 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -60,10 +60,13 @@ export default { const userResult = usersQuery[i]; const emoji = positionEmojis[i + 1]; - const username = - (await interaction.guild.members.fetch(userResult.senderUserId).user.username) || - userResult.senderUserName || - "Unkown username"; + let username; + try { + const member = await interaction.guild.members.fetch(userResult.senderUserId); + username = member.user.username; + } catch (error) { + username = userResult.senderUserName || "Unknown username"; + } leaderboardContent += `${emoji} <@${userResult.senderUserId}> (${username}): **#${userResult.wordCount}**\n`; } From ef9875c74bc00d7a6818e67207cdb5d456a125cd Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 00:18:04 +0100 Subject: [PATCH 22/43] fixed undefined error --- src/commands/fun/word-leaderboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index 363dbe28..e578b8a0 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -42,7 +42,7 @@ export default { ); console.log(usersQuery); - let leaderboardContent; + let leaderboardContent = ""; const positionEmojis = { 1: ":first_place:", 2: ":second_place:", From e346dcaebcecf3f2f340a10fe9a41d27cdcec414 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 00:21:02 +0100 Subject: [PATCH 23/43] moved positionEmojis to format helper --- src/commands/fun/word-leaderboard.js | 16 ++-------------- src/helpers/format.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index e578b8a0..50b74521 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -1,8 +1,9 @@ import { SlashCommandBuilder } from "discord.js"; import { embedReplyPrimaryColor } from "../../helpers/embeds/embed-reply.js"; -import { query } from "../../helpers/db.js"; +import { positionEmojis } from "../../helpers/format.js"; import { checkIfNotInGuild } from "../../helpers/command-validation/general.js"; import { replyAndLog } from "../../helpers/reply.js"; +import { query } from "../../helpers/db.js"; const commandName = "word-leaderboard"; @@ -43,19 +44,6 @@ export default { console.log(usersQuery); let leaderboardContent = ""; - const positionEmojis = { - 1: ":first_place:", - 2: ":second_place:", - 3: ":third_place:", - 4: ":number_4:", - 5: ":number_5:", - 6: ":number_6:", - 7: ":number_7:", - 8: ":number_8:", - 9: ":number_9:", - 10: ":number_10:", - }; - for (let i = 0; i < usersQuery.length; i++) { const userResult = usersQuery[i]; const emoji = positionEmojis[i + 1]; diff --git a/src/helpers/format.js b/src/helpers/format.js index a6744d52..a9abded9 100644 --- a/src/helpers/format.js +++ b/src/helpers/format.js @@ -15,3 +15,16 @@ export const formatRouletteColor = (color) => { console.error("The color you've provided for the formatRouletteColor() function is invalid."); } }; + +export const positionEmojis = { + 1: ":first_place:", + 2: ":second_place:", + 3: ":third_place:", + 4: ":number_4:", + 5: ":number_5:", + 6: ":number_6:", + 7: ":number_7:", + 8: ":number_8:", + 9: ":number_9:", + 10: ":number_10:", +}; From ffc3ef56f0b5db22ec788bd226ebcb58c964c1c2 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 00:35:58 +0100 Subject: [PATCH 24/43] changed reply method to deferReply to avoid timeouts --- src/commands/fun/word-leaderboard.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index 50b74521..6de35bbd 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -2,7 +2,7 @@ import { SlashCommandBuilder } from "discord.js"; import { embedReplyPrimaryColor } from "../../helpers/embeds/embed-reply.js"; import { positionEmojis } from "../../helpers/format.js"; import { checkIfNotInGuild } from "../../helpers/command-validation/general.js"; -import { replyAndLog } from "../../helpers/reply.js"; +import { logToFileAndDatabase } from "../../helpers/logger.js"; import { query } from "../../helpers/db.js"; const commandName = "word-leaderboard"; @@ -24,6 +24,8 @@ export default { ) .setDMPermission(false), async execute(interaction) { + await interaction.deferReply(); + const guildCheck = checkIfNotInGuild(commandName, interaction); if (guildCheck) { return await replyAndLog(interaction, guildCheck); @@ -63,10 +65,11 @@ export default { `Word Leaderboard: "${targetWord}"`, usersQuery.length !== 0 ? `Leaderboard of users whose messages contained the word **${targetWord}** the most:\n\n${leaderboardContent}` - : `No user has used the word **${targetWord}** in their messages so far.`, + : `:x: No user has used the word **${targetWord}** in their messages so far.`, interaction ); - return replyAndLog(interaction, embedReply); + await interaction.editReply({ embeds: [embedReply] }); + await logToFileAndDatabase(interaction, JSON.stringify(embedReply.toJSON())); }, }; From 5368c3928e853fd4ed10c69f282a20df07d3b018 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 00:40:17 +0100 Subject: [PATCH 25/43] removed debug console logging --- src/commands/fun/word-leaderboard.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/fun/word-leaderboard.js b/src/commands/fun/word-leaderboard.js index 6de35bbd..3f119bd6 100644 --- a/src/commands/fun/word-leaderboard.js +++ b/src/commands/fun/word-leaderboard.js @@ -43,7 +43,6 @@ export default { LIMIT 10`, [currentServerId, `%${targetWord}%`] ); - console.log(usersQuery); let leaderboardContent = ""; for (let i = 0; i < usersQuery.length; i++) { From 80d50cceb7ef7648eb6d59d28ee5e3dc1e9194a1 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 01:59:07 +0100 Subject: [PATCH 26/43] added word-leaderboard to commandData --- src/data/commandData.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data/commandData.csv b/src/data/commandData.csv index 5881c8d7..14e202d6 100644 --- a/src/data/commandData.csv +++ b/src/data/commandData.csv @@ -37,3 +37,4 @@ 193,cigany,fun,"Says ""fuj"" and sends a random pic of a ""person"" from a specific race." 194,cooldown,economy,Lets you check your or other users economy cooldowns for all or a specified economy command. 195,invite,utility,Gives you back a link for inviting the bot to any server where you have permissions to do so. +652,word-leaderboard,fun,Counts a specified word in the current server and sends back a leaderboard with the users who used that word the most through all their previous messages. From 3d1f08c26e0222f846ac72a7444d5076938de6c2 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 02:48:53 +0100 Subject: [PATCH 27/43] fixed merge conflict in package-lock --- package-lock.json | 42 +++--------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8455b2e6..34fa74b7 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1179,15 +1179,9 @@ } }, "node_modules/@types/node": { -<<<<<<< HEAD - "version": "24.10.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.0.tgz", - "integrity": "sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A==", -======= "version": "24.10.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz", "integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==", ->>>>>>> dev "license": "MIT", "dependencies": { "undici-types": "~7.16.0" @@ -1447,15 +1441,9 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { -<<<<<<< HEAD - "version": "2.8.25", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.25.tgz", - "integrity": "sha512-2NovHVesVF5TXefsGX1yzx1xgr7+m9JQenvz6FQY3qd+YXkKkYiv+vTCc7OriP9mcDZpTC5mAOYN4ocd29+erA==", -======= "version": "2.8.30", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.30.tgz", "integrity": "sha512-aTUKW4ptQhS64+v2d6IkPzymEzzhw+G0bA1g3uBRV3+ntkH+svttKseW5IOR4Ed6NUVKqnY7qT3dKvzQ7io4AA==", ->>>>>>> dev "dev": true, "license": "Apache-2.0", "bin": { @@ -1565,15 +1553,9 @@ } }, "node_modules/caniuse-lite": { -<<<<<<< HEAD - "version": "1.0.30001754", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001754.tgz", - "integrity": "sha512-x6OeBXueoAceOmotzx3PO4Zpt4rzpeIFsSr6AAePTZxSkXiYDUmpypEl7e2+8NCd9bD7bXjqyef8CJYPC1jfxg==", -======= "version": "1.0.30001756", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001756.tgz", "integrity": "sha512-4HnCNKbMLkLdhJz3TToeVWHSnfJvPaq6vu/eRP0Ahub/07n484XHhBF5AJoSGHdVrS8tKFauUQz8Bp9P7LVx7A==", ->>>>>>> dev "dev": true, "funding": [ { @@ -1904,30 +1886,18 @@ } }, "node_modules/discord-api-types": { -<<<<<<< HEAD - "version": "0.38.33", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.33.tgz", - "integrity": "sha512-oau1V7OzrNX8yNi+DfQpoLZCNCv7cTFmvPKwHfMrA/tewsO6iQKrMTzA7pa3iBSj0fED6NlklJ/1B/cC1kI08Q==", -======= "version": "0.38.34", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.34.tgz", "integrity": "sha512-muq7xKGznj5MSFCzuIm/2TO7DpttuomUTemVM82fRqgnMl70YRzEyY24jlbiV6R9tzOTq6A6UnZ0bsfZeKD38Q==", ->>>>>>> dev "license": "MIT", "workspaces": [ "scripts/actions/documentation" ] }, "node_modules/discord.js": { -<<<<<<< HEAD - "version": "14.24.2", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.24.2.tgz", - "integrity": "sha512-VMEDbmguRdX/EeMaTsf9Mb0IQA90WdYF2cn4QDfslQFXgQ6LFtmlPn0FSotnS0kcFbFp+JBSIxtnF+bnAHG/hQ==", -======= "version": "14.25.0", "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.25.0.tgz", "integrity": "sha512-9rnJWTAkfauKTieYJ3oI4oncrSzpbJPWN1/XU+2H6wsHQPtqbOrXvgM0nFhSVnIbTo7nfUF7fzcYRevvRGjpzA==", ->>>>>>> dev "license": "Apache-2.0", "dependencies": { "@discordjs/builders": "^1.13.0", @@ -2028,15 +1998,9 @@ } }, "node_modules/electron-to-chromium": { -<<<<<<< HEAD - "version": "1.5.249", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.249.tgz", - "integrity": "sha512-5vcfL3BBe++qZ5kuFhD/p8WOM1N9m3nwvJPULJx+4xf2usSlZFJ0qoNYO2fOX4hi3ocuDcmDobtA+5SFr4OmBg==", -======= - "version": "1.5.258", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.258.tgz", - "integrity": "sha512-rHUggNV5jKQ0sSdWwlaRDkFc3/rRJIVnOSe9yR4zrR07m3ZxhP4N27Hlg8VeJGGYgFTxK5NqDmWI4DSH72vIJg==", ->>>>>>> dev + "version": "1.5.259", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.259.tgz", + "integrity": "sha512-I+oLXgpEJzD6Cwuwt1gYjxsDmu/S/Kd41mmLA3O+/uH2pFRO/DvOjUyGozL8j3KeLV6WyZ7ssPwELMsXCcsJAQ==", "dev": true, "license": "ISC" }, From 453bc33b6948679ca33444407f58e29c175132e0 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 03:12:45 +0100 Subject: [PATCH 28/43] fixed query in /darwin-random --- src/commands/fun/darwin-random.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js index 71c618b6..6524e981 100644 --- a/src/commands/fun/darwin-random.js +++ b/src/commands/fun/darwin-random.js @@ -14,7 +14,12 @@ export default { .setDMPermission(true), async execute(interaction) { const randomVideo = query( - "SELECT videoId, processedAt FROM darwinCache ORDER BY RAND() LIMIT 1;" + `SELECT originalFileUrl, forumPostUrl, title, processedAt + FROM darwinCache + WHERE forumPostUrl IS NOT NULL + AND title IS NOT NULL + ORDER BY RANDOM() + LIMIT 1` ); const videoId = randomVideo[0].videoId; From 98c43140f5214cf05251a13ad600a531d6c54ac4 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 03:19:20 +0100 Subject: [PATCH 29/43] updated message format & query --- src/commands/fun/darwin-random.js | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js index 6524e981..cbaee770 100644 --- a/src/commands/fun/darwin-random.js +++ b/src/commands/fun/darwin-random.js @@ -14,30 +14,23 @@ export default { .setDMPermission(true), async execute(interaction) { const randomVideo = query( - `SELECT originalFileUrl, forumPostUrl, title, processedAt + `SELECT directVideoUrl, forumPostUrl, videoTitle, processedAt FROM darwinCache WHERE forumPostUrl IS NOT NULL - AND title IS NOT NULL - ORDER BY RANDOM() + AND videoTitle IS NOT NULL + ORDER BY RAND() LIMIT 1` ); - const videoId = randomVideo[0].videoId; - const directStreamLink = `${darwinConfig.cdnUrl}/${videoId}.mp4`; + const directVideoUrl = randomVideo[0].directVideoUrl; + const forumPostUrl = randomVideo[0].forumPostUrl; + const videoTitle = randomVideo[0].videoTitle; + const processedAt = randomVideo[0].processedAt; - const messageContent = `[[ STREAMING & DOWNLOAD ]](${directStreamLink}) - [[ FORUM POST ]](<${comments}>)\nTitle: {}\nProcessed at: {}\nSize: {}`; + const messageContent = `[[ STREAMING & DOWNLOAD ]](${directVideoUrl}) - [[ FORUM POST ]](<${forumPostUrl}>)\n + Title: ${videoTitle} + \nProcessed at: ${processedAt}`; - const embedReply = embedReplyPrimaryColorWithFields( - "Random video from Darwin's database", - "", - [ - { name: "Title", value: "", inline: false }, - { name: "Processed at", value: "", inline: true }, - { name: "Size", value: "", inline: true }, - ], - interaction - ); - - await baseReplyAndLog(messageContent, embedReply, "a"); + await baseReplyAndLog(messageContent, messageContent); }, }; From cc9009e068ce9275e37cf5974d61d2ca136c14a7 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 03:19:30 +0100 Subject: [PATCH 30/43] updated column name in sql file --- src/sql/darwinCache/table.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sql/darwinCache/table.sql b/src/sql/darwinCache/table.sql index 45a23973..ed284b81 100644 --- a/src/sql/darwinCache/table.sql +++ b/src/sql/darwinCache/table.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `darwinCache` ( `id` INT AUTO_INCREMENT PRIMARY KEY, - `originalFileUrl` VARCHAR(255) NOT NULL, + `directVideoUrl` VARCHAR(255) NOT NULL, `forumPostUrl` VARCHAR(255) NOT NULL, `videoId` VARCHAR(100) NOT NULL, `videoTitle` VARCHAR(180) NOT NULL, From 205dabce6b627d3c8baae598dea96024ecf4064a Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 03:24:30 +0100 Subject: [PATCH 31/43] fixed var name in reply helper, updated messageContent formatting --- src/commands/fun/darwin-random.js | 13 ++++++++----- src/helpers/reply.js | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js index cbaee770..8e4409f5 100644 --- a/src/commands/fun/darwin-random.js +++ b/src/commands/fun/darwin-random.js @@ -13,7 +13,7 @@ export default { .setNSFW(false) .setDMPermission(true), async execute(interaction) { - const randomVideo = query( + const randomVideo = await query( `SELECT directVideoUrl, forumPostUrl, videoTitle, processedAt FROM darwinCache WHERE forumPostUrl IS NOT NULL @@ -22,15 +22,18 @@ export default { LIMIT 1` ); + console.log(randomVideo); + const directVideoUrl = randomVideo[0].directVideoUrl; const forumPostUrl = randomVideo[0].forumPostUrl; const videoTitle = randomVideo[0].videoTitle; const processedAt = randomVideo[0].processedAt; - const messageContent = `[[ STREAMING & DOWNLOAD ]](${directVideoUrl}) - [[ FORUM POST ]](<${forumPostUrl}>)\n - Title: ${videoTitle} - \nProcessed at: ${processedAt}`; + const messageContent = + `[[ STREAMING & DOWNLOAD ]](${directVideoUrl}) - [[ FORUM POST ]](<${forumPostUrl}>)\n` + + `**Title**: ${videoTitle}\n` + + `**Processed at**: ${processedAt}`; - await baseReplyAndLog(messageContent, messageContent); + await baseReplyAndLog(interaction, messageContent); }, }; diff --git a/src/helpers/reply.js b/src/helpers/reply.js index 0b47be86..f3324ba6 100644 --- a/src/helpers/reply.js +++ b/src/helpers/reply.js @@ -5,7 +5,7 @@ export const replyAndLog = async (interaction, embedReply) => { await logToFileAndDatabase(interaction, JSON.stringify(embedReply.toJSON())); }; -export const baseReplyAndLog = async (interaction, message) => { +export const baseReplyAndLog = async (interaction, messageContent) => { await interaction.reply(messageContent); await logToFileAndDatabase(interaction, messageContent); }; From 77b37e140a953ee894efcabfb14e430d76b37ff8 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 03:28:05 +0100 Subject: [PATCH 32/43] updated processedAt time formatting --- src/commands/fun/darwin-random.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js index 8e4409f5..167056a0 100644 --- a/src/commands/fun/darwin-random.js +++ b/src/commands/fun/darwin-random.js @@ -27,12 +27,12 @@ export default { const directVideoUrl = randomVideo[0].directVideoUrl; const forumPostUrl = randomVideo[0].forumPostUrl; const videoTitle = randomVideo[0].videoTitle; - const processedAt = randomVideo[0].processedAt; + const processedAt = Math.floor(new Date(randomVideo[0].processedAt).getTime() / 1000); const messageContent = `[[ STREAMING & DOWNLOAD ]](${directVideoUrl}) - [[ FORUM POST ]](<${forumPostUrl}>)\n` + `**Title**: ${videoTitle}\n` + - `**Processed at**: ${processedAt}`; + `**Processed at**: `; await baseReplyAndLog(interaction, messageContent); }, From fa17c8d146382d8a437e6e8d7d90a27d8024ab21 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Fri, 21 Nov 2025 03:29:29 +0100 Subject: [PATCH 33/43] changed processedAt formatting to relative time --- src/commands/fun/darwin-random.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js index 167056a0..51eaeefe 100644 --- a/src/commands/fun/darwin-random.js +++ b/src/commands/fun/darwin-random.js @@ -32,7 +32,7 @@ export default { const messageContent = `[[ STREAMING & DOWNLOAD ]](${directVideoUrl}) - [[ FORUM POST ]](<${forumPostUrl}>)\n` + `**Title**: ${videoTitle}\n` + - `**Processed at**: `; + `**Processed at**: `; await baseReplyAndLog(interaction, messageContent); }, From 1c5c042fc34721af0bb9ea436222cfe0a4920795 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 22 Nov 2025 21:51:33 +0100 Subject: [PATCH 34/43] removed unused imports --- src/commands/fun/darwin-random.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js index 51eaeefe..d7b41b6d 100644 --- a/src/commands/fun/darwin-random.js +++ b/src/commands/fun/darwin-random.js @@ -1,11 +1,7 @@ import { SlashCommandBuilder } from "discord.js"; import { query } from "../../helpers/db.js"; -import { embedReplyPrimaryColorWithFields } from "../../helpers/embeds/embed-reply.js"; import { baseReplyAndLog } from "../../helpers/reply.js"; -import config from "../../../config.json" with { type: "json" }; -const darwinConfig = config.darwin; - export default { data: new SlashCommandBuilder() .setName("darwin-random") From 22dc9046354fa4ff134007d04c4fa379ccd58111 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 22 Nov 2025 21:51:41 +0100 Subject: [PATCH 35/43] removed debug logging --- src/commands/fun/darwin-random.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js index d7b41b6d..135a0d43 100644 --- a/src/commands/fun/darwin-random.js +++ b/src/commands/fun/darwin-random.js @@ -18,8 +18,6 @@ export default { LIMIT 1` ); - console.log(randomVideo); - const directVideoUrl = randomVideo[0].directVideoUrl; const forumPostUrl = randomVideo[0].forumPostUrl; const videoTitle = randomVideo[0].videoTitle; From df3dbbdba489c7cc72c62ec9ae8c9340a55928d9 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 22 Nov 2025 21:51:55 +0100 Subject: [PATCH 36/43] updated packages --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 34fa74b7..3cf82b2c 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1895,9 +1895,9 @@ ] }, "node_modules/discord.js": { - "version": "14.25.0", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.25.0.tgz", - "integrity": "sha512-9rnJWTAkfauKTieYJ3oI4oncrSzpbJPWN1/XU+2H6wsHQPtqbOrXvgM0nFhSVnIbTo7nfUF7fzcYRevvRGjpzA==", + "version": "14.25.1", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.25.1.tgz", + "integrity": "sha512-2l0gsPOLPs5t6GFZfQZKnL1OJNYFcuC/ETWsW4VtKVD/tg4ICa9x+jb9bkPffkMdRpRpuUaO/fKkHCBeiCKh8g==", "license": "Apache-2.0", "dependencies": { "@discordjs/builders": "^1.13.0", From 97127ae931c0b9c9d274bd885a8e9c24e31110bc Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 22 Nov 2025 21:56:19 +0100 Subject: [PATCH 37/43] made title bold in darwinProcess --- src/helpers/darwin/darwinProcess.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/darwin/darwinProcess.js b/src/helpers/darwin/darwinProcess.js index 977b2167..c517655d 100644 --- a/src/helpers/darwin/darwinProcess.js +++ b/src/helpers/darwin/darwinProcess.js @@ -77,7 +77,7 @@ const getVideoLocation = async (href, markerOne, markerTwo) => { * @returns {string} - Formatted message */ const messageGen = (title, href, comments) => { - return `[[ STREAMING & DOWNLOAD ]](${href}) - [[ FORUM POST ]](<${comments}>)\n${title}`; + return `[[ STREAMING & DOWNLOAD ]](${href}) - [[ FORUM POST ]](<${comments}>)\n**${title}**`; }; /** From a10adeae0f5d1a8bf954e11e0146e5a414dc686c Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 22 Nov 2025 21:57:48 +0100 Subject: [PATCH 38/43] fdiscord --- src/commands/fun/darwin-random.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js index 135a0d43..8e0ac20f 100644 --- a/src/commands/fun/darwin-random.js +++ b/src/commands/fun/darwin-random.js @@ -6,7 +6,7 @@ export default { data: new SlashCommandBuilder() .setName("darwin-random") .setDescription("Sends back a random streamable video from Darwin's database.") - .setNSFW(false) + .setNSFW(false) //should be true, but fucking discord forces id checks to view NSFW channel. i won't comply. .setDMPermission(true), async execute(interaction) { const randomVideo = await query( From bceda5387bcf58f42418ce0929c0ec0374246cb3 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 22 Nov 2025 22:01:10 +0100 Subject: [PATCH 39/43] updated darwinCache table schema declaration from prod db DDL --- src/sql/darwinCache/table.sql | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/sql/darwinCache/table.sql b/src/sql/darwinCache/table.sql index ed284b81..86ec5e5e 100644 --- a/src/sql/darwinCache/table.sql +++ b/src/sql/darwinCache/table.sql @@ -1,14 +1,13 @@ -- discordbot.darwinCache definition -CREATE TABLE IF NOT EXISTS `darwinCache` ( - `id` INT AUTO_INCREMENT PRIMARY KEY, - `directVideoUrl` VARCHAR(255) NOT NULL, - `forumPostUrl` VARCHAR(255) NOT NULL, - `videoId` VARCHAR(100) NOT NULL, - `videoTitle` VARCHAR(180) NOT NULL, - `originalFileSize` DECIMAL NOT NULL, - `processedFileSize` DECIMAL DEFAULT NULL, - `processedAt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - UNIQUE KEY (`directVideoUrl`), - UNIQUE KEY (`videoId`) +CREATE TABLE `darwinCache` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `directVideoUrl` varchar(255) NOT NULL, + `forumPostUrl` varchar(255) NOT NULL DEFAULT '', + `videoId` varchar(100) NOT NULL, + `videoTitle` varchar(180) NOT NULL DEFAULT '', + `processedAt` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `videoId` (`videoId`), + UNIQUE KEY `directVideoUrl` (`directVideoUrl`) ); From 2f1b8d69a0522e5391f22300d2e5432da2aeb7d2 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 22 Nov 2025 22:02:36 +0100 Subject: [PATCH 40/43] removed unneded config values from example config.json file --- config.json.example | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/config.json.example b/config.json.example index 575393b8..d45f9190 100644 --- a/config.json.example +++ b/config.json.example @@ -34,10 +34,6 @@ "feedUrl" : "https://theync.com/most-recent/", "interval" : 120000, "markerOne" : "https://theync.com/media/video", - "markerTwo" : "https://theync.com", - "maxDownloadSize" : 50, - "targetDir" : "/path/to/videos/folder", - "tempDir" : "/path/to/videos/folder/transcodes", - "cdnUrl" : "https://cdn.vb2007.hu/darwin" + "markerTwo" : "https://theync.com" } } From 5c439369f4f1bc61b0adbc7ce72e57c9f3020063 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 22 Nov 2025 22:13:10 +0100 Subject: [PATCH 41/43] updated commandData + fixed auto increment --- src/commands/fun/darwin-random.js | 2 +- src/data/commandData.csv | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/commands/fun/darwin-random.js b/src/commands/fun/darwin-random.js index 8e0ac20f..285e3e19 100644 --- a/src/commands/fun/darwin-random.js +++ b/src/commands/fun/darwin-random.js @@ -5,7 +5,7 @@ import { baseReplyAndLog } from "../../helpers/reply.js"; export default { data: new SlashCommandBuilder() .setName("darwin-random") - .setDescription("Sends back a random streamable video from Darwin's database.") + .setDescription("Sends back a random, streamable video from Darwin's database.") .setNSFW(false) //should be true, but fucking discord forces id checks to view NSFW channel. i won't comply. .setDMPermission(true), async execute(interaction) { diff --git a/src/data/commandData.csv b/src/data/commandData.csv index 14e202d6..116ddc6c 100644 --- a/src/data/commandData.csv +++ b/src/data/commandData.csv @@ -25,16 +25,17 @@ 24,ban,moderation,Bans a specified member from the server. 25,purge,moderation,Purges (mass deletes) a specified amount of messages from the current channel. 26,config-autorole,administration,"Sets / modifies / disables the autorole feature. When a new member joins the server, a specified role will get assigned to them automatically." -28,config-welcome,administration,"Sets / modifies / disables the welcome messages feature. When a new member joins the server, the bot send a specified welcome message." -30,config-logging,administration,Sets / modifies / disables the channel where event on the server will get logged -32,config-bridge,administration,Sets / modifies / disables bridging all messages from one channel to another. -34,rename,administration,Renames a specified user to a specified nickname in the current server. -35,slowmode,administration,Sets / disables the slowmode for a specified channel. -36,config-goodbye,administration,"Sets / modifies / disables the goodbye messages feature. When a member leaves the server, the bot send a specified goodbye message." -82,coinflip-fun,fun,Flips a coin that has a 50/50 chance landing on heads or tails. Has an economy (*/coinflip*) version with gambling. -112,blackjack,economy,Lets you play a game of blackjack with a specified amount. You can pick **Hit** or **Stand** until the player or the house wins -192,config-darwin,administration,Sets / modifies / disables Darwin's occasional video scraping & posting feature. -193,cigany,fun,"Says ""fuj"" and sends a random pic of a ""person"" from a specific race." -194,cooldown,economy,Lets you check your or other users economy cooldowns for all or a specified economy command. -195,invite,utility,Gives you back a link for inviting the bot to any server where you have permissions to do so. -652,word-leaderboard,fun,Counts a specified word in the current server and sends back a leaderboard with the users who used that word the most through all their previous messages. +27,config-welcome,administration,"Sets / modifies / disables the welcome messages feature. When a new member joins the server, the bot send a specified welcome message." +28,config-logging,administration,Sets / modifies / disables the channel where event on the server will get logged +29,config-bridge,administration,Sets / modifies / disables bridging all messages from one channel to another. +30,rename,administration,Renames a specified user to a specified nickname in the current server. +31,slowmode,administration,Sets / disables the slowmode for a specified channel. +32,config-goodbye,administration,"Sets / modifies / disables the goodbye messages feature. When a member leaves the server, the bot send a specified goodbye message." +33,coinflip-fun,fun,Flips a coin that has a 50/50 chance landing on heads or tails. Has an economy (*/coinflip*) version with gambling. +34,blackjack,economy,Lets you play a game of blackjack with a specified amount. You can pick **Hit** or **Stand** until the player or the house wins +35,config-darwin,administration,Sets / modifies / disables Darwin's occasional video scraping & posting feature. +36,cigany,fun,"Says ""fuj"" and sends a random pic of a ""person"" from a specific race." +37,cooldown,economy,Lets you check your or other users economy cooldowns for all or a specified economy command. +38,invite,utility,Gives you back a link for inviting the bot to any server where you have permissions to do so. +39,word-leaderboard,fun,Counts a specified word in the current server and sends back a leaderboard with the users who used that word the most through all their previous messages. +40,darwin-random,fun,"Sends back a random, streamable video from Darwin's database." From ea4f2e8699a5dd5d3a023f391b6580550abd6624 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 22 Nov 2025 22:15:51 +0100 Subject: [PATCH 42/43] bumped version number in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fa15ea1..f0380cd2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discordbot", - "version": "4.2.0", + "version": "4.2.1", "description": "A simple discord bot of mine developed with discord.js (Node.js).", "type": "module", "main": "index.js", From a16e0a4929676987b39a8bcb97efe7fd55388d4f Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 22 Nov 2025 22:16:00 +0100 Subject: [PATCH 43/43] fixed trigger in wiki update workflow --- .github/workflows/wiki-update.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/wiki-update.yml b/.github/workflows/wiki-update.yml index 36e6c944..d341c079 100644 --- a/.github/workflows/wiki-update.yml +++ b/.github/workflows/wiki-update.yml @@ -2,8 +2,7 @@ name: Update Wiki Commands on: push: - branches: - - main + branches: [main] paths: - "src/data/commandData.csv" workflow_dispatch: