feat: track if mentees join or leave
Node.js CI / Lint and Test (push) Successful in 45s

This commit is contained in:
2025-09-02 19:34:24 -07:00
parent 9cc8f1fdbb
commit bfaf757d3e
6 changed files with 153 additions and 1 deletions
+44
View File
@@ -0,0 +1,44 @@
/**
* @copyright NHCarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { ids } from "../config/ids.js";
import { logger } from "../utils/logger.js";
import type { Amari } from "../interfaces/amari.js";
import type { GuildMember, PartialGuildMember } from "discord.js";
/**
* Run when a guild member leaves. If the member had the mentorship role,
* notify Naomi.
* @param amari - Amari's instance.
* @param member - The member payload from Discord.
*/
export const logMenteeLeave = async(
amari: Amari,
member: GuildMember | PartialGuildMember,
): Promise<void> => {
if (!member.roles.cache.has(ids.roles.mentorship)) {
return;
}
const channel = amari.discord.channels.cache.get(ids.channels.menteeChat)
?? await amari.discord.channels.fetch(ids.channels.menteeChat);
if (channel?.isSendable() !== true) {
await logger.log(
"warn",
"Mentee Chat channel does not exist or is not sendable.",
);
return;
}
await channel.send({
content: `Hey <@${ids.users.naomi}>~!
<@${member.id}> (${member.user.displayName} - ${member.id}) has left the server.
It seems they were part of the mentorship programme, so you may need to offboard them.`,
});
};