foxwells: join request logger

This commit is contained in:
Cynthia Foxwell 2025-03-16 12:11:50 -06:00
parent 1e68c2be12
commit 28bdba1fd4
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -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);
}
});