Skip to content

Commit e42fd16

Browse files
feat(website): Show constructor information (#8540)
1 parent dd44e8b commit e42fd16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+689
-625
lines changed

packages/builders/.eslintrc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"extends": "../../.eslintrc.json"
2+
"extends": "../../.eslintrc.json",
3+
"plugins": ["eslint-plugin-tsdoc"],
4+
"rules": {
5+
"tsdoc/syntax": "warn"
6+
}
37
}

packages/builders/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"eslint-config-prettier": "^8.5.0",
7575
"eslint-import-resolver-typescript": "^3.4.1",
7676
"eslint-plugin-import": "^2.26.0",
77+
"eslint-plugin-tsdoc": "^0.2.16",
7778
"prettier": "^2.7.1",
7879
"rollup-plugin-typescript2": "0.32.1",
7980
"typescript": "^4.7.4",

packages/builders/src/components/ActionRow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentBu
5959
}
6060

6161
/**
62-
* {@inheritDoc JSONEncodable.toJSON}
62+
* {@inheritDoc ComponentBuilder.toJSON}
6363
*/
6464
public toJSON(): APIActionRowComponent<ReturnType<T['toJSON']>> {
6565
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions

packages/builders/src/components/Component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ export abstract class ComponentBuilder<
2323
public readonly data: Partial<DataType>;
2424

2525
/**
26-
* {@inheritDoc JSONEncodable.toJSON}
26+
* Serializes this component to an API-compatible JSON object
27+
*
28+
* @remarks
29+
* This method runs validations on the data before serializing it.
30+
* As such, it may throw an error if the data is invalid.
2731
*/
2832
public abstract toJSON(): AnyAPIActionRowComponent;
2933

packages/builders/src/components/button/Button.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,35 @@ import { ComponentBuilder } from '../Component';
2121
* Represents a button component
2222
*/
2323
export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
24+
/**
25+
* Creates a new button from API data
26+
* @param data - The API data to create this button with
27+
*
28+
* @example
29+
* Creating a button from an API data object
30+
* ```ts
31+
* const button = new ButtonBuilder({
32+
* style: 'primary',
33+
* label: 'Click Me',
34+
* emoji: {
35+
* name: ':smile:',
36+
* id: '12345678901234567890123456789012',
37+
* },
38+
* custom_id: '12345678901234567890123456789012',
39+
* });
40+
* ```
41+
*
42+
* @example
43+
* Creating a button using setters and API data
44+
* ```ts
45+
* const button = new ButtonBuilder({
46+
* style: 'primary',
47+
* label: 'Click Me',
48+
* })
49+
* .setEmoji({ name: ':smile:', id: '12345678901234567890123456789012' })
50+
* .setCustomId('12345678901234567890123456789012');
51+
* ```
52+
*/
2453
public constructor(data?: Partial<APIButtonComponent>) {
2554
super({ type: ComponentType.Button, ...data });
2655
}
@@ -38,6 +67,10 @@ export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
3867
/**
3968
* Sets the URL for this button
4069
*
70+
* @remarks
71+
* This method is only available to buttons using the `Link` button style.
72+
* Only three types of URL schemes are currently supported: `https://`, `http://` and `discord://`
73+
*
4174
* @param url - The URL to open when this button is clicked
4275
*/
4376
public setURL(url: string) {
@@ -48,6 +81,9 @@ export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
4881
/**
4982
* Sets the custom id for this button
5083
*
84+
* @remarks
85+
* This method is only applicable to buttons that are not using the `Link` button style.
86+
*
5187
* @param customId - The custom id to use for this button
5288
*/
5389
public setCustomId(customId: string) {
@@ -86,7 +122,7 @@ export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
86122
}
87123

88124
/**
89-
* {@inheritDoc JSONEncodable.toJSON}
125+
* {@inheritDoc ComponentBuilder.toJSON}
90126
*/
91127
public toJSON(): APIButtonComponent {
92128
validateRequiredButtonParameters(

packages/builders/src/components/selectMenu/SelectMenu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class SelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent>
117117
}
118118

119119
/**
120-
* {@inheritDoc JSONEncodable.toJSON}
120+
* {@inheritDoc ComponentBuilder.toJSON}
121121
*/
122122
public toJSON(): APISelectMenuComponent {
123123
validateRequiredSelectMenuParameters(this.options, this.data.custom_id);

packages/builders/src/components/selectMenu/SelectMenuOption.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class SelectMenuOptionBuilder implements JSONEncodable<APISelectMenuOptio
6565
}
6666

6767
/**
68-
* {@inheritDoc JSONEncodable.toJSON}
68+
* {@inheritDoc ComponentBuilder.toJSON}
6969
*/
7070
public toJSON(): APISelectMenuOption {
7171
validateRequiredSelectMenuOptionParameters(this.data.label, this.data.value);

packages/builders/src/components/textInput/TextInput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class TextInputBuilder
104104
}
105105

106106
/**
107-
* {@inheritDoc JSONEncodable.toJSON}
107+
* {@inheritDoc ComponentBuilder.toJSON}
108108
*/
109109
public toJSON(): APITextInputComponent {
110110
validateRequiredParameters(this.data.custom_id, this.data.style, this.data.label);

packages/builders/src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class ContextMenuCommandBuilder {
3535
* Whether the command is enabled by default when the app is added to a guild
3636
*
3737
* @deprecated This property is deprecated and will be removed in the future.
38-
* You should use `setDefaultMemberPermissions` or `setDMPermission` instead.
38+
* You should use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
3939
*/
4040
public readonly default_permission: boolean | undefined = undefined;
4141

@@ -86,7 +86,7 @@ export class ContextMenuCommandBuilder {
8686
* @param value - Whether or not to enable this command by default
8787
*
8888
* @see https://discord.com/developers/docs/interactions/application-commands#permissions
89-
* @deprecated Use `setDefaultMemberPermissions` or `setDMPermission` instead.
89+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
9090
*/
9191
public setDefaultPermission(value: boolean) {
9292
// Assert the value matches the conditions

packages/builders/src/interactions/modals/Modal.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ export class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCa
7070
return this;
7171
}
7272

73+
/**
74+
* {@inheritDoc ComponentBuilder.toJSON}
75+
*/
7376
public toJSON(): APIModalInteractionResponseCallbackData {
7477
validateRequiredParameters(this.data.custom_id, this.data.title, this.components);
7578
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions

0 commit comments

Comments
 (0)