/** * @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 => { 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 };