From e64a86c9d6cb53772a88869cb77833f8df397ec7 Mon Sep 17 00:00:00 2001 From: Bluefield <48862659+bluefield-creator@users.noreply.github.com> Date: Sat, 10 May 2025 19:55:37 +0200 Subject: [PATCH 1/3] fix: package versioning The previous code only worked if you launched the bot using npm, but if you launch using any other launchers / supervisors, it wont display the correct version. Fixes by importing package.json and reading the version off from it. --- src/commands/info.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/commands/info.ts b/src/commands/info.ts index 4ded893..8a09ded 100644 --- a/src/commands/info.ts +++ b/src/commands/info.ts @@ -1,4 +1,18 @@ import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction } from 'discord.js' +import { readFileSync } from 'fs'; + +interface PackageJson { + version?: string; + [key: string]: any; +} + +function getVersion(): string { + // Use import.meta.url for proper resolution in ES modules + const jsonPath = new URL('../package.json', import.meta.url); + const raw = readFileSync(jsonPath, 'utf-8'); + const pkg: PackageJson = JSON.parse(raw); + return pkg.version ?? '0'; +} export async function info (interaction:CommandInteraction) { const invite = new ButtonBuilder() @@ -20,7 +34,7 @@ export async function info (interaction:CommandInteraction) { .setURL('https://discord.com/api/oauth2/authorize?client_id=905979909049028649&permissions=414464724032&scope=bot') .setThumbnail('https://starmanthegamer.com/icon.png') .addFields( - { name: 'Version', value: `Currently running version: ${process.env.npm_package_version}` }, + { name: 'Version', value: `Currently running version: ${getVersion()}` }, { name: 'Contributed by:', value: 'baggy, DevPixels, Index, InsertSoda, and many more!', inline: true } ) .setFooter({ text: 'Thank you for using Polytoria Community Bot!', iconURL: 'https://starmanthegamer.com/icon.png' }) From 0ae01b14a2caf0323134a4c24e801329f67361ca Mon Sep 17 00:00:00 2001 From: Bluefield <48862659+bluefield-creator@users.noreply.github.com> Date: Sat, 10 May 2025 19:58:04 +0200 Subject: [PATCH 2/3] typo: add proper path i think idk im running this on web not locally, so cant tell lmfao --- src/commands/info.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/info.ts b/src/commands/info.ts index 8a09ded..f26818d 100644 --- a/src/commands/info.ts +++ b/src/commands/info.ts @@ -8,7 +8,7 @@ interface PackageJson { function getVersion(): string { // Use import.meta.url for proper resolution in ES modules - const jsonPath = new URL('../package.json', import.meta.url); + const jsonPath = new URL('../../package.json', import.meta.url); const raw = readFileSync(jsonPath, 'utf-8'); const pkg: PackageJson = JSON.parse(raw); return pkg.version ?? '0'; From e51244e7848f21874adc2e7637ac62c53f0c8784 Mon Sep 17 00:00:00 2001 From: StarManTheGamer <68450308+StarManTheGamer@users.noreply.github.com> Date: Fri, 20 Jun 2025 02:38:53 -0500 Subject: [PATCH 3/3] Fix build error --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 8ae45c4..903a638 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "noEmit": false, "target": "es2020", "importHelpers": true, - "module": "es6", + "module": "es2020", "skipLibCheck": false, "esModuleInterop": true, "outDir": "dist",