From ced0421ee92457c433eca88ee7d1bb3df8b05376 Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Wed, 19 Nov 2025 09:04:47 -0600 Subject: [PATCH] rearange errors --- src/api/util/handlers/Webhook.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/api/util/handlers/Webhook.ts b/src/api/util/handlers/Webhook.ts index 3980b47e..9037f650 100644 --- a/src/api/util/handlers/Webhook.ts +++ b/src/api/util/handlers/Webhook.ts @@ -8,14 +8,6 @@ import { WebhookExecuteSchema } from "@spacebar/schemas"; export const executeWebhook = async (req: Request, res: Response) => { const body = req.body as WebhookExecuteSchema; - if (body.username) { - ValidateName(body.username); - } - - // ensure one of content, embeds, components, or file is present - if (!body.content && !body.embeds && !body.components && !body.file && !body.attachments) { - throw DiscordApiErrors.CANNOT_SEND_EMPTY_MESSAGE; - } const { webhook_id, token } = req.params; const webhook = await Webhook.findOne({ @@ -33,6 +25,15 @@ export const executeWebhook = async (req: Request, res: Response) => { throw DiscordApiErrors.INVALID_WEBHOOK_TOKEN_PROVIDED; } + if (body.username) { + ValidateName(body.username); + } + + // ensure one of content, embeds, components, or file is present + if (!body.content && !body.embeds && !body.components && !body.file && !body.attachments) { + throw DiscordApiErrors.CANNOT_SEND_EMPTY_MESSAGE; + } + const { wait } = req.query; if (!wait) {