feat(api): update-roles will report x-audit-log-reason to discord

Signed-off-by: Katalina Okano <git@kat.cafe>
This commit is contained in:
41666 2021-07-17 19:22:16 -04:00
parent 824fee0703
commit d52508a046

View file

@ -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,