mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
fixing
This commit is contained in:
1 parent
5ba24bf1df
commit
2ee4a0a86d
2 files changed
+42
-29
No files matched your search
+4
-29
@@ -1,6 +1,7 @@
|
||||
import { CommandBuilder } from "../src/CommandHandler.mjs";
|
||||
import { EmbedBuilder } from "@fluxerjs/core";
|
||||
import { getGlobalColor } from "../src/MessageHandler.mjs";
|
||||
import { logger } from "../src/constants/Logger.mjs";
|
||||
|
||||
const DEFAULT_ALIAS = "default";
|
||||
|
||||
@@ -208,35 +209,9 @@ export async function run(msg, data) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (result.startMs > 0) {
|
||||
await p.seekToPosition(result.startMs);
|
||||
}
|
||||
|
||||
p._clearTrackEndTimer();
|
||||
p._activeTrackOpt = null;
|
||||
|
||||
if (result.endMs > 0) {
|
||||
const elapsedMs = Date.now() - p.startedPlaying;
|
||||
const remainingMs = result.endMs - elapsedMs;
|
||||
if (remainingMs > 0) {
|
||||
const match = result;
|
||||
p._activeTrackOpt = match;
|
||||
p._trackEndTimer = setTimeout(() => {
|
||||
if (p._destroyed || p.leaving || !p._activeTrackOpt) return;
|
||||
logger.player(`[Player] TrackOptions: end time reached (${match.endMs}ms), skipping track`);
|
||||
p._activeTrackOpt = null;
|
||||
p._trackEndTimer = null;
|
||||
p._trackEndRemainingMs = null;
|
||||
p._skipping = true;
|
||||
p._stopMediaPlayer().then(() => {
|
||||
p._doPlayNext();
|
||||
}).catch(() => {
|
||||
p._doPlayNext();
|
||||
});
|
||||
}, remainingMs);
|
||||
}
|
||||
} else {
|
||||
p._activeTrackOpt = result;
|
||||
const applied = p.applyTrackOption(result);
|
||||
if (!applied) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Failed to apply alias.")] });
|
||||
}
|
||||
|
||||
const aliasLabel = safeAlias === DEFAULT_ALIAS ? "default" : safeAlias;
|
||||
|
||||
@@ -2468,6 +2468,44 @@ export default class Player extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
applyTrackOption(match) {
|
||||
if (!match || !this.connection || this._paused) return false;
|
||||
|
||||
if (match.startMs > 0) {
|
||||
this.seekToPosition(match.startMs).catch((e) => {
|
||||
logger.warn("[Player] TrackOptions apply-seek error:", e.message);
|
||||
});
|
||||
}
|
||||
|
||||
this._clearTrackEndTimer();
|
||||
this._activeTrackOpt = null;
|
||||
|
||||
if (match.endMs > 0) {
|
||||
const elapsedMs = Date.now() - this.startedPlaying;
|
||||
const remainingMs = match.endMs - elapsedMs;
|
||||
if (remainingMs > 0) {
|
||||
this._activeTrackOpt = match;
|
||||
this._trackEndTimer = setTimeout(() => {
|
||||
if (this._destroyed || this.leaving || !this._activeTrackOpt) return;
|
||||
logger.player(`[Player] TrackOptions: end time reached (${match.endMs}ms), skipping track`);
|
||||
this._activeTrackOpt = null;
|
||||
this._trackEndTimer = null;
|
||||
this._trackEndRemainingMs = null;
|
||||
this._skipping = true;
|
||||
this._stopMediaPlayer().then(() => {
|
||||
this._doPlayNext();
|
||||
}).catch(() => {
|
||||
this._doPlayNext();
|
||||
});
|
||||
}, remainingMs);
|
||||
}
|
||||
} else {
|
||||
this._activeTrackOpt = match;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async lyrics() {
|
||||
const current = this.queue.getCurrent();
|
||||
if (!current) return null;
|
||||
|
||||
Reference in new issue
Block a user