feat: helper to generate proper syntax for everyone ping
Node.js CI / CI (pull_request) Successful in 40s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 1m1s

This commit is contained in:
2026-01-05 14:08:23 -08:00
parent 971fcae8e3
commit 2692948202
+8 -8
View File
@@ -12,17 +12,17 @@ const channelIds: Record<AnnouncementType, string> = {
company: "1422472775695728661", company: "1422472775695728661",
products: "1386105452881776661", products: "1386105452881776661",
}; };
const roleIds: Record<AnnouncementType, string> = { const roleIds: Record<Exclude<AnnouncementType, "company">, string> = {
community: "1386107941224054895", community: "1386107941224054895",
/**
* Note that this is not a role ID, but the server ID.
* Company announcements ping everyone.
*/
company: "1354624415861833870",
products: "1386107909699666121", products: "1386107909699666121",
}; };
const getAnnouncementPing = (type: AnnouncementType): string => {
return type === "company"
? "@everyone"
: `<@&${roleIds[type]}>`;
};
/** /**
* Forwards an announcement to our Discord server. * Forwards an announcement to our Discord server.
* @param title - The title of the announcement. * @param title - The title of the announcement.
@@ -40,7 +40,7 @@ export const announceOnDiscord = async(
{ {
body: JSON.stringify({ body: JSON.stringify({
allowed_mentions: { parse: [ "users", "roles" ] }, allowed_mentions: { parse: [ "users", "roles" ] },
content: `# ${title}\n\n${content}\n-# <@&${roleIds[type]}>`, content: `# ${title}\n\n${content}\n-# ${getAnnouncementPing(type)}`,
}), }),
headers: { headers: {
"Authorization": `Bot ${process.env.DISCORD_TOKEN ?? ""}`, "Authorization": `Bot ${process.env.DISCORD_TOKEN ?? ""}`,