mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
fix(builders): add proper snowflake validation (#11290)
* fix(builders): add proper snowflake validation close #11289 * fix(builders): use snowflake validation for attachment id * test(builders): add validation tests for snowflake attachment IDs * fix: better regex Co-authored-by: Almeida <github@almeidx.dev> * test(builders): fix snowflake validation in fileBody test * Update packages/builders/src/Assertions.ts Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * fix: update regex --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Almeida <github@almeidx.dev> Co-authored-by: Vlad Frangu <me@vladfrangu.dev> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Buffer } from 'node:buffer';
|
||||
import { AllowedMentionsTypes, ComponentType, MessageFlags, MessageReferenceType } from 'discord-api-types/v10';
|
||||
import { z } from 'zod';
|
||||
import { snowflakePredicate } from '../Assertions.js';
|
||||
import { embedPredicate } from './embed/Assertions.js';
|
||||
import { pollPredicate } from './poll/Assertions.js';
|
||||
|
||||
@@ -15,7 +16,7 @@ export const rawFilePredicate = z.object({
|
||||
|
||||
export const attachmentPredicate = z.object({
|
||||
// As a string it only makes sense for edits when we do have an attachment snowflake
|
||||
id: z.union([z.string(), z.number()]),
|
||||
id: z.union([snowflakePredicate, z.number()]),
|
||||
description: z.string().max(1_024).optional(),
|
||||
duration_secs: z
|
||||
.number()
|
||||
|
||||
Reference in New Issue
Block a user