mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-25 11:01:56 +01:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { TransformPipe } from '@discord-nestjs/common';
|
|
|
|
import { Command, DiscordCommand, UsePipes } from '@discord-nestjs/core';
|
|
import { CommandInteraction, InteractionReplyOptions } from 'discord.js';
|
|
import { DiscordMessageService } from '../clients/discord/discord.message.service';
|
|
import { PlaybackService } from '../playback/playback.service';
|
|
|
|
@Command({
|
|
name: 'previous',
|
|
description: 'Go to the previous track',
|
|
})
|
|
@UsePipes(TransformPipe)
|
|
export class PreviousTrackCommand implements DiscordCommand {
|
|
constructor(
|
|
private readonly playbackService: PlaybackService,
|
|
private readonly discordMessageService: DiscordMessageService,
|
|
) {}
|
|
|
|
handler(
|
|
dcommandInteraction: CommandInteraction,
|
|
): InteractionReplyOptions | string {
|
|
if (!this.playbackService.previousTrack()) {
|
|
return {
|
|
embeds: [
|
|
this.discordMessageService.buildErrorMessage({
|
|
title: 'There is no previous track',
|
|
}),
|
|
],
|
|
};
|
|
}
|
|
|
|
return {
|
|
embeds: [
|
|
this.discordMessageService.buildMessage({
|
|
title: 'Went to previous track',
|
|
}),
|
|
],
|
|
};
|
|
}
|
|
}
|