Make video a per-server toggle instead of an env-wide setting

VIDEO_ENABLED is now permission rather than behaviour: it decides whether
the feature exists at all, while turning it on for a server is a toggle in
the panel or !video in chat, off by default. Video costs real CPU for
every playing channel, so that should be a deliberate choice rather than
something a config flag switches on everywhere.

With the env flag off the panel renders no toggle at all and !video says
so, and the switch applies from the next track — swapping tracks mid-play
would cut the current one.

The loop button no longer reads "выкл" either: it sat next to the video
button showing the same word, so the two states were indistinguishable.
Both now name what they do and rely on highlighting for state.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Leonid Pershin
2026-09-09 02:13:08 +03:00
co-authored by Claude Opus 5
parent e06c42f60c
commit a9b680c418
11 changed files with 92 additions and 13 deletions
+12 -3
View File
@@ -66,7 +66,9 @@ export class GuildPlayer extends EventEmitter<GuildPlayerEvents> {
current: Track | null = null;
volume = config.DEFAULT_VOLUME;
loop: LoopMode = "off";
shuffleUsed = false;
shuffleUsed = false;
/** Per-server switch for publishing the clip; the env flag gates it too. */
videoEnabled = false;
private status: PlayerStatus = "idle";
private readonly revoice: RevoiceLike;
@@ -113,7 +115,8 @@ export class GuildPlayer extends EventEmitter<GuildPlayerEvents> {
history: this.history.slice(0, 10),
volume: this.volume,
loop: this.loop,
shuffleUsed: this.shuffleUsed,
shuffleUsed: this.shuffleUsed,
videoEnabled: this.videoEnabled,
updatedAt: Date.now(),
};
}
@@ -307,7 +310,7 @@ export class GuildPlayer extends EventEmitter<GuildPlayerEvents> {
this.publish();
try {
const input = await openPlayback(track, seekSeconds);
const input = await openPlayback(track, seekSeconds, { video: this.videoEnabled });
this.currentInput = input;
this.expectingStop = false;
await media.playStream(input.input, input.inputOptions);
@@ -464,6 +467,12 @@ export class GuildPlayer extends EventEmitter<GuildPlayerEvents> {
this.publish();
}
/** Takes effect on the next track: switching mid-stream would cut playback. */
setVideo(enabled: boolean): void {
this.videoEnabled = enabled;
this.publish();
}
setLoop(mode: LoopMode): void {
this.loop = mode;
this.publish();