From d52508a04672e51427c6fb06ff06753617a63840 Mon Sep 17 00:00:00 2001 From: Katalina Okano Date: Sat, 17 Jul 2021 19:22:16 -0400 Subject: [PATCH] feat(api): update-roles will report x-audit-log-reason to discord Signed-off-by: Katalina Okano --- packages/api/handlers/update-roles.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/api/handlers/update-roles.ts b/packages/api/handlers/update-roles.ts index b51b29d..9703741 100644 --- a/packages/api/handlers/update-roles.ts +++ b/packages/api/handlers/update-roles.ts @@ -21,10 +21,11 @@ import { const notFound = () => respond({ error: 'guild not found' }, { status: 404 }); export const UpdateRoles = withSession( - ({ guilds, user: { id: userID } }: SessionData) => + ({ guilds, user: { id: userID, username, discriminator } }: SessionData) => async (request: Request) => { const updateRequest = (await request.json()) as RoleUpdate; - const [, , guildID] = new URL(request.url).pathname.split('/'); + const url = new URL(request.url); + const [, , guildID] = url.pathname.split('/'); if (!guildID) { return respond({ error: 'guild ID missing from URL' }, { status: 400 }); @@ -67,6 +68,7 @@ export const UpdateRoles = withSession( method: 'PATCH', headers: { 'content-type': 'application/json', + 'x-audit-log-reason': `${username}#${discriminator} changes their roles via ${url.hostname}`, }, body: JSON.stringify({ roles: newRoles,