fix: replace deprecated ephemeral flag and add error handling across modules

- Replace `ephemeral: true` with `flags: [ MessageFlags.Ephemeral ]` in all command files
- Add try/catch with logger.error to logMenteeJoin, checkAchievements, processMentorshipRole
- Extract handleIssueOpened and handlePrOpened helpers in processGitHubEvent to reduce complexity
- Add logger.error calls in all newly introduced catch blocks
This commit is contained in:
2026-03-03 12:04:20 -08:00
parent 5beebeff44
commit 3f89b7eb4f
8 changed files with 149 additions and 95 deletions
+25 -19
View File
@@ -20,25 +20,31 @@ export const logMenteeJoin = async(
amari: Amari,
member: GuildMember,
): Promise<void> => {
const request = await fetch(`https://forms.nhcarrigan.com/api/database/rows/table/756/?user_field_names=true&search=${member.id}`, { headers: {
authorization: `Token ${process.env.BASEROW_TOKEN ?? "huh"}`,
} });
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Fetch accepts no generic here.
const response = await request.json() as MentorshipRow;
try {
const request = await fetch(`https://forms.nhcarrigan.com/api/database/rows/table/756/?user_field_names=true&search=${member.id}`, { headers: {
authorization: `Token ${process.env.BASEROW_TOKEN ?? "huh"}`,
} });
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Fetch accepts no generic here.
const response = await request.json() as MentorshipRow;
if (response.count <= 0) {
return;
if (response.count <= 0) {
return;
}
const channel = amari.discord.channels.cache.get(ids.channels.general)
?? await amari.discord.channels.fetch(ids.channels.general);
if (channel?.isSendable() !== true) {
await logger.log(
"warn",
"General channel does not exist or is not sendable.",
);
return;
}
await logger.metric("processed_mentee_join", 1, { user: member.id });
} catch (error) {
if (error instanceof Error) {
await logger.error("logMenteeJoin module", error);
}
}
const channel = amari.discord.channels.cache.get(ids.channels.general)
?? await amari.discord.channels.fetch(ids.channels.general);
if (channel?.isSendable() !== true) {
await logger.log(
"warn",
"General channel does not exist or is not sendable.",
);
return;
}
await logger.metric("processed_mentee_join", 1, { user: member.id });
};