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