mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-25 02:51:57 +01:00
🚑 Fix voice connection being stuck in signaling
This commit is contained in:
parent
09a67b087a
commit
54c62f240a
@ -9,6 +9,7 @@ import {
|
||||
joinVoiceChannel,
|
||||
NoSubscriberBehavior,
|
||||
VoiceConnection,
|
||||
VoiceConnectionStatus,
|
||||
} from '@discordjs/voice';
|
||||
|
||||
import { Injectable } from '@nestjs/common';
|
||||
@ -216,6 +217,33 @@ export class DiscordVoiceService {
|
||||
}
|
||||
|
||||
private attachEventListenersToAudioPlayer() {
|
||||
this.voiceConnection.on('debug', (message) => {
|
||||
if (process.env.DEBUG?.toLowerCase() !== 'true') {
|
||||
return;
|
||||
}
|
||||
this.logger.debug(message);
|
||||
});
|
||||
this.voiceConnection.on('error', (err) => {
|
||||
this.logger.error(`Voice connection error: ${err}`);
|
||||
});
|
||||
|
||||
// Tempoary keep alive fix for servers, see https://github.com/discordjs/discord.js/issues/9185
|
||||
this.voiceConnection.on('stateChange', (oldState, newState) => {
|
||||
const oldNetworking = Reflect.get(oldState, 'networking');
|
||||
const newNetworking = Reflect.get(newState, 'networking');
|
||||
|
||||
const networkStateChangeHandler = (
|
||||
oldNetworkState: any,
|
||||
newNetworkState: any,
|
||||
) => {
|
||||
const newUdp = Reflect.get(newNetworkState, 'udp');
|
||||
clearInterval(newUdp?.keepAliveInterval);
|
||||
};
|
||||
|
||||
oldNetworking?.off('stateChange', networkStateChangeHandler);
|
||||
newNetworking?.on('stateChange', networkStateChangeHandler);
|
||||
});
|
||||
|
||||
this.audioPlayer.on('debug', (message) => {
|
||||
this.logger.debug(message);
|
||||
});
|
||||
|
@ -90,7 +90,7 @@ export class GenericPlaylist {
|
||||
* @returns if there is a track next in the playlist
|
||||
*/
|
||||
hasNextTrackInPlaylist() {
|
||||
return this.activeTrackIndex < this.tracks.length;
|
||||
return this.activeTrackIndex + 1 < this.tracks.length;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,11 +33,11 @@ export const Constants = {
|
||||
InvisibleSpace: '\u1CBC',
|
||||
Icons: {
|
||||
JellyfinLogo:
|
||||
'https://github.com/manuel-rw/jellyfin-discord-music-bot/blob/nestjs-migration/images/icons/jellyfin-icon-squared.png?raw=true',
|
||||
'https://raw.githubusercontent.com/manuel-rw/jellyfin-discord-music-bot/master/images/icons/jellyfin-icon-squared.png',
|
||||
SuccessIcon:
|
||||
'https://github.com/manuel-rw/jellyfin-discord-music-bot/blob/nestjs-migration/images/icons/circle-check.png?raw=true',
|
||||
'https://raw.githubusercontent.com/manuel-rw/jellyfin-discord-music-bot/master/images/icons/circle-check.png',
|
||||
ErrorIcon:
|
||||
'https://github.com/manuel-rw/jellyfin-discord-music-bot/blob/nestjs-migration/images/icons/alert-circle.png?raw=true',
|
||||
'https://raw.githubusercontent.com/manuel-rw/jellyfin-discord-music-bot/master/images/icons/alert-circle.png',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user