2022-12-16 16:10:16 +01:00
|
|
|
import { TransformPipe } from '@discord-nestjs/common';
|
|
|
|
|
2022-12-17 22:39:33 +01:00
|
|
|
import { Command, DiscordCommand, UsePipes } from '@discord-nestjs/core';
|
|
|
|
import { CommandInteraction } from 'discord.js';
|
|
|
|
import { DiscordMessageService } from '../clients/discord/discord.message.service';
|
|
|
|
import { DiscordVoiceService } from '../clients/discord/discord.voice.service';
|
|
|
|
import { GenericCustomReply } from '../models/generic-try-handler';
|
|
|
|
import { PlaybackService } from '../playback/playback.service';
|
2022-12-16 16:10:16 +01:00
|
|
|
|
|
|
|
@Command({
|
|
|
|
name: 'stop',
|
|
|
|
description: 'Stop playback entirely and clear the current playlist',
|
|
|
|
})
|
|
|
|
@UsePipes(TransformPipe)
|
2022-12-17 22:39:33 +01:00
|
|
|
export class StopPlaybackCommand implements DiscordCommand {
|
|
|
|
constructor(
|
|
|
|
private readonly playbackService: PlaybackService,
|
|
|
|
private readonly discordMessageService: DiscordMessageService,
|
|
|
|
private readonly discordVoiceService: DiscordVoiceService,
|
|
|
|
) {}
|
2022-12-20 11:03:24 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2022-12-17 22:39:33 +01:00
|
|
|
handler(CommandInteraction: CommandInteraction): GenericCustomReply {
|
|
|
|
this.playbackService.clear();
|
|
|
|
this.discordVoiceService.stop(false);
|
|
|
|
|
|
|
|
return {
|
|
|
|
embeds: [
|
|
|
|
this.discordMessageService.buildMessage({
|
|
|
|
title: 'Playlist cleared',
|
|
|
|
description:
|
|
|
|
'Playback was stopped and your playlist has been cleared',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|
2022-12-16 16:10:16 +01:00
|
|
|
}
|
|
|
|
}
|