mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 18:13:29 +01:00
docs(builders): Add some basic documentation (#9359)
This commit is contained in:
@@ -18,15 +18,15 @@ import {
|
||||
import { ComponentBuilder } from '../Component.js';
|
||||
|
||||
/**
|
||||
* Represents a button component
|
||||
* A builder that creates API-compatible JSON data for buttons.
|
||||
*/
|
||||
export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
||||
/**
|
||||
* Creates a new button from API data
|
||||
* Creates a new button from API data.
|
||||
*
|
||||
* @param data - The API data to create this button with
|
||||
* @example
|
||||
* Creating a button from an API data object
|
||||
* Creating a button from an API data object:
|
||||
* ```ts
|
||||
* const button = new ButtonBuilder({
|
||||
* custom_id: 'a cool button',
|
||||
@@ -39,7 +39,7 @@ export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
||||
* });
|
||||
* ```
|
||||
* @example
|
||||
* Creating a button using setters and API data
|
||||
* Creating a button using setters and API data:
|
||||
* ```ts
|
||||
* const button = new ButtonBuilder({
|
||||
* style: ButtonStyle.Secondary,
|
||||
@@ -54,9 +54,9 @@ export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the style of this button
|
||||
* Sets the style of this button.
|
||||
*
|
||||
* @param style - The style of the button
|
||||
* @param style - The style to use
|
||||
*/
|
||||
public setStyle(style: ButtonStyle) {
|
||||
this.data.style = buttonStyleValidator.parse(style);
|
||||
@@ -64,12 +64,12 @@ export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URL for this button
|
||||
* Sets the URL for this button.
|
||||
*
|
||||
* @remarks
|
||||
* This method is only available to buttons using the `Link` button style.
|
||||
* Only three types of URL schemes are currently supported: `https://`, `http://` and `discord://`
|
||||
* @param url - The URL to open when this button is clicked
|
||||
* Only three types of URL schemes are currently supported: `https://`, `http://`, and `discord://`.
|
||||
* @param url - The URL to use
|
||||
*/
|
||||
public setURL(url: string) {
|
||||
(this.data as APIButtonComponentWithURL).url = urlValidator.parse(url);
|
||||
@@ -77,11 +77,11 @@ export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the custom id for this button
|
||||
* Sets the custom id for this button.
|
||||
*
|
||||
* @remarks
|
||||
* This method is only applicable to buttons that are not using the `Link` button style.
|
||||
* @param customId - The custom id to use for this button
|
||||
* @param customId - The custom id to use
|
||||
*/
|
||||
public setCustomId(customId: string) {
|
||||
(this.data as APIButtonComponentWithCustomId).custom_id = customIdValidator.parse(customId);
|
||||
@@ -89,9 +89,9 @@ export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the emoji to display on this button
|
||||
* Sets the emoji to display on this button.
|
||||
*
|
||||
* @param emoji - The emoji to display on this button
|
||||
* @param emoji - The emoji to use
|
||||
*/
|
||||
public setEmoji(emoji: APIMessageComponentEmoji) {
|
||||
this.data.emoji = emojiValidator.parse(emoji);
|
||||
@@ -99,7 +99,7 @@ export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this button is disabled
|
||||
* Sets whether this button is disabled.
|
||||
*
|
||||
* @param disabled - Whether to disable this button
|
||||
*/
|
||||
@@ -109,9 +109,9 @@ export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label for this button
|
||||
* Sets the label for this button.
|
||||
*
|
||||
* @param label - The label to display on this button
|
||||
* @param label - The label to use
|
||||
*/
|
||||
public setLabel(label: string) {
|
||||
this.data.label = buttonLabelValidator.parse(label);
|
||||
|
||||
Reference in New Issue
Block a user