Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/commands/info.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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' })
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"noEmit": false,
"target": "es2020",
"importHelpers": true,
"module": "es6",
"module": "es2020",
"skipLibCheck": false,
"esModuleInterop": true,
"outDir": "dist",
Expand Down
Loading