mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-23 18:21:55 +01:00
✨ Implement stop command
This commit is contained in:
parent
7d8dc888c3
commit
4be0ca1537
@ -92,6 +92,13 @@ export class DiscordVoiceService {
|
|||||||
this.createAndReturnOrGetAudioPlayer().pause();
|
this.createAndReturnOrGetAudioPlayer().pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the audio player
|
||||||
|
*/
|
||||||
|
stop(force: boolean): boolean {
|
||||||
|
return this.createAndReturnOrGetAudioPlayer().stop(force);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unpauses the current audio player
|
* Unpauses the current audio player
|
||||||
*/
|
*/
|
||||||
|
@ -1,23 +1,35 @@
|
|||||||
import { TransformPipe } from '@discord-nestjs/common';
|
import { TransformPipe } from '@discord-nestjs/common';
|
||||||
|
|
||||||
import {
|
import { Command, DiscordCommand, UsePipes } from '@discord-nestjs/core';
|
||||||
Command,
|
import { CommandInteraction } from 'discord.js';
|
||||||
DiscordTransformedCommand,
|
import { DiscordMessageService } from '../clients/discord/discord.message.service';
|
||||||
TransformedCommandExecutionContext,
|
import { DiscordVoiceService } from '../clients/discord/discord.voice.service';
|
||||||
UsePipes,
|
import { GenericCustomReply } from '../models/generic-try-handler';
|
||||||
} from '@discord-nestjs/core';
|
import { PlaybackService } from '../playback/playback.service';
|
||||||
import { InteractionReplyOptions } from 'discord.js';
|
|
||||||
|
|
||||||
@Command({
|
@Command({
|
||||||
name: 'stop',
|
name: 'stop',
|
||||||
description: 'Stop playback entirely and clear the current playlist',
|
description: 'Stop playback entirely and clear the current playlist',
|
||||||
})
|
})
|
||||||
@UsePipes(TransformPipe)
|
@UsePipes(TransformPipe)
|
||||||
export class StopPlaybackCommand implements DiscordTransformedCommand<unknown> {
|
export class StopPlaybackCommand implements DiscordCommand {
|
||||||
handler(
|
constructor(
|
||||||
dto: unknown,
|
private readonly playbackService: PlaybackService,
|
||||||
executionContext: TransformedCommandExecutionContext<any>,
|
private readonly discordMessageService: DiscordMessageService,
|
||||||
): InteractionReplyOptions | string {
|
private readonly discordVoiceService: DiscordVoiceService,
|
||||||
return 'nice';
|
) {}
|
||||||
|
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',
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user