feat: components v2 in builders v1 (#10787)

* feat(builders): components v2 in builders v1

* feat: implemented the first components

* fix: tests

* fix: tests

* fix: export the new stuff

* feat: add rest of components

* feat: add callback syntax

* feat: callback syntax for section

* fix: missing implements

* fix: accessory property

* fix: apply suggestions from v2 PR

* chore: bring in line with builders v2

* fix: add missing type

* chore: split accessory methods

* chore: backport changes from v2 PR

* fix: accent_color is nullish

* fix: allow passing raw json to MediaGallery methods

* fix: add test

* chore: add Container#addXComponents

* fix: docs

* chore: bump discord-api-types

* Update packages/builders/src/components/Assertions.ts

Co-authored-by: Denis-Adrian Cristea <didinele.dev@gmail.com>

---------

Co-authored-by: Denis-Adrian Cristea <didinele.dev@gmail.com>
This commit is contained in:
Qjuh
2025-04-24 21:59:58 +02:00
committed by GitHub
parent 53dbc96194
commit 118e682682
31 changed files with 1955 additions and 120 deletions

View File

@@ -1,5 +1,5 @@
import { getUserAgentAppendix } from '@discordjs/util';
import { APIVersion } from 'discord-api-types/v10';
import { APIVersion, type ImageSize } from 'discord-api-types/v10';
import { getDefaultStrategy } from '../../environment.js';
import type { RESTOptions, ResponseLike } from './types.js';
@@ -48,11 +48,10 @@ export enum RESTEvents {
export const ALLOWED_EXTENSIONS = ['webp', 'png', 'jpg', 'jpeg', 'gif'] as const satisfies readonly string[];
export const ALLOWED_STICKER_EXTENSIONS = ['png', 'json', 'gif'] as const satisfies readonly string[];
export const ALLOWED_SIZES = [16, 32, 64, 128, 256, 512, 1_024, 2_048, 4_096] as const satisfies readonly number[];
export const ALLOWED_SIZES: readonly number[] = [16, 32, 64, 128, 256, 512, 1_024, 2_048, 4_096] satisfies ImageSize[];
export type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number];
export type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number];
export type ImageSize = (typeof ALLOWED_SIZES)[number];
export const OverwrittenMimeTypes = {
// https://github.com/discordjs/discord.js/issues/8557
@@ -67,3 +66,5 @@ export const BurstHandlerMajorIdKey = 'burst';
* @internal
*/
export const DEPRECATION_WARNING_PREFIX = 'DeprecationWarning' as const;
export { type ImageSize } from 'discord-api-types/v10';