diff --git a/commands/trackopt.mjs b/commands/trackopt.mjs index d172533..42a78b6 100644 --- a/commands/trackopt.mjs +++ b/commands/trackopt.mjs @@ -209,7 +209,7 @@ export async function run(msg, data) { } try { - const applied = p.applyTrackOption(result); + const applied = await p.applyTrackOption(result); if (!applied) { return msg.reply({ embeds: [new EmbedBuilder().setColor("#ff0000").setDescription("❌ Failed to apply alias.")] }); } diff --git a/src/Player.mjs b/src/Player.mjs index 146b31d..b2cdf0d 100644 --- a/src/Player.mjs +++ b/src/Player.mjs @@ -2468,18 +2468,19 @@ export default class Player extends EventEmitter { } } - applyTrackOption(match) { + async 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; + try { + await this.seekToPosition(match.startMs || 0); + } catch (e) { + logger.warn("[Player] TrackOptions apply-seek error:", e.message); + return false; + } + if (match.endMs > 0) { const elapsedMs = Date.now() - this.startedPlaying; const remainingMs = match.endMs - elapsedMs;