Add status command

This commit is contained in:
Manuel Ruwe 2022-12-16 14:15:32 +01:00
parent beb34b7d7c
commit f5c1cb71a6
4 changed files with 60 additions and 35 deletions

View File

@ -2,11 +2,12 @@ import { Module } from '@nestjs/common';
import { DiscordModule } from '@discord-nestjs/core';
import { HelpCommand } from './help.command';
import { StatusCommand } from './status.command';
@Module({
imports: [DiscordModule.forFeature()],
controllers: [],
providers: [HelpCommand],
providers: [HelpCommand, StatusCommand],
exports: [],
})
export class CommandModule {}

View File

@ -8,10 +8,11 @@ import {
} from '@discord-nestjs/core';
import { EmbedBuilder } from '@discordjs/builders';
import { InteractionReplyOptions, MessagePayload } from 'discord.js';
import { DefaultJellyfinColor } from 'src/types/colors';
@Command({
name: 'help',
description: 'ejifejf',
description: 'Get help if you're having problems with this bot',
})
@UsePipes(TransformPipe)
export class HelpCommand implements DiscordTransformedCommand<unknown> {
@ -33,6 +34,7 @@ export class HelpCommand implements DiscordTransformedCommand<unknown> {
'https://github.com/walkxcode/dashboard-icons/blob/main/png/jellyfin.png?raw=true',
url: 'https://github.com/manuel-rw/jellyfin-discord-music-bot',
})
.setColor(DefaultJellyfinColor)
.setTitle('Help Information')
.setDescription(
'Jellyfin Discord Music bot is an easy way to broadcast your music collection to a Discord voicechannel.',
@ -54,37 +56,4 @@ export class HelpCommand implements DiscordTransformedCommand<unknown> {
],
};
}
/*
handler(
dto: unknown,
executionContext: TransformedCommandExecutionContext<any>,
) {
return new EmbedBuilder()
.setAuthor({
name: 'Jellyfin Discord Bot',
iconURL:
'https://github.com/walkxcode/dashboard-icons/blob/main/png/jellyfin.png?raw=true',
url: 'https://github.com/manuel-rw/jellyfin-discord-music-bot',
})
.setTitle('Help Information')
.setDescription(
'Jellyfin Discord Music bot is an easy way to broadcast your music collection to a Discord voicechannel.',
)
.addFields([
{
name: 'Report an issue',
value:
'https://github.com/manuel-rw/jellyfin-discord-music-bot/issues/new/choose',
inline: true,
},
{
name: 'Source code',
value: 'https://github.com/manuel-rw/jellyfin-discord-music-bot',
inline: true,
},
])
.toJSON();
}
*/
}

View File

@ -0,0 +1,52 @@
import { TransformPipe } from '@discord-nestjs/common';
import {
Command,
DiscordTransformedCommand,
InjectDiscordClient,
TransformedCommandExecutionContext,
UsePipes,
} from '@discord-nestjs/core';
import { EmbedBuilder } from '@discordjs/builders';
import { Client, InteractionReplyOptions } from 'discord.js';
import { DefaultJellyfinColor } from 'src/types/colors';
@Command({
name: 'status',
description: 'Display the current status for troubleshooting',
})
@UsePipes(TransformPipe)
export class StatusCommand implements DiscordTransformedCommand<unknown> {
constructor(
@InjectDiscordClient()
private readonly client: Client,
) {}
handler(
dto: unknown,
executionContext: TransformedCommandExecutionContext<any>,
): InteractionReplyOptions {
const ping = this.client.ws.ping;
return {
embeds: [
new EmbedBuilder()
.setTitle('Online and ready')
.setColor(DefaultJellyfinColor)
.addFields([
{
name: 'Ping',
value: `${ping}ms`,
inline: true,
},
{
name: 'Source code',
value: 'https://github.com/manuel-rw/jellyfin-discord-music-bot',
inline: true,
},
])
.toJSON(),
],
};
}
}

3
src/types/colors.ts Normal file
View File

@ -0,0 +1,3 @@
import { RGBTuple } from 'discord.js';
export const DefaultJellyfinColor: RGBTuple = [119, 116, 204];