From 28bdba1fd4ee63c479fc22a1e906273b863a10a1 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Sun, 16 Mar 2025 12:11:50 -0600 Subject: [PATCH] foxwells: join request logger --- src/modules/foxwells.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/modules/foxwells.js b/src/modules/foxwells.js index 62ad126..e3e079a 100644 --- a/src/modules/foxwells.js +++ b/src/modules/foxwells.js @@ -263,3 +263,33 @@ async function processReaction(_msg, reaction, user) { events.add("messageReactionAdd", "vinboard", processReaction); events.add("messageReactionRemove", "vinboard", processReaction); + +/* join request logger */ +const STAFF_CHANNEL_ID = "662007759738372096"; + +function processJoinRequest(data) { + if (data.status !== "SUBMITTED") return; + if (!data.request) return; + if (data.request.guild_id !== FOXWELLS_GUILD_ID) return; + + const channel = hf.bot.guilds.get(FOXWELLS_GUILD_ID).channels.get(STAFF_CHANNEL_ID); + const userId = data.request.user_id; + + channel.createMessage({ + embeds: [ + { + title: "New join request", + description: `<@${userId}> (\`${userId}\`)`, + fields: data.request.form_responses + .filter((field) => field.field_type !== "TERMS") + .map((field) => ({name: field.label, value: `\`\`\`\n${field.response}\n\`\`\``})), + }, + ], + }); +} + +events.add("unknown", "foxwells_joinrequest", (packet) => { + if (packet.t === "GUILD_JOIN_REQUEST_UPDATE") { + processJoinRequest(packet.d); + } +});