summary refs log tree commit diff
path: root/src/api/util
diff options
context:
space:
mode:
authorMathMan05 <mathmanrm@gmail.com>2025-11-19 09:04:47 -0600
committerMathMan05 <mathmanrm@gmail.com>2025-11-19 09:04:47 -0600
commitced0421ee92457c433eca88ee7d1bb3df8b05376 (patch)
treed5a7f69c770a327f4b05ef7d8518d4560b735874 /src/api/util
parentfixes (diff)
downloadserver-ts-ced0421ee92457c433eca88ee7d1bb3df8b05376.tar.xz
rearange errors
Diffstat (limited to 'src/api/util')
-rw-r--r--src/api/util/handlers/Webhook.ts17
1 files 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) {