From 8e72ace4d90c5f08e19b34fffe2abde04cc751aa Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 26 Oct 2025 02:33:00 +0100 Subject: [PATCH 01/27] updated app version in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7feb10b2..da916176 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discordbot", - "version": "4.1.1", + "version": "4.1.3", "description": "A simple discord bot of mine developed with discord.js (Node.js).", "type": "module", "main": "index.js", From b58c362beae430f1e348645c014a326c6ec91562 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 26 Oct 2025 02:33:31 +0100 Subject: [PATCH 02/27] updated app version in package-lock.json --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c995ab14..d464d505 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "discordbot", - "version": "4.0.1", + "version": "4.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "discordbot", - "version": "4.0.1", + "version": "4.1.3", "license": "AGPL-3.0-only", "dependencies": { "ajv": "^8.17.1", From e0871d742c000a754aaa78990416813c057bd4b7 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 26 Oct 2025 02:38:02 +0100 Subject: [PATCH 03/27] added release & deploy status badges to readme, removed codeql for now --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d235f94b..8b73e290 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@
-[![Unit tests](https://github.com/vb2007/discordbot/actions/workflows/unit-tests.yml/badge.svg?branch=dev)](https://github.com/vb2007/discordbot/actions/workflows/unit-tests.yml) [![Update Wiki Commands](https://github.com/vb2007/discordbot/actions/workflows/wiki-update.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/wiki-update.yml) [![CodeQL](https://github.com/vb2007/discordbot/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/github-code-scanning/codeql) +[![Deploy](https://github.com/vb2007/discordbot/actions/workflows/deploy.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/deploy.yml) [![Release on GitHub](https://github.com/vb2007/discordbot/actions/workflows/gh-release.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/gh-release.yml) [![Update Wiki Commands](https://github.com/vb2007/discordbot/actions/workflows/wiki-update.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/wiki-update.yml) [![Unit tests](https://github.com/vb2007/discordbot/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/unit-tests.yml)
From ba3fecea65dd252cfe0fefc959367955aec7f82c Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 26 Oct 2025 02:39:55 +0100 Subject: [PATCH 04/27] added back codeql badge --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 8b73e290..57390647 100755 --- a/README.md +++ b/README.md @@ -6,6 +6,12 @@ +
+ +[![CodeQL](https://github.com/vb2007/discordbot/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/github-code-scanning/codeql) + +
+ A simple discord bot of mine developed with **Node.js**'s [discord.js](https://www.npmjs.com/package/discord.js?activeTab=readme) package. ## Invite the bot From 762b015153b4c1db170d0ca2eb72865aa2940cf5 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 26 Oct 2025 02:41:55 +0100 Subject: [PATCH 05/27] deleted .vscode and .zed folders --- .vscode/launch.json | 41 ----------------------------------------- .vscode/settings.json | 3 --- .zed/settings.json | 5 ----- 3 files changed, 49 deletions(-) delete mode 100755 .vscode/launch.json delete mode 100644 .vscode/settings.json delete mode 100644 .zed/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100755 index b579f615..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Launch bot.", - "type": "node", - "request": "launch", - "skipFiles": ["/**"], - "program": "${workspaceFolder}/src/index.js" - }, - { - "name": "Deploy slash commands.", - "type": "node", - "request": "launch", - "skipFiles": ["/**"], - "program": "${workspaceFolder}/src/deploy-commands.js" - }, - { - "name": "Run unit tests.", - "type": "node", - "request": "launch", - "runtimeArgs": [ - "--inspect-brk", - "${workspaceRoot}/node_modules/jest/bin/jest.js", - "--runInBand" - ], - "console": "integratedTerminal", - "internalConsoleOptions": "neverOpen" - }, - { - "name": "Create SQL tables.", - "type": "node", - "request": "launch", - "skipFiles": ["/**"], - "program": "${workspaceFolder}/src/create-tables.js" - } - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index d3cb2ac4..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "postman.settings.dotenv-detection-notification-visibility": false -} diff --git a/.zed/settings.json b/.zed/settings.json deleted file mode 100644 index 79860b3a..00000000 --- a/.zed/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -// Folder-specific settings -// -// For a full list of overridable settings, and general information on folder-specific settings, -// see the documentation: https://zed.dev/docs/configuring-zed#settings-files -{} From 862acc724735ed8c641ccdca26a123e6e8f1b4c7 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 26 Oct 2025 02:42:49 +0100 Subject: [PATCH 06/27] updated .gitignore with ide specific folders --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 8aaabd8e..0605d8e0 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +# Application specific files & folders .env config.json /node_modules @@ -5,3 +6,7 @@ config.json /src/data/cigpics.json /src/data/pics.json /src/data/commands.md + +# IDE / code editor specific folders +/.vscode +/.zed From 0bc1fe236d1f38eee89643576846235ce54073e5 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Mon, 27 Oct 2025 23:44:26 +0100 Subject: [PATCH 07/27] created store.js --- src/commands/economy/store.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/commands/economy/store.js diff --git a/src/commands/economy/store.js b/src/commands/economy/store.js new file mode 100644 index 00000000..e69de29b From 7041917f6ade5fea0be0156986f6e74281fd677a Mon Sep 17 00:00:00 2001 From: VB2007 Date: Thu, 30 Oct 2025 23:59:10 +0100 Subject: [PATCH 08/27] created base for command --- src/commands/economy/store.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/commands/economy/store.js b/src/commands/economy/store.js index e69de29b..d6247a5b 100644 --- a/src/commands/economy/store.js +++ b/src/commands/economy/store.js @@ -0,0 +1,7 @@ +import { SlashCommandBuilder } from "discord.js"; +import { embedReplyPrimaryColorWithFields } from "../../helpers/embeds/embed-reply.js"; + +export default { + data: new SlashCommandBuilder(), + async execute(interaction) {}, +}; From 57f201cddbd86d6d70847da348315c4d70fda772 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 22 Nov 2025 23:08:08 +0100 Subject: [PATCH 09/27] fixed error in darwinCache table creation sql script --- 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 86ec5e5e..c8483b94 100644 --- a/src/sql/darwinCache/table.sql +++ b/src/sql/darwinCache/table.sql @@ -1,6 +1,6 @@ -- discordbot.darwinCache definition -CREATE TABLE `darwinCache` ( +CREATE TABLE IF NOT EXISTS `darwinCache` ( `id` int(11) NOT NULL AUTO_INCREMENT, `directVideoUrl` varchar(255) NOT NULL, `forumPostUrl` varchar(255) NOT NULL DEFAULT '', From 7f634a3dd79e33c4ccc2cb98698d0b57691b6e13 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 23 Nov 2025 01:28:19 +0100 Subject: [PATCH 10/27] updated darwinCache table definition --- src/sql/darwinCache/table.sql | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sql/darwinCache/table.sql b/src/sql/darwinCache/table.sql index c8483b94..167765fb 100644 --- a/src/sql/darwinCache/table.sql +++ b/src/sql/darwinCache/table.sql @@ -1,13 +1,13 @@ -- discordbot.darwinCache definition CREATE TABLE IF NOT EXISTS `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`) + `id` int(11) NOT NULL AUTO_INCREMENT, + `directVideoUrl` varchar(255) NOT NULL, + `forumPostUrl` varchar(255) DEFAULT NULL, + `videoId` varchar(100) NOT NULL, + `videoTitle` varchar(180) DEFAULT NULL, + `processedAt` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + UNIQUE KEY `videoId` (`videoId`), + UNIQUE KEY `directVideoUrl` (`directVideoUrl`) ); From d18b38e078f5fdcd5bf96e77a1444df0ba1347a8 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 23 Nov 2025 01:29:22 +0100 Subject: [PATCH 11/27] updated version in package lock --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3cf82b2c..2ea0c503 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "discordbot", - "version": "4.2.0", + "version": "4.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "discordbot", - "version": "4.2.0", + "version": "4.2.1", "license": "AGPL-3.0-only", "dependencies": { "ajv": "^8.17.1", From 2bbafb1c303360380ba426d7b2cd1a2276f26695 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 23 Nov 2025 01:31:41 +0100 Subject: [PATCH 12/27] created sql file for new economy store table --- src/sql/economyStore/table.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/sql/economyStore/table.sql diff --git a/src/sql/economyStore/table.sql b/src/sql/economyStore/table.sql new file mode 100644 index 00000000..e69de29b From 39ee60747fd4eb68772d0bc0109feb9153c77441 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 23 Nov 2025 01:35:33 +0100 Subject: [PATCH 13/27] added execution logic for /store --- src/commands/economy/store.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/commands/economy/store.js b/src/commands/economy/store.js index d6247a5b..c11a8764 100644 --- a/src/commands/economy/store.js +++ b/src/commands/economy/store.js @@ -1,7 +1,24 @@ import { SlashCommandBuilder } from "discord.js"; import { embedReplyPrimaryColorWithFields } from "../../helpers/embeds/embed-reply.js"; +import { checkIfNotInGuild } from "../../helpers/command-validation/general.js"; +import { query } from "../../helpers/db.js"; + +const commandName = "store"; export default { - data: new SlashCommandBuilder(), - async execute(interaction) {}, + data: new SlashCommandBuilder() + .setName(commandName) + .setDescription("") + .setNSFW(false) + .setDMPermission(false), + async execute(interaction) { + const guildCheck = checkIfNotInGuild(commandName, interaction); + if (guildCheck) { + return await replyAndLog(interaction, guildCheck); + } + + const embedReply = embedReplyPrimaryColorWithFields("Store", "", {}, interaction); + + return await replyAndLog(interaction, embedReply); + }, }; From da371066ee8d49ecadfaedc5d977bb7649cc6d33 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 23 Nov 2025 01:44:12 +0100 Subject: [PATCH 14/27] Fixed tokens & permissions in wiki update workflow --- .github/workflows/wiki-update.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wiki-update.yml b/.github/workflows/wiki-update.yml index d341c079..ded2b0ed 100644 --- a/.github/workflows/wiki-update.yml +++ b/.github/workflows/wiki-update.yml @@ -13,6 +13,9 @@ on: default: "main" type: string +permissions: + contents: write #gives both read & write access + jobs: update-wiki: runs-on: self-hosted @@ -31,10 +34,10 @@ jobs: - name: Update Wiki env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # Clone wiki repo - git clone https://${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.wiki.git wiki + git clone https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git wiki # Copy new content cp src/data/commands.md ./wiki/Commands.md From 127c28ea92ce3373fb77bf87b1aa0aef1b69e092 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 23 Nov 2025 01:47:22 +0100 Subject: [PATCH 15/27] fixed permissions in rest of the workflows --- .github/workflows/deploy.yml | 4 +++- .github/workflows/unit-tests.yml | 3 +++ .github/workflows/wiki-update.yml | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 28f80b80..a99bd3f4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,5 +1,7 @@ name: Deploy -permissions: {} + +permissions: + contents: read on: push: diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 535943e9..30d89316 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -1,5 +1,8 @@ name: Unit tests +permissions: + contents: read + on: pull_request: branches: [main, dev] diff --git a/.github/workflows/wiki-update.yml b/.github/workflows/wiki-update.yml index ded2b0ed..e24a7092 100644 --- a/.github/workflows/wiki-update.yml +++ b/.github/workflows/wiki-update.yml @@ -1,5 +1,8 @@ name: Update Wiki Commands +permissions: + contents: write #gives both read & write access + on: push: branches: [main] @@ -13,9 +16,6 @@ on: default: "main" type: string -permissions: - contents: write #gives both read & write access - jobs: update-wiki: runs-on: self-hosted From c5fa6135c457c4d7ae06cb8a4f331278b9e1ae74 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 29 Nov 2025 23:01:19 +0100 Subject: [PATCH 16/27] updated packages --- package-lock.json | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2ea0c503..816ec269 100755 --- a/package-lock.json +++ b/package-lock.json @@ -56,7 +56,6 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -1441,9 +1440,9 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "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==", + "version": "2.8.32", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.32.tgz", + "integrity": "sha512-OPz5aBThlyLFgxyhdwf/s2+8ab3OvT7AdTNvKHBwpXomIYeXqpUUuT8LrdtxZSsWJ4R4CU1un4XGh5Ez3nlTpw==", "dev": true, "license": "Apache-2.0", "bin": { @@ -1500,7 +1499,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.25", "caniuse-lite": "^1.0.30001754", @@ -1553,9 +1551,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001756", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001756.tgz", - "integrity": "sha512-4HnCNKbMLkLdhJz3TToeVWHSnfJvPaq6vu/eRP0Ahub/07n484XHhBF5AJoSGHdVrS8tKFauUQz8Bp9P7LVx7A==", + "version": "1.0.30001757", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001757.tgz", + "integrity": "sha512-r0nnL/I28Zi/yjk1el6ilj27tKcdjLsNqAOZr0yVjWPrSQyHgKI2INaEWw21bAQSv2LXRt1XuCS/GomNpWOxsQ==", "dev": true, "funding": [ { @@ -1886,9 +1884,9 @@ } }, "node_modules/discord-api-types": { - "version": "0.38.34", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.34.tgz", - "integrity": "sha512-muq7xKGznj5MSFCzuIm/2TO7DpttuomUTemVM82fRqgnMl70YRzEyY24jlbiV6R9tzOTq6A6UnZ0bsfZeKD38Q==", + "version": "0.38.35", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.35.tgz", + "integrity": "sha512-pI6FKJmkyIhToiDK5f8iok7acugSJDFnr3D2a0m+r91EMSFWCzAAEgUro9Km0AUYQPAUluS6iJaXVKt6+wBF7w==", "license": "MIT", "workspaces": [ "scripts/actions/documentation" @@ -1998,9 +1996,9 @@ } }, "node_modules/electron-to-chromium": { - "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==", + "version": "1.5.262", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.262.tgz", + "integrity": "sha512-NlAsMteRHek05jRUxUR0a5jpjYq9ykk6+kO0yRaMi5moe7u0fVIOeQ3Y30A8dIiWFBNUoQGi1ljb1i5VtS9WQQ==", "dev": true, "license": "ISC" }, @@ -3750,9 +3748,9 @@ } }, "node_modules/prettier": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", - "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.3.tgz", + "integrity": "sha512-QgODejq9K3OzoBbuyobZlUhznP5SKwPqp+6Q6xw6o8gnhr4O85L2U915iM2IDcfF2NPXVaM9zlo9tdwipnYwzg==", "dev": true, "license": "MIT", "bin": { From 85f1880078a63882110693f42f3891b249d38c67 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sat, 29 Nov 2025 23:44:18 +0100 Subject: [PATCH 17/27] changed bot's status to display current version --- src/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index b44fb321..1d568d4f 100644 --- a/src/index.js +++ b/src/index.js @@ -10,6 +10,10 @@ import config from "../config.json" with { type: "json" }; import "dotenv/config"; const token = process.env.TOKEN; +//for displaying version is bot's status +import packageJson from "../package.json" with { type: "json" }; +const version = packageJson.version; + import { getConnection } from "./helpers/db.js"; import { runDarwinProcess } from "./helpers/darwin/darwinProcess.js"; import { validateConfig } from "./scripts/verify-config-syntax.js"; @@ -218,8 +222,8 @@ const setActivity = () => { client.user.setActivity({ status: "online", - type: ActivityType.Playing, - name: "with stolen user data.", + type: ActivityType.Custom, + name: `Running v${version}`, }); // console.log("Re-announced bot's activity."); From 4b1d24cf5f83fa693538f9e130114929ed362807 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 30 Nov 2025 00:21:56 +0100 Subject: [PATCH 18/27] implemented economyStore sql table definition --- src/sql/economyStore/table.sql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sql/economyStore/table.sql b/src/sql/economyStore/table.sql index e69de29b..3fab9a26 100644 --- a/src/sql/economyStore/table.sql +++ b/src/sql/economyStore/table.sql @@ -0,0 +1,9 @@ +-- discordbot.economyStore definition + +CREATE TABLE IF NOT EXISTS `economyStore` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `price` int(11) NOT NULL, + `name` varchar(100) NOT NULL, + `description` varchar(100) DEFAULT 'No description provided.', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; From 34e5a715eb88c52298c0e9004ff17228e7ec8bf6 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 30 Nov 2025 01:25:32 +0100 Subject: [PATCH 19/27] made name unique in economyStore --- src/sql/commandData/table.sql | 2 +- src/sql/economyStore/table.sql | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sql/commandData/table.sql b/src/sql/commandData/table.sql index 3fd413f2..00afc760 100644 --- a/src/sql/commandData/table.sql +++ b/src/sql/commandData/table.sql @@ -7,4 +7,4 @@ CREATE TABLE IF NOT EXISTS `commandData` ( `description` text DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `unique_name` (`name`) -); \ No newline at end of file +); diff --git a/src/sql/economyStore/table.sql b/src/sql/economyStore/table.sql index 3fab9a26..7c690103 100644 --- a/src/sql/economyStore/table.sql +++ b/src/sql/economyStore/table.sql @@ -5,5 +5,6 @@ CREATE TABLE IF NOT EXISTS `economyStore` ( `price` int(11) NOT NULL, `name` varchar(100) NOT NULL, `description` varchar(100) DEFAULT 'No description provided.', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci; From e56f4c088c5bea68862a81ce45813ca3c7fb5fd8 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 30 Nov 2025 01:28:09 +0100 Subject: [PATCH 20/27] updated description & implemented query logic for /store --- src/commands/economy/store.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/commands/economy/store.js b/src/commands/economy/store.js index c11a8764..03594194 100644 --- a/src/commands/economy/store.js +++ b/src/commands/economy/store.js @@ -8,7 +8,9 @@ const commandName = "store"; export default { data: new SlashCommandBuilder() .setName(commandName) - .setDescription("") + .setDescription( + "Returns a store page with various purchaseable items that can help with your economy status." + ) .setNSFW(false) .setDMPermission(false), async execute(interaction) { @@ -17,7 +19,17 @@ export default { return await replyAndLog(interaction, guildCheck); } - const embedReply = embedReplyPrimaryColorWithFields("Store", "", {}, interaction); + const storeQuery = query( + `SELECT name, price, description FROM economyStore ORDER BY price ASC` + ); + console.log(storeQuery); + + const embedReply = embedReplyPrimaryColorWithFields( + "Store", + "Use the `/buy`(`name`) command to purchase any of these items.", + {}, + interaction + ); return await replyAndLog(interaction, embedReply); }, From 4391830d35661713cfe6449e3f42781d4404b997 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 30 Nov 2025 01:29:38 +0100 Subject: [PATCH 21/27] added missing replyAndLog import --- src/commands/economy/store.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/economy/store.js b/src/commands/economy/store.js index 03594194..3a631343 100644 --- a/src/commands/economy/store.js +++ b/src/commands/economy/store.js @@ -1,6 +1,7 @@ import { SlashCommandBuilder } from "discord.js"; import { embedReplyPrimaryColorWithFields } from "../../helpers/embeds/embed-reply.js"; import { checkIfNotInGuild } from "../../helpers/command-validation/general.js"; +import { replyAndLog } from "../../helpers/reply.js"; import { query } from "../../helpers/db.js"; const commandName = "store"; @@ -19,7 +20,7 @@ export default { return await replyAndLog(interaction, guildCheck); } - const storeQuery = query( + const storeQuery = await query( `SELECT name, price, description FROM economyStore ORDER BY price ASC` ); console.log(storeQuery); From c6b6712c62a95ce717da71e6ad2f83b2c6de4258 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 30 Nov 2025 15:04:31 +0100 Subject: [PATCH 22/27] added query mapping for displaying items correctly in embed response --- src/commands/economy/store.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/commands/economy/store.js b/src/commands/economy/store.js index 3a631343..c7495274 100644 --- a/src/commands/economy/store.js +++ b/src/commands/economy/store.js @@ -23,12 +23,16 @@ export default { const storeQuery = await query( `SELECT name, price, description FROM economyStore ORDER BY price ASC` ); - console.log(storeQuery); + const fields = storeQuery.map((item) => ({ + name: `${item.name} - \`$${item.price}\``, + value: item.description, + inline: false, + })); const embedReply = embedReplyPrimaryColorWithFields( "Store", - "Use the `/buy`(`name`) command to purchase any of these items.", - {}, + "Use the `/buy`(**item name**) command to purchase any of these items.", + fields, interaction ); From e0c326d6f68c9e8770b9f7f818937b21eed1be45 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 30 Nov 2025 23:25:22 +0100 Subject: [PATCH 23/27] added economyStore.csv data file --- src/data/economyStore.csv | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/data/economyStore.csv diff --git a/src/data/economyStore.csv b/src/data/economyStore.csv new file mode 100644 index 00000000..4ea357e4 --- /dev/null +++ b/src/data/economyStore.csv @@ -0,0 +1,9 @@ +"id","price","name","description" +1,5,Bread,"flour, yeast, salt, water. fresh." +2,150,gun,"Makes you able to rob from a user's bank account, if they haven't been bankrobbed already after their last deposit." +3,80,fentanyl,"Gives you a 100% success rate on your next rob command, unless your target has a police badge." +4,5000,clipped-coins,"Gets you expelled from 109 countries, but makes you gain a 3x multiplier on any gabling command you use first after activation." +5,15000,dildo,very long +6,2500,fried-chicken,"Best paired with watermelon & Kool-aid. Your black mind runs faster from it, thus giving you a 15% win rate on your next roulette game, if you bet on green." +7,100,police-badge,"Takes your opponent's breath instantly when it's under the influence of fent, thus making the robbery attempt unsuccessful." +8,150,kippah,"Makes your nose huge, but gives you a 3x multiplier on the next work commands." From c27b0cc77baee1100a4616de282e1c8c95c051f4 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 30 Nov 2025 23:30:18 +0100 Subject: [PATCH 24/27] created parseCSVLine, made a universal parseAndUpdateCSV function & called it for new data file --- src/create-tables.js | 87 +++++++++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 26 deletions(-) diff --git a/src/create-tables.js b/src/create-tables.js index cf1412fb..f6289814 100644 --- a/src/create-tables.js +++ b/src/create-tables.js @@ -24,45 +24,69 @@ const readSQLFiles = (dir) => { return sqlQueries; }; -const updateCommandData = async () => { +//parses CSV line into array of values +const parseCSVLine = (line) => { + const regex = /(?:^|,)(?:"([^"]*(?:""[^"]*)*)"|([^,"]*))/g; + const values = []; + let match; + + while ((match = regex.exec(line))) { + const value = match[1] || match[2]; + values.push(value ? value.replace(/""/g, '"').trim() : ""); + } + + return values; +}; + +//universal function to parse and update CSV data into database tables +const parseAndUpdateCSV = async (csvFileName, tableName, columnMapping) => { try { - const csvPath = path.join(__dirname, "data", "commandData.csv"); + const csvPath = path.join(__dirname, "data", csvFileName); const csvContent = fs.readFileSync(csvPath, "utf8"); - const commands = csvContent - .split("\n") + //parse CSV and extract headers + const lines = csvContent.split("\n").filter((line) => line.trim()); + const headers = parseCSVLine(lines[0]); + + const rows = lines .slice(1) - .filter((line) => line.trim()) .map((line) => { - //csv parsing - const regex = /(?:^|,)(?:"([^"]*(?:""[^"]*)*)"|([^,"]*))/g; - const values = []; - let match; + const values = parseCSVLine(line); - while ((match = regex.exec(line))) { - const value = match[1] || match[2]; - values.push(value ? value.replace(/""/g, '"').trim() : ""); - } + if (values.length < headers.length) return null; - if (values.length < 4) return null; + //create object with header-value pairs + const row = {}; + headers.forEach((header, index) => { + row[header] = values[index]; + }); - const [id, name, category, description] = values; - return { name, category, description }; + return row; }) - .filter((cmd) => cmd !== null); + .filter((row) => row !== null); + + //prepare SQL query + const columns = columnMapping.columns; + const placeholders = columns.map(() => "?").join(", "); + const updateClause = columns + .filter((col) => !columnMapping.skipUpdate?.includes(col)) + .map((col) => `${col} = VALUES(${col})`) + .join(", "); - for (const cmd of commands) { - console.log(`Processing command: ${cmd.name}`); + const insertQuery = `INSERT INTO ${tableName} (${columns.join(", ")}) VALUES (${placeholders}) ON DUPLICATE KEY UPDATE ${updateClause}`; - await query( - "INSERT INTO commandData (name, category, description) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE category = VALUES(category), description = VALUES(description)", - [cmd.name, cmd.category, cmd.description] - ); + for (const row of rows) { + const identifier = row[columnMapping.identifier] || row.name || row.id; + console.log(`Processing ${tableName}: ${identifier}`); + + const values = columns.map((col) => row[col]); + + await query(insertQuery, values); } - console.log("Command data has been updated successfully."); + console.log(`${tableName} data has been updated successfully.`); } catch (error) { - console.error("Error updating command data:", error); + console.error(`Error updating ${tableName} data:`, error); console.error("Error details:", error.stack); } }; @@ -106,7 +130,18 @@ const createTables = async () => { const init = async () => { await createTables(); - await updateCommandData(); + + await parseAndUpdateCSV("commandData.csv", "commandData", { + columns: ["name", "category", "description"], + identifier: "name", + }); + + await parseAndUpdateCSV("economyStore.csv", "economyStore", { + columns: ["id", "price", "name", "description"], + identifier: "name", + skipUpdate: ["id"], + }); + process.exit(0); }; From 6ee3fa1861af69d86d33b7582f0e8d438f6395ce Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 30 Nov 2025 23:32:02 +0100 Subject: [PATCH 25/27] removed id column processing from economyStore table update --- src/create-tables.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/create-tables.js b/src/create-tables.js index f6289814..6d7c155a 100644 --- a/src/create-tables.js +++ b/src/create-tables.js @@ -137,9 +137,8 @@ const init = async () => { }); await parseAndUpdateCSV("economyStore.csv", "economyStore", { - columns: ["id", "price", "name", "description"], + columns: ["price", "name", "description"], identifier: "name", - skipUpdate: ["id"], }); process.exit(0); From b356eeba97201c7431a9ebb03bebd11f1b4dfc21 Mon Sep 17 00:00:00 2001 From: VB2007 Date: Sun, 30 Nov 2025 23:42:58 +0100 Subject: [PATCH 26/27] moved all QA badges to another line in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 57390647..c3e4291c 100755 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@
-[![Deploy](https://github.com/vb2007/discordbot/actions/workflows/deploy.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/deploy.yml) [![Release on GitHub](https://github.com/vb2007/discordbot/actions/workflows/gh-release.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/gh-release.yml) [![Update Wiki Commands](https://github.com/vb2007/discordbot/actions/workflows/wiki-update.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/wiki-update.yml) [![Unit tests](https://github.com/vb2007/discordbot/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/unit-tests.yml) +[![Deploy](https://github.com/vb2007/discordbot/actions/workflows/deploy.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/deploy.yml) [![Release on GitHub](https://github.com/vb2007/discordbot/actions/workflows/gh-release.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/gh-release.yml) [![Update Wiki Commands](https://github.com/vb2007/discordbot/actions/workflows/wiki-update.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/wiki-update.yml)
-[![CodeQL](https://github.com/vb2007/discordbot/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/github-code-scanning/codeql) +[![Unit tests](https://github.com/vb2007/discordbot/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/unit-tests.yml) [![CodeQL](https://github.com/vb2007/discordbot/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/vb2007/discordbot/actions/workflows/github-code-scanning/codeql)
From aa39edda85149465d3f23199e521f11903fa1ecf Mon Sep 17 00:00:00 2001 From: VB2007 Date: Mon, 1 Dec 2025 01:19:28 +0100 Subject: [PATCH 27/27] added store 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 116ddc6c..cd512289 100644 --- a/src/data/commandData.csv +++ b/src/data/commandData.csv @@ -39,3 +39,4 @@ 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." +41,store,economy,Displays a store filled with various items / power-ups you can buy to help you progress in this terrible economy.