Clear the search list after a pick, and stop double-announcing tracks
Two bits of clutter visible in one screenshot: the results list stayed in the channel after a track was chosen, still wearing its reactions, and every track produced two lines — the command's own reply and the player's "now playing" notice. Picking now spends the session and deletes the list, so a second reaction does nothing and the message goes away. The player announces a track only when it started one by itself; when a command started it, that command has already said so. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
bf2d04d579
commit
a63db8c957
+7
-5
@@ -306,7 +306,7 @@ export class GuildPlayer extends EventEmitter<GuildPlayerEvents> {
|
||||
/** Starts playback if nothing is currently playing. */
|
||||
async ensurePlaying(): Promise<void> {
|
||||
if (this.current || this.status === "buffering" || this.status === "connecting") return;
|
||||
await this.advance(false);
|
||||
await this.advance(false, false);
|
||||
}
|
||||
|
||||
private async startPlayback(track: Track, seekSeconds = 0): Promise<void> {
|
||||
@@ -425,7 +425,7 @@ export class GuildPlayer extends EventEmitter<GuildPlayerEvents> {
|
||||
}
|
||||
|
||||
/** Moves to the next track. `skipLoop` ignores per-track looping (used by skip). */
|
||||
private async advance(skipLoop: boolean): Promise<void> {
|
||||
private async advance(skipLoop: boolean, announce = true): Promise<void> {
|
||||
const finished = this.current;
|
||||
this.current = null;
|
||||
// The track has to go with the sound: a published video track keeps showing
|
||||
@@ -452,14 +452,16 @@ export class GuildPlayer extends EventEmitter<GuildPlayerEvents> {
|
||||
}
|
||||
|
||||
await this.startPlayback(next);
|
||||
this.notify(`▶️ Сейчас играет: **${next.title}**`);
|
||||
// A command that started this track has already said so; announcing again
|
||||
// would double every line in the channel.
|
||||
if (announce) this.notify(`▶️ Сейчас играет: **${next.title}**`);
|
||||
}
|
||||
|
||||
async skip(count = 1): Promise<Track | null> {
|
||||
if (!this.current && this.queue.length === 0) throw new UserFacingError("Нечего пропускать");
|
||||
for (let i = 1; i < count; i += 1) this.queue.shift();
|
||||
this.teardownPlayback();
|
||||
await this.advance(true);
|
||||
await this.advance(true, false);
|
||||
return this.current;
|
||||
}
|
||||
|
||||
@@ -558,7 +560,7 @@ export class GuildPlayer extends EventEmitter<GuildPlayerEvents> {
|
||||
if (tracks.length === 0) return;
|
||||
this.queue.unshift(...tracks);
|
||||
this.teardownPlayback();
|
||||
await this.advance(true);
|
||||
await this.advance(true, false);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------- housekeeping ---
|
||||
|
||||
Reference in New Issue
Block a user