generated from nhcarrigan/template
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
* @author Naomi Carrigan
|
* @author Naomi Carrigan
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { ids } from "../config/ids.js";
|
||||||
import { respondToMention } from "../modules/respondToMention.js";
|
import { respondToMention } from "../modules/respondToMention.js";
|
||||||
import { updateMentorshipThread } from "../modules/updateMentorshipThread.js";
|
import { updateMentorshipThread } from "../modules/updateMentorshipThread.js";
|
||||||
import type { Amari } from "../interfaces/amari.js";
|
import type { Amari } from "../interfaces/amari.js";
|
||||||
@@ -22,6 +23,10 @@ export const handleMessageCreate = async(
|
|||||||
if (message.author.bot || message.system) {
|
if (message.author.bot || message.system) {
|
||||||
return;
|
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 updateMentorshipThread(amari, message);
|
||||||
await respondToMention(amari, message);
|
await respondToMention(amari, message);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ const amari: Amari = {
|
|||||||
freeCodeCamp: null,
|
freeCodeCamp: null,
|
||||||
hackerNews: null,
|
hackerNews: null,
|
||||||
},
|
},
|
||||||
|
recentlyActiveChannels: new Set<string>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
amari.discord.once(Events.ClientReady, () => {
|
amari.discord.once(Events.ClientReady, () => {
|
||||||
@@ -65,6 +66,9 @@ amari.discord.once(Events.ClientReady, () => {
|
|||||||
await logger.log("debug", "Auditing guild tags.");
|
await logger.log("debug", "Auditing guild tags.");
|
||||||
await cacheData(amari);
|
await cacheData(amari);
|
||||||
});
|
});
|
||||||
|
setInterval(() => {
|
||||||
|
amari.recentlyActiveChannels = new Set<string>();
|
||||||
|
}, 10 * 60 * 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
amari.discord.on(Events.MessageCreate, (message) => {
|
amari.discord.on(Events.MessageCreate, (message) => {
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ export interface Amari {
|
|||||||
freeCodeCamp: string | null;
|
freeCodeCamp: string | null;
|
||||||
hackerNews: string | null;
|
hackerNews: string | null;
|
||||||
};
|
};
|
||||||
|
recentlyActiveChannels: Set<string>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,13 @@ export const respondToMention = async(
|
|||||||
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 } = 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;
|
||||||
}
|
}
|
||||||
|
if (amari.recentlyActiveChannels.has(channel.id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mentions.has(ids.users.naomi, {
|
if (mentions.has(ids.users.naomi, {
|
||||||
ignoreEveryone: true,
|
ignoreEveryone: true,
|
||||||
ignoreRepliedUser: true,
|
ignoreRepliedUser: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user