feat: track when naomi is recently active
Node.js CI / Lint and Test (push) Successful in 48s

This commit is contained in:
2025-09-02 14:14:03 -07:00
parent 994f50c174
commit 7facefccd8
4 changed files with 14 additions and 1 deletions
+5
View File
@@ -4,6 +4,7 @@
* @author Naomi Carrigan
*/
import { ids } from "../config/ids.js";
import { respondToMention } from "../modules/respondToMention.js";
import { updateMentorshipThread } from "../modules/updateMentorshipThread.js";
import type { Amari } from "../interfaces/amari.js";
@@ -22,6 +23,10 @@ export const handleMessageCreate = async(
if (message.author.bot || message.system) {
return;
}
if (message.author.id === ids.users.naomi
&& !amari.recentlyActiveChannels.has(message.channel.id)) {
amari.recentlyActiveChannels.add(message.channel.id);
}
await updateMentorshipThread(amari, message);
await respondToMention(amari, message);
};
+4
View File
@@ -51,6 +51,7 @@ const amari: Amari = {
freeCodeCamp: null,
hackerNews: null,
},
recentlyActiveChannels: new Set<string>(),
};
amari.discord.once(Events.ClientReady, () => {
@@ -65,6 +66,9 @@ amari.discord.once(Events.ClientReady, () => {
await logger.log("debug", "Auditing guild tags.");
await cacheData(amari);
});
setInterval(() => {
amari.recentlyActiveChannels = new Set<string>();
}, 10 * 60 * 1000);
});
amari.discord.on(Events.MessageCreate, (message) => {
+1
View File
@@ -14,4 +14,5 @@ export interface Amari {
freeCodeCamp: string | null;
hackerNews: string | null;
};
recentlyActiveChannels: Set<string>;
}
+4 -1
View File
@@ -25,10 +25,13 @@ export const respondToMention = async(
try {
const naomi = amari.discord.users.cache.get(ids.users.naomi)
?? await amari.discord.users.fetch(ids.users.naomi);
const { mentions, content, author, url } = message;
const { mentions, content, author, url, channel } = message;
if (author.bot || author.id === ids.users.naomi) {
return;
}
if (amari.recentlyActiveChannels.has(channel.id)) {
return;
}
if (mentions.has(ids.users.naomi, {
ignoreEveryone: true,
ignoreRepliedUser: true,