generated from nhcarrigan/template
feat: mentorship improvements and name mention notifications #14
+2
-1
@@ -1,2 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
prod
|
prod
|
||||||
|
data/welcomed.txt
|
||||||
@@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
import { ids } from "../config/ids.js";
|
import { ids } from "../config/ids.js";
|
||||||
import { logger } from "../utils/logger.js";
|
import { logger } from "../utils/logger.js";
|
||||||
|
import {
|
||||||
|
addWelcomedMentee,
|
||||||
|
welcomedMentees,
|
||||||
|
} from "../utils/welcomedMentees.js";
|
||||||
import type { Amari } from "../interfaces/amari.js";
|
import type { Amari } from "../interfaces/amari.js";
|
||||||
import type { GuildMember, PartialGuildMember } from "discord.js";
|
import type { GuildMember, PartialGuildMember } from "discord.js";
|
||||||
|
|
||||||
@@ -25,6 +29,7 @@ export const processMentorshipRole = async(
|
|||||||
if (
|
if (
|
||||||
oldMember.roles.cache.has(ids.roles.mentorship)
|
oldMember.roles.cache.has(ids.roles.mentorship)
|
||||||
|| !updatedMember.roles.cache.has(ids.roles.mentorship)
|
|| !updatedMember.roles.cache.has(ids.roles.mentorship)
|
||||||
|
|| welcomedMentees.has(updatedMember.id)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -52,6 +57,7 @@ Last name:
|
|||||||
\`\`\`
|
\`\`\`
|
||||||
Then read our [mentorship wiki](<https://docs.nhcarrigan.com/mentorship/00-faq/>) for the next steps!`,
|
Then read our [mentorship wiki](<https://docs.nhcarrigan.com/mentorship/00-faq/>) for the next steps!`,
|
||||||
});
|
});
|
||||||
|
addWelcomedMentee(updatedMember.id);
|
||||||
await logger.metric("processed_mentorship_role", 1, {
|
await logger.metric("processed_mentorship_role", 1, {
|
||||||
user: updatedMember.id,
|
user: updatedMember.id,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* @copyright NHCarrigan
|
||||||
|
* @license Naomi's Public License
|
||||||
|
* @author Naomi Carrigan
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { appendFileSync, existsSync, readFileSync } from "node:fs";
|
||||||
|
|
||||||
|
const filePath = "data/welcomed.txt";
|
||||||
|
|
||||||
|
const loadWelcomedMentees = (): Set<string> => {
|
||||||
|
if (!existsSync(filePath)) {
|
||||||
|
return new Set();
|
||||||
|
}
|
||||||
|
const contents = readFileSync(filePath, "utf-8");
|
||||||
|
return new Set(contents.split("\n").filter(Boolean));
|
||||||
|
};
|
||||||
|
|
||||||
|
const welcomedMentees = loadWelcomedMentees();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends a mentee's ID to the welcomed set and persists it to disk.
|
||||||
|
* @param id - The Discord user ID to record.
|
||||||
|
*/
|
||||||
|
const addWelcomedMentee = (id: string): void => {
|
||||||
|
welcomedMentees.add(id);
|
||||||
|
appendFileSync(filePath, `${id}\n`);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { addWelcomedMentee, welcomedMentees };
|
||||||
Reference in New Issue
Block a user