Skip to content

Commit e04075b

Browse files
Merge pull request #119 from bluefield-creator/patch-3
fix: package versioning
2 parents d7a5fde + e51244e commit e04075b

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/commands/info.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction } from 'discord.js'
2+
import { readFileSync } from 'fs';
3+
4+
interface PackageJson {
5+
version?: string;
6+
[key: string]: any;
7+
}
8+
9+
function getVersion(): string {
10+
// Use import.meta.url for proper resolution in ES modules
11+
const jsonPath = new URL('../../package.json', import.meta.url);
12+
const raw = readFileSync(jsonPath, 'utf-8');
13+
const pkg: PackageJson = JSON.parse(raw);
14+
return pkg.version ?? '0';
15+
}
216

317
export async function info (interaction:CommandInteraction) {
418
const invite = new ButtonBuilder()
@@ -20,7 +34,7 @@ export async function info (interaction:CommandInteraction) {
2034
.setURL('https://discord.com/api/oauth2/authorize?client_id=905979909049028649&permissions=414464724032&scope=bot')
2135
.setThumbnail('https://starmanthegamer.com/icon.png')
2236
.addFields(
23-
{ name: 'Version', value: `Currently running version: ${process.env.npm_package_version}` },
37+
{ name: 'Version', value: `Currently running version: ${getVersion()}` },
2438
{ name: 'Contributed by:', value: 'baggy, DevPixels, Index, InsertSoda, and many more!', inline: true }
2539
)
2640
.setFooter({ text: 'Thank you for using Polytoria Community Bot!', iconURL: 'https://starmanthegamer.com/icon.png' })

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"noEmit": false,
77
"target": "es2020",
88
"importHelpers": true,
9-
"module": "es6",
9+
"module": "es2020",
1010
"skipLibCheck": false,
1111
"esModuleInterop": true,
1212
"outDir": "dist",

0 commit comments

Comments
 (0)