Make bot sticky to its configured VC
This commit is contained in:
parent
6a6be77dbd
commit
1fc86a56c2
@ -274,13 +274,21 @@ class MusicPlayer implements Initialisable
|
||||
if (!connectionData)
|
||||
return;
|
||||
|
||||
const config = this.#options.guilds.find(conf => conf.id === guild.id);
|
||||
const { connection } = connectionData;
|
||||
const { me } = guild.members;
|
||||
if (!me || !config)
|
||||
return;
|
||||
try
|
||||
{
|
||||
await Promise.race([
|
||||
entersState(connection, VoiceConnectionStatus.Signalling, 5_000),
|
||||
entersState(connection, VoiceConnectionStatus.Connecting, 5_000)
|
||||
]);
|
||||
// If we find ourselves here, the bot was successfully able to reconnect to a VC
|
||||
// Now we check if it's the one it's meant to be in
|
||||
if (me.voice.channelId !== config.voiceChannel)
|
||||
this.#joinVoiceChannel(guild, config.voiceChannel, config.textOutput);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -288,10 +296,7 @@ class MusicPlayer implements Initialisable
|
||||
// this.#logger.error('Promise error:', err as Error);
|
||||
connection.destroy();
|
||||
this.#connections.delete(guild.id);
|
||||
const details = this.#options.guilds.find((conf) => conf.id === guild.id);
|
||||
if (!details)
|
||||
return;
|
||||
this.#joinVoiceChannel(guild, details.voiceChannel, details.textOutput);
|
||||
this.#joinVoiceChannel(guild, config.voiceChannel, config.textOutput);
|
||||
}
|
||||
// if (newState.status !== VoiceConnectionStatus.Disconnected)
|
||||
// return;
|
||||
|
Loading…
Reference in New Issue
Block a user