generated from nhcarrigan/template
feat: new slash commands and bug fixes #23
@@ -29,6 +29,8 @@ export const handleMessageCreate = async(
|
||||
amari.recentlyActiveChannels.add(message.channel.id);
|
||||
}
|
||||
await updateMentorshipThread(amari, message);
|
||||
await respondToMention(amari, message);
|
||||
await notifyNameMention(amari, message);
|
||||
const mentionNotified = await respondToMention(amari, message);
|
||||
if (!mentionNotified) {
|
||||
await notifyNameMention(amari, message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,21 +15,22 @@ import type { Amari } from "../interfaces/amari.js";
|
||||
* If so, responds.
|
||||
* @param amari -- Amari's instance.
|
||||
* @param message -- The guild message payload from Discord.
|
||||
* @returns Whether a DM notification was sent.
|
||||
*/
|
||||
// eslint-disable-next-line complexity -- Mainly those reply options...
|
||||
export const respondToMention = async(
|
||||
amari: Amari,
|
||||
message: Message<true>,
|
||||
): Promise<void> => {
|
||||
): Promise<boolean> => {
|
||||
try {
|
||||
const naomi = amari.discord.users.cache.get(ids.users.naomi)
|
||||
?? await amari.discord.users.fetch(ids.users.naomi);
|
||||
const { mentions, content, author, url, channel } = message;
|
||||
if (author.bot || author.id === ids.users.naomi) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (amari.recentlyActiveChannels.has(channel.id)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
const mentionsNaomi = mentions.has(ids.users.naomi, {
|
||||
ignoreEveryone: true,
|
||||
@@ -45,7 +46,7 @@ export const respondToMention = async(
|
||||
ignoreRoles: true,
|
||||
}) || /nhcarrigan/i.test(content);
|
||||
if (!mentionsNaomi && !mentionsNHCarrigan) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
await naomi.send(
|
||||
{
|
||||
@@ -56,9 +57,11 @@ export const respondToMention = async(
|
||||
await logger.metric("processed_mention", 1, { pingType: mentionsNaomi
|
||||
? "naomi"
|
||||
: "nhcarrigan", user: author.id });
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
await logger.error("respond to mention module", error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user