diff --git a/src/modules/standup.ts b/src/modules/standup.ts index 3c40651..d92bdda 100644 --- a/src/modules/standup.ts +++ b/src/modules/standup.ts @@ -3,9 +3,9 @@ * @license Naomi's Public License * @author Naomi Carrigan */ +import { ChannelType, type Client } from "discord.js"; import { channels } from "../config/channels.js"; import { logger } from "../utils/logger.js"; -import type { Client } from "discord.js"; /** * Posts a daily standup reminder in configured channels. @@ -16,12 +16,15 @@ export const standup = async(client: Client): Promise => { const mapped = await Promise.all( channels.map(async(channel) => { const fetched = await client.channels.fetch(channel).catch(() => { + void logger.log("warn", `Failed to fetch channel ${channel}.`); return null; }); if (!fetched) { + await logger.log("warn", `Channel ${channel} not found.`); return null; } - if (!fetched.isTextBased() || !("send" in fetched)) { + if (fetched.type !== ChannelType.GuildText) { + await logger.log("warn", `Channel ${channel} is not a text channel.`); return null; } return fetched; @@ -35,7 +38,9 @@ export const standup = async(client: Client): Promise => { await channel.send( // eslint-disable-next-line stylistic/max-len -- This message is too long to fit on one line. "Good morning @everyone~! It's time for standup! Please share your goals for today.", - ); + ).catch(() => { + void logger.log("warn", `Failed to send standup reminder in channel ${channel.name}.`); + }); }), ); } catch (error) {