mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
* docs: add missing, fix existing * refactor: new stuff * fix: requested changes * fix: use `@link` for `@mixes` Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> * chore: disable bad eslint rule --------- Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import type { JSONEncodable } from '@discordjs/util';
|
|
import type { APIBaseComponent, ComponentType } from 'discord-api-types/v10';
|
|
|
|
export interface ComponentBuilderBaseData {
|
|
id?: number | undefined;
|
|
}
|
|
|
|
/**
|
|
* The base component builder that contains common symbols for all sorts of components.
|
|
*
|
|
* @typeParam Component - The type of API data that is stored within the builder
|
|
*/
|
|
export abstract class ComponentBuilder<Component extends APIBaseComponent<ComponentType>>
|
|
implements JSONEncodable<Component>
|
|
{
|
|
/**
|
|
* @internal
|
|
*/
|
|
protected abstract readonly data: ComponentBuilderBaseData;
|
|
|
|
/**
|
|
* Sets the id of this component.
|
|
*
|
|
* @param id - The id to use
|
|
*/
|
|
public setId(id: number) {
|
|
this.data.id = id;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Clears the id of this component, defaulting to a default incremented id.
|
|
*/
|
|
public clearId() {
|
|
this.data.id = undefined;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Serializes this builder to API-compatible JSON data.
|
|
*
|
|
* Note that by disabling validation, there is no guarantee that the resulting object will be valid.
|
|
*
|
|
* @param validationOverride - Force validation to run/not run regardless of your global preference
|
|
*/
|
|
public abstract toJSON(validationOverride?: boolean): Component;
|
|
}
|