mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-23 18:21:55 +01:00
✨ Add status command
This commit is contained in:
parent
beb34b7d7c
commit
f5c1cb71a6
@ -2,11 +2,12 @@ import { Module } from '@nestjs/common';
|
|||||||
import { DiscordModule } from '@discord-nestjs/core';
|
import { DiscordModule } from '@discord-nestjs/core';
|
||||||
|
|
||||||
import { HelpCommand } from './help.command';
|
import { HelpCommand } from './help.command';
|
||||||
|
import { StatusCommand } from './status.command';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [DiscordModule.forFeature()],
|
imports: [DiscordModule.forFeature()],
|
||||||
controllers: [],
|
controllers: [],
|
||||||
providers: [HelpCommand],
|
providers: [HelpCommand, StatusCommand],
|
||||||
exports: [],
|
exports: [],
|
||||||
})
|
})
|
||||||
export class CommandModule {}
|
export class CommandModule {}
|
||||||
|
@ -8,10 +8,11 @@ import {
|
|||||||
} from '@discord-nestjs/core';
|
} from '@discord-nestjs/core';
|
||||||
import { EmbedBuilder } from '@discordjs/builders';
|
import { EmbedBuilder } from '@discordjs/builders';
|
||||||
import { InteractionReplyOptions, MessagePayload } from 'discord.js';
|
import { InteractionReplyOptions, MessagePayload } from 'discord.js';
|
||||||
|
import { DefaultJellyfinColor } from 'src/types/colors';
|
||||||
|
|
||||||
@Command({
|
@Command({
|
||||||
name: 'help',
|
name: 'help',
|
||||||
description: 'ejifejf',
|
description: 'Get help if you're having problems with this bot',
|
||||||
})
|
})
|
||||||
@UsePipes(TransformPipe)
|
@UsePipes(TransformPipe)
|
||||||
export class HelpCommand implements DiscordTransformedCommand<unknown> {
|
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',
|
'https://github.com/walkxcode/dashboard-icons/blob/main/png/jellyfin.png?raw=true',
|
||||||
url: 'https://github.com/manuel-rw/jellyfin-discord-music-bot',
|
url: 'https://github.com/manuel-rw/jellyfin-discord-music-bot',
|
||||||
})
|
})
|
||||||
|
.setColor(DefaultJellyfinColor)
|
||||||
.setTitle('Help Information')
|
.setTitle('Help Information')
|
||||||
.setDescription(
|
.setDescription(
|
||||||
'Jellyfin Discord Music bot is an easy way to broadcast your music collection to a Discord voicechannel.',
|
'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();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
52
src/commands/status.command.ts
Normal file
52
src/commands/status.command.ts
Normal 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
3
src/types/colors.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { RGBTuple } from 'discord.js';
|
||||||
|
|
||||||
|
export const DefaultJellyfinColor: RGBTuple = [119, 116, 204];
|
Loading…
Reference in New Issue
Block a user