mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-10-18 19:35: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,
|
joinVoiceChannel,
|
||||||
NoSubscriberBehavior,
|
NoSubscriberBehavior,
|
||||||
VoiceConnection,
|
VoiceConnection,
|
||||||
|
VoiceConnectionStatus,
|
||||||
} from '@discordjs/voice';
|
} from '@discordjs/voice';
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
@ -96,7 +97,12 @@ export class DiscordVoiceService {
|
|||||||
if (this.voiceConnection === undefined) {
|
if (this.voiceConnection === undefined) {
|
||||||
this.voiceConnection = getVoiceConnection(member.guild.id);
|
this.voiceConnection = getVoiceConnection(member.guild.id);
|
||||||
}
|
}
|
||||||
|
this.voiceConnection?.on(VoiceConnectionStatus.Disconnected, () => {
|
||||||
|
if (this.voiceConnection !== undefined) {
|
||||||
|
const playlist = this.playbackService.getPlaylistOrDefault().clear();
|
||||||
|
this.disconnect();
|
||||||
|
}
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
reply: {},
|
reply: {},
|
||||||
|
Loading…
Reference in New Issue
Block a user