-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from Blvckleg/dev
Dev
- Loading branch information
Showing
6 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import { | ||
CacheType, | ||
CommandInteraction, | ||
Interaction, | ||
SlashCommandBuilder, | ||
} from 'discord.js'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { SlashCommandBuilder } from 'discord.js'; | ||
import { ACommand } from '../command.abstract'; | ||
import { VersionService } from '../../version/service/version.service'; | ||
|
||
@Injectable() | ||
export class VersionCommand extends ACommand { | ||
constructor( | ||
@Inject(VersionService) private readonly versionService: VersionService, | ||
) { | ||
super(); | ||
} | ||
data = new SlashCommandBuilder() | ||
.setName('version') | ||
.setDescription( | ||
'show the version of the currently running bingus instance', | ||
); | ||
|
||
async execute(interaction) { | ||
const version = await this.versionService.getVersion(); | ||
return this.run(async () => { | ||
if (version && version.length > 0) { | ||
return await interaction.reply(`The current version is: ${version}`); | ||
} | ||
return await interaction.reply('Failed to get version'); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { VersionService } from '../service/version.service'; | ||
|
||
@Module({ | ||
imports: [], | ||
controllers: [], | ||
providers: [VersionService], | ||
exports: [VersionService], | ||
}) | ||
export class VersionModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import * as fs from 'fs'; | ||
|
||
@Injectable() | ||
export class VersionService { | ||
private version: string; | ||
|
||
constructor() { | ||
// Read package.json synchronously | ||
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8')); | ||
this.version = packageJson.version; | ||
} | ||
|
||
getVersion(): string { | ||
return this.version; | ||
} | ||
} |