feat(voice): guarantee an empty generated channel disappears

A generated channel could survive with nobody in it: the row was dropped before
the channel was really gone, so a refused delete call left a room nothing could
track anymore, and an event missed while the bot was down was never retried.

The row is now kept until Discord confirms the channel is gone, and a sweep at
startup then every minute deletes whatever the event missed. The grace period
is tunable with VOICE_EMPTY_GRACE_MS, 0 deleting as soon as the room empties.
This commit is contained in:
BlackAngelTV committed 2026-09-15 16:11:30 +02:00
1 parent 836abeafd5
commit 76e2269555
5 files changed
+227 -36

No files matched your search

+11
View File
@@ -10,6 +10,13 @@ const readBool = (key, fallback = false) => {
const value = read(key);
return value === '' ? fallback : value === 'true';
};
/** Durations accept 0, which `readInt` cannot express because 0 is falsy. */
const readDuration = (key, fallback) => {
const value = read(key);
if (value === '') return fallback;
const parsed = Number.parseInt(value, 10);
return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback;
};
export const env = Object.freeze({
nodeEnv: read('NODE_ENV', 'development'),
@@ -47,6 +54,10 @@ export const env = Object.freeze({
voiceCategory: read('CATEGORY_VOICE_ID'),
},
voice: {
emptyGraceMs: readDuration('VOICE_EMPTY_GRACE_MS', 5_000),
},
gitea: {
url: read('GITEA_URL').replace(/\/+$/, ''),
token: read('GITEA_TOKEN'),