mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-25 02:51:57 +01:00
🐛 Stop command stuck (#244)
This commit is contained in:
parent
4894065d15
commit
02f2dbec3c
@ -50,7 +50,6 @@ export class DiscordVoiceService {
|
||||
},
|
||||
);
|
||||
this.playResource(resource);
|
||||
console.log(resource);
|
||||
}
|
||||
|
||||
tryJoinChannelAndEstablishVoiceConnection(
|
||||
@ -138,9 +137,7 @@ export class DiscordVoiceService {
|
||||
*/
|
||||
@OnEvent('internal.voice.controls.stop')
|
||||
stop(force: boolean): boolean {
|
||||
const stopped = this.createAndReturnOrGetAudioPlayer().stop(force);
|
||||
this.eventEmitter.emit('playback.state.stop');
|
||||
return stopped;
|
||||
return this.createAndReturnOrGetAudioPlayer().stop(force);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -342,9 +339,6 @@ export class DiscordVoiceService {
|
||||
const activeTrack = playlist.getActiveTrack();
|
||||
|
||||
if (!activeTrack) {
|
||||
this.logger.error(
|
||||
"Failed to update ellapsed audio time because active track was unexpectitly undefined",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import { CommandInteraction } from 'discord.js';
|
||||
import { DiscordMessageService } from '../clients/discord/discord.message.service';
|
||||
import { DiscordVoiceService } from '../clients/discord/discord.voice.service';
|
||||
import { defaultMemberPermissions } from 'src/utils/environment';
|
||||
import { PlaybackService } from 'src/playback/playback.service';
|
||||
|
||||
@Injectable()
|
||||
@Command({
|
||||
@ -18,6 +19,7 @@ export class DisconnectCommand {
|
||||
constructor(
|
||||
private readonly discordVoiceService: DiscordVoiceService,
|
||||
private readonly discordMessageService: DiscordMessageService,
|
||||
private readonly playbackService: PlaybackService
|
||||
) {}
|
||||
|
||||
@Handler()
|
||||
@ -30,6 +32,8 @@ export class DisconnectCommand {
|
||||
],
|
||||
});
|
||||
|
||||
this.discordVoiceService.stop(false);
|
||||
this.playbackService.getPlaylistOrDefault().clear();
|
||||
const disconnect = this.discordVoiceService.disconnect();
|
||||
|
||||
if (!disconnect.success) {
|
||||
|
@ -24,25 +24,28 @@ export class StopPlaybackCommand {
|
||||
|
||||
@Handler()
|
||||
async handler(@IA() interaction: CommandInteraction): Promise<void> {
|
||||
const hasActiveTrack = this.playbackService.getPlaylistOrDefault();
|
||||
const title = hasActiveTrack
|
||||
? 'Playback stopped successfully'
|
||||
: 'Playback failed to stop';
|
||||
const description = hasActiveTrack
|
||||
? 'In addition, your playlist has been cleared'
|
||||
: 'There is no active track in the queue';
|
||||
if (hasActiveTrack) {
|
||||
this.discordVoiceService.stop(false);
|
||||
// this.playbackService.getPlaylistOrDefault().clear();
|
||||
const playlist = this.playbackService.getPlaylistOrDefault();
|
||||
|
||||
if (playlist.tracks.length === 0) {
|
||||
await interaction.reply({
|
||||
embeds: [
|
||||
this.discordMessageService.buildErrorMessage({
|
||||
title: 'Unable to stop when nothing is playing'
|
||||
}),
|
||||
],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (playlist.hasActiveTrack()) {
|
||||
this.discordVoiceService.stop(false);
|
||||
}
|
||||
playlist.clear();
|
||||
|
||||
await interaction.reply({
|
||||
embeds: [
|
||||
this.discordMessageService[
|
||||
hasActiveTrack ? 'buildMessage' : 'buildErrorMessage'
|
||||
]({
|
||||
title,
|
||||
description,
|
||||
this.discordMessageService.buildMessage({
|
||||
title: 'Playback stopped'
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user