mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
feat(leave): add optional channel argument to /leave command
- %leave now accepts an optional `channel` option; defaults to the user's current voice channel when omitted - Updated locale strings to describe the new behaviour and provide clearer error messages (noVoiceChannel, specifyChannel, noPlayerInChannel) fix(PlayerManager): improve voice-state resolution after reboot - Added VoiceManager.voiceStates as a fallback lookup when getVoiceChannelId() returns null on startup - Multi-player guilds now check LiveKit remote participants to determine which channel a user is actually in - Filter out destroyed players when resolving guild player list fix(PlayerManager): deduplicate Last.fm scrobble timers - Added _pendingScrobbleTimers map to prevent duplicate scrobbles when startplay fires multiple times for the same channel - Timers are now properly cleared on song skip and player stop fix(RecoveryManager): restore textChannel after reboot for 24/7 mode - Spawned players after reboot now resolve an announcement channel from server settings or the first available text channel, so song announcements aren't silently dropped fix(Player): remove unused worker semaphore and dead media-player code - Removed _workerSemaphore / _workerQueue / _workerPool semaphore logic - Removed no-op _setupMediaPlayerMonitoring and _cleanupMediaPlayer methods - Removed unused spotifyConfig field fix(CommandHandler): skip Flag instances during option processing
This commit is contained in:
1 parent
7a4009f5c3
commit
9cfa8e2e6c
10 files changed
+188
-100
No files matched your search
+2
-57
@@ -243,8 +243,6 @@ export class Queue extends EventEmitter {
|
||||
return `Moved **${track.title}** from position ${from + 1} to ${to + 1}.`;
|
||||
}
|
||||
|
||||
addFirst(data) { return this.add(data, true); }
|
||||
|
||||
add(data, top = false) {
|
||||
this.emit("queue", { type: "add", data: { append: !top, data } });
|
||||
return top ? this.data.unshift(data) : this.data.push(data);
|
||||
@@ -311,8 +309,6 @@ export default class Player extends EventEmitter {
|
||||
client = null;
|
||||
settings = null;
|
||||
config = {};
|
||||
spotifyConfig = null;
|
||||
|
||||
// revoice.js instances
|
||||
/** @type {import("revoice.js").MediaPlayer|null} */
|
||||
_mediaPlayer = null;
|
||||
@@ -377,7 +373,6 @@ export default class Player extends EventEmitter {
|
||||
this.queue = new Queue();
|
||||
this.client = opts.client;
|
||||
this.config = opts.config ?? {};
|
||||
this.spotifyConfig = opts.config?.spotify;
|
||||
this.settings = opts.settings ?? null;
|
||||
this.settingsMgr = opts.settingsMgr ?? null;
|
||||
this._observedVoiceUsers = opts.observedVoiceUsers ?? null;
|
||||
@@ -739,17 +734,7 @@ export default class Player extends EventEmitter {
|
||||
// @fluxerjs channels do NOT have a .members property.
|
||||
// Use the guild's member manager and filter by voice state instead.
|
||||
const guild = this.client?.guilds?.get?.(this._guildId);
|
||||
if (guild?.members) {
|
||||
for (const member of guild.members.values()) {
|
||||
// GuildMember doesn't expose voice channelId directly in @fluxerjs,
|
||||
// so fall through to the voice_states raw data check below.
|
||||
if (!member?.user?.bot) {
|
||||
// We can't determine channel from member alone — skip here
|
||||
// and rely on _observedVoiceUsers or voice_states instead.
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fallback: iterate raw voice_states on the guild object.
|
||||
// Iterate raw voice_states on the guild object.
|
||||
const voiceStates = guild?.voice_states;
|
||||
if (voiceStates) {
|
||||
const entries = Array.isArray(voiceStates)
|
||||
@@ -892,8 +877,6 @@ export default class Player extends EventEmitter {
|
||||
try {
|
||||
this._mediaPlayer = new MediaPlayer();
|
||||
this._mediaPlayer.setMaxListeners(0);
|
||||
this._setupMediaPlayerMonitoring();
|
||||
|
||||
await this._mediaPlayer.publishToRoom(room);
|
||||
logger.mediaplayer("[Player] MediaPlayer published successfully");
|
||||
return true;
|
||||
@@ -914,18 +897,6 @@ export default class Player extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
_setupMediaPlayerMonitoring() {
|
||||
// No-op: recovery is fully handled by connection.on("disconnect") in join().
|
||||
}
|
||||
|
||||
async _cleanupMediaPlayer() {
|
||||
try {
|
||||
await this._mediaPlayer?.stop();
|
||||
} catch (_) {}
|
||||
|
||||
this._mediaPlayer = null;
|
||||
}
|
||||
|
||||
async _stopMediaPlayer() {
|
||||
this._streamingStopped = true;
|
||||
|
||||
@@ -1624,12 +1595,6 @@ export default class Player extends EventEmitter {
|
||||
this._workerPool = null;
|
||||
}
|
||||
|
||||
while (this._workerQueue.length > 0) {
|
||||
const resolve = this._workerQueue.shift();
|
||||
resolve();
|
||||
}
|
||||
this._workerSemaphore = 0;
|
||||
|
||||
const connToDestroy = this.connection;
|
||||
this.connection = null;
|
||||
this._mediaPlayer = null;
|
||||
@@ -2124,27 +2089,7 @@ export default class Player extends EventEmitter {
|
||||
// Worker Management
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
_workerSemaphore = 0;
|
||||
_workerMaxConcurrent = 3;
|
||||
_workerQueue = [];
|
||||
_workerPool = null;
|
||||
|
||||
_acquireWorkerSlot() {
|
||||
if (this._workerSemaphore < this._workerMaxConcurrent) {
|
||||
this._workerSemaphore++;
|
||||
return Promise.resolve();
|
||||
}
|
||||
return new Promise(resolve => this._workerQueue.push(resolve));
|
||||
}
|
||||
|
||||
_releaseWorkerSlot() {
|
||||
const next = this._workerQueue.shift();
|
||||
if (next) {
|
||||
next();
|
||||
} else {
|
||||
this._workerSemaphore--;
|
||||
}
|
||||
}
|
||||
_workerPool = null;
|
||||
|
||||
_getWorkerPool() {
|
||||
if (!this._workerPool) {
|
||||
|
||||
Reference in new issue
Block a user