mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
This commit is contained in:
1 parent
08e5d363fc
commit
665be29a16
9 files changed
+303
-39
No files matched your search
@@ -117,7 +117,7 @@ export class PlayerManager {
|
||||
}
|
||||
|
||||
/** Find a player by both guild and channel. @param {string} guildId @param {string} channelId @returns {Player|null} */
|
||||
getPlayerByGuildAndChannel(guildId, channelId) {
|
||||
getPlayerByGuildAndChannel(guildId, channelId) {
|
||||
const cId = cleanId(channelId);
|
||||
const players = this.getGuildPlayers(guildId);
|
||||
for (const [mapChannelId, player] of players) {
|
||||
@@ -126,6 +126,21 @@ export class PlayerManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-resume all active players after a Lavalink/NodeLink node reconnection.
|
||||
* @async
|
||||
*/
|
||||
async resumeAllOnNodeReconnect() {
|
||||
const activePlayers = [...new Set(this.playerMap.values())].filter(p => p && !p._destroyed && !p.leaving);
|
||||
if (activePlayers.length === 0) return;
|
||||
logger.lavalink(`[PlayerManager] Auto-resuming ${activePlayers.length} player(s) after node reconnection...`);
|
||||
for (const player of activePlayers) {
|
||||
player.resumePlaybackAfterNodeReconnect?.().catch(e =>
|
||||
logger.warn(`[PlayerManager] Resume failed for guild ${player._guildId}:`, e?.message)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a player counts as "busy" — i.e. the bot is actively
|
||||
* serving that channel: a track is loaded (playing or paused), the queue
|
||||
|
||||
Reference in new issue
Block a user