feat: more logging
All checks were successful
Node.js CI / Lint and Test (push) Successful in 32s

This commit is contained in:
Naomi Carrigan 2025-02-25 16:44:13 -08:00
parent f3ab9e541f
commit 5bcc436292
Signed by: naomi
SSH Key Fingerprint: SHA256:rca1iUI2OhAM6n4FIUaFcZcicmri0jgocqKiTTAfrt8

View File

@ -3,9 +3,9 @@
* @license Naomi's Public License * @license Naomi's Public License
* @author Naomi Carrigan * @author Naomi Carrigan
*/ */
import { ChannelType, type Client } from "discord.js";
import { channels } from "../config/channels.js"; import { channels } from "../config/channels.js";
import { logger } from "../utils/logger.js"; import { logger } from "../utils/logger.js";
import type { Client } from "discord.js";
/** /**
* Posts a daily standup reminder in configured channels. * Posts a daily standup reminder in configured channels.
@ -16,12 +16,15 @@ export const standup = async(client: Client): Promise<void> => {
const mapped = await Promise.all( const mapped = await Promise.all(
channels.map(async(channel) => { channels.map(async(channel) => {
const fetched = await client.channels.fetch(channel).catch(() => { const fetched = await client.channels.fetch(channel).catch(() => {
void logger.log("warn", `Failed to fetch channel ${channel}.`);
return null; return null;
}); });
if (!fetched) { if (!fetched) {
await logger.log("warn", `Channel ${channel} not found.`);
return null; 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 null;
} }
return fetched; return fetched;
@ -35,7 +38,9 @@ export const standup = async(client: Client): Promise<void> => {
await channel.send( await channel.send(
// eslint-disable-next-line stylistic/max-len -- This message is too long to fit on one line. // 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.", "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) { } catch (error) {