generated from nhcarrigan/template
This commit is contained in:
parent
f3ab9e541f
commit
5bcc436292
@ -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<void> => {
|
||||
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<void> => {
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user