feat: new slash commands and bug fixes #23

Merged
naomi merged 5 commits from feat/commands-two into main 2026-03-12 23:47:46 -07:00
2 changed files with 11 additions and 6 deletions
Showing only changes of commit 343d712e33 - Show all commits
+4 -2
View File
@@ -29,6 +29,8 @@ export const handleMessageCreate = async(
amari.recentlyActiveChannels.add(message.channel.id); amari.recentlyActiveChannels.add(message.channel.id);
} }
await updateMentorshipThread(amari, message); await updateMentorshipThread(amari, message);
await respondToMention(amari, message); const mentionNotified = await respondToMention(amari, message);
await notifyNameMention(amari, message); if (!mentionNotified) {
await notifyNameMention(amari, message);
}
}; };
+7 -4
View File
@@ -15,21 +15,22 @@ import type { Amari } from "../interfaces/amari.js";
* If so, responds. * If so, responds.
* @param amari -- Amari's instance. * @param amari -- Amari's instance.
* @param message -- The guild message payload from Discord. * @param message -- The guild message payload from Discord.
* @returns Whether a DM notification was sent.
*/ */
// eslint-disable-next-line complexity -- Mainly those reply options... // eslint-disable-next-line complexity -- Mainly those reply options...
export const respondToMention = async( export const respondToMention = async(
amari: Amari, amari: Amari,
message: Message<true>, message: Message<true>,
): Promise<void> => { ): Promise<boolean> => {
try { try {
const naomi = amari.discord.users.cache.get(ids.users.naomi) const naomi = amari.discord.users.cache.get(ids.users.naomi)
?? await amari.discord.users.fetch(ids.users.naomi); ?? await amari.discord.users.fetch(ids.users.naomi);
const { mentions, content, author, url, channel } = message; const { mentions, content, author, url, channel } = message;
if (author.bot || author.id === ids.users.naomi) { if (author.bot || author.id === ids.users.naomi) {
return; return false;
} }
if (amari.recentlyActiveChannels.has(channel.id)) { if (amari.recentlyActiveChannels.has(channel.id)) {
return; return false;
} }
const mentionsNaomi = mentions.has(ids.users.naomi, { const mentionsNaomi = mentions.has(ids.users.naomi, {
ignoreEveryone: true, ignoreEveryone: true,
@@ -45,7 +46,7 @@ export const respondToMention = async(
ignoreRoles: true, ignoreRoles: true,
}) || /nhcarrigan/i.test(content); }) || /nhcarrigan/i.test(content);
if (!mentionsNaomi && !mentionsNHCarrigan) { if (!mentionsNaomi && !mentionsNHCarrigan) {
return; return false;
} }
await naomi.send( await naomi.send(
{ {
@@ -56,9 +57,11 @@ export const respondToMention = async(
await logger.metric("processed_mention", 1, { pingType: mentionsNaomi await logger.metric("processed_mention", 1, { pingType: mentionsNaomi
? "naomi" ? "naomi"
: "nhcarrigan", user: author.id }); : "nhcarrigan", user: author.id });
return true;
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
await logger.error("respond to mention module", error); await logger.error("respond to mention module", error);
} }
return false;
} }
}; };