2022-12-16 16:10:16 +01:00
|
|
|
import { TransformPipe } from '@discord-nestjs/common';
|
|
|
|
|
2022-12-17 19:52:32 +01:00
|
|
|
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';
|
2022-12-16 16:10:16 +01:00
|
|
|
|
|
|
|
@Command({
|
2022-12-18 12:30:42 +01:00
|
|
|
name: 'next',
|
|
|
|
description: 'Go to the next track in the playlist',
|
2022-12-16 16:10:16 +01:00
|
|
|
})
|
|
|
|
@UsePipes(TransformPipe)
|
2022-12-17 19:52:32 +01:00
|
|
|
export class SkipTrackCommand implements DiscordCommand {
|
|
|
|
constructor(
|
|
|
|
private readonly playbackService: PlaybackService,
|
|
|
|
private readonly discordMessageService: DiscordMessageService,
|
|
|
|
) {}
|
|
|
|
|
2022-12-16 16:10:16 +01:00
|
|
|
handler(
|
2022-12-20 11:03:24 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2022-12-17 19:52:32 +01:00
|
|
|
interactionCommand: CommandInteraction,
|
2022-12-16 16:10:16 +01:00
|
|
|
): InteractionReplyOptions | string {
|
2022-12-17 19:52:32 +01:00
|
|
|
if (!this.playbackService.nextTrack()) {
|
|
|
|
return {
|
|
|
|
embeds: [
|
|
|
|
this.discordMessageService.buildErrorMessage({
|
|
|
|
title: 'There is no next track',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
embeds: [
|
|
|
|
this.discordMessageService.buildMessage({
|
|
|
|
title: 'Skipped to the next track',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|
2022-12-16 16:10:16 +01:00
|
|
|
}
|
|
|
|
}
|