mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-10-18 11:25:04 +02:00
Listen for Discord disconnect event and make sure it's handled (#259)
This commit is contained in:
parent
941bc8745e
commit
cdb8508226
@ -9,6 +9,7 @@ import {
|
||||
joinVoiceChannel,
|
||||
NoSubscriberBehavior,
|
||||
VoiceConnection,
|
||||
VoiceConnectionStatus,
|
||||
} from '@discordjs/voice';
|
||||
|
||||
import { Injectable } from '@nestjs/common';
|
||||
@ -96,7 +97,12 @@ export class DiscordVoiceService {
|
||||
if (this.voiceConnection === undefined) {
|
||||
this.voiceConnection = getVoiceConnection(member.guild.id);
|
||||
}
|
||||
|
||||
this.voiceConnection?.on(VoiceConnectionStatus.Disconnected, () => {
|
||||
if (this.voiceConnection !== undefined) {
|
||||
const playlist = this.playbackService.getPlaylistOrDefault().clear();
|
||||
this.disconnect();
|
||||
}
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
reply: {},
|
||||
|
Loading…
Reference in New Issue
Block a user