From 0d158babe2e48559566d8228f7e0bdd2fa9c1e23 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Fri, 23 Jul 2021 12:13:08 -0600 Subject: [PATCH] Move the callback rejection before creating the webhook --- src/endpoints/discord/auth/callback.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/endpoints/discord/auth/callback.ts b/src/endpoints/discord/auth/callback.ts index eea3ab5..2a6167c 100644 --- a/src/endpoints/discord/auth/callback.ts +++ b/src/endpoints/discord/auth/callback.ts @@ -9,6 +9,10 @@ export default { async handler(request: Request, h: ResponseToolkit) { let { code, guild_id: gID } = request.query; + // Assert the guild is allowed to be setup. + if (!config.guilds[gID]) { + throw boom.notFound(`Cannot save a webhook for a guild that doesn't have a config set up.`); + }; let data = new URLSearchParams(); data.set(`client_id`, config.discord.client_id);