Check channel existence before sending motd

This commit is contained in:
James Shiffer 2023-10-08 19:45:41 -07:00
parent 2896eb491e
commit 95037db6b1

View File

@ -77,6 +77,10 @@ async function scheduleRandomMessage(firstTime = false)
{
if (!firstTime) {
const channel = <TextChannel> 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}`);