From 95037db6b1447d1d52fb62a40b726a0946597260 Mon Sep 17 00:00:00 2001 From: James Shiffer Date: Sun, 8 Oct 2023 19:45:41 -0700 Subject: [PATCH] Check channel existence before sending motd --- discord/bot.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/discord/bot.ts b/discord/bot.ts index c0313a4..c09de36 100644 --- a/discord/bot.ts +++ b/discord/bot.ts @@ -77,6 +77,10 @@ async function scheduleRandomMessage(firstTime = false) { if (!firstTime) { const channel = await client.channels.fetch(process.env.MOTD_CHANNEL); + if (!channel) { + console.warn(`[bot] Channel ${process.env.MOTD_CHANNEL} not found, disabling MOTD.`); + return; + } const randomMessage = await fetchMotd(); await channel.send(randomMessage); logInfo(`[bot] Sent MOTD: ${randomMessage}`);