diff --git a/server/.env.example b/server/.env.example index c6be7f11..c22efa4f 100644 --- a/server/.env.example +++ b/server/.env.example @@ -20,3 +20,6 @@ CORS_VALID_DOMAINS=slmn.gg,localhost SLMNGG_LOGS_GUILD_ID= SLMNGG_LOGS_CHANNEL_ID= + +# Set if you want Discord voice bots to run +DISCORD_RUN_VOICE_BOTS= diff --git a/server/src/discord/bot-controller.js b/server/src/discord/bot-controller.js index cb639634..459cb49a 100644 --- a/server/src/discord/bot-controller.js +++ b/server/src/discord/bot-controller.js @@ -101,30 +101,34 @@ async function checkBroadcast(id, broadcast) { } } -onUpdate(async(id, { newData, oldData }) => { - setTimeout(async () => { - if (id === "Broadcasts") { - broadcastIDs = newData.ids.map(id => cleanID(id)); - // check all broadcasts - broadcastIDs.map(id => checkBroadcast(id)); - } +if (!process.env.DISCORD_RUN_VOICE_BOTS) { + console.log("Discord voice bots won't run because DISCORD_RUN_VOICE_BOTS is not set."); +} else { + onUpdate(async(id, { newData, oldData }) => { + setTimeout(async () => { + if (id === "Broadcasts") { + broadcastIDs = newData.ids.map(id => cleanID(id)); + // check all broadcasts + broadcastIDs.map(id => checkBroadcast(id)); + } - if (broadcastIDs.includes(cleanID(id))) { - checkBroadcast(id, newData); - // check broadcast ID - } - if (watchIDs.includes(cleanID(id))) { - broadcastIDs.map(id => checkBroadcast(id)); - } + if (broadcastIDs.includes(cleanID(id))) { + checkBroadcast(id, newData); + // check broadcast ID + } + if (watchIDs.includes(cleanID(id))) { + broadcastIDs.map(id => checkBroadcast(id)); + } - if (id === "Discord Bots") { - let botData = await getBots(); // update manager? - manager.setTokens(botData.filter(d => d?.token).map(d => d.token)); + if (id === "Discord Bots") { + let botData = await getBots(); // update manager? + manager.setTokens(botData.filter(d => d?.token).map(d => d.token)); - // manager.createJob("996236081819303936", "bpl4", "assistance"); - } - }, 100); -}); + // manager.createJob("996236081819303936", "bpl4", "assistance"); + } + }, 100); + }); +} /** @@ -378,6 +382,7 @@ class DiscordBot { } checkJob(currentChannelID) { + console.log("checking job", this.job); if (!this.job) return this.log(`No job but currently in channel ${currentChannelID}`); this.log(`Current job is ${this.socketRoom} ${this.job.broadcastKey}/${this.job.taskKey} ${this.job.channelID}`);