@@ -3,30 +3,26 @@ title: ButtonKit
3
3
description : No description provided
4
4
---
5
5
6
+
6
7
## ButtonKit extends ButtonBuilder
7
8
9
+
8
10
``` typescript
9
- new ButtonKit (data );
11
+ new ButtonKit (data )
10
12
```
13
+ | Parameter | Type | Optional |
14
+ | ----------- | ----------- | ----------- |
15
+ | data | Partial\< ButtonComponentData> \| Partial\< APIButtonComponent> | ✅ |
11
16
12
- | Parameter | Type | Optional |
13
- | --------- | ------------------------------------------------------------- | -------- |
14
- | data | Partial\< ButtonComponentData> \| Partial\< APIButtonComponent> | ✅ |
15
17
16
18
## Properties
17
-
18
19
### public data: any
19
-
20
20
The API data associated with this component.
21
21
22
22
## Methods
23
-
24
23
### public dispose(): ButtonKit
25
-
26
- - [ Source] ( https://github.com/underctrl-io/commandkit/blob/d276a8377813631933aebfa66545130a52f7a7cb/packages/commandkit/src/components/ButtonKit.ts#L165 )
27
-
24
+ - [ Source] ( https://github.com/underctrl-io/commandkit/blob/6e189b13079ad78949d9ad2ddda0cbfd45677e1d/packages/commandkit/src/components/ButtonKit.ts#L165 )
28
25
### public onClick(handler, data?): this
29
-
30
26
Sets up an inline interaction collector for this button. This collector by default allows as many interactions as possible if it is actively used.
31
27
If unused, this expires after 24 hours or custom time if specified.
32
28
@@ -38,99 +34,89 @@ const button = new ButtonKit()
38
34
39
35
const row = new ActionRowBuilder ().addComponents (button );
40
36
41
- const message = await channel .send ({
42
- content: ' Click the button' ,
43
- components: [row ],
44
- });
37
+ const message = await channel .send ({ content: ' Click the button' , components: [row ] });
45
38
46
- button .onClick (
47
- async (interaction ) => {
48
- await interaction .reply (' You clicked me!' );
49
- },
50
- { message },
51
- );
39
+ button .onClick (async (interaction ) => {
40
+ await interaction .reply (' You clicked me!' );
41
+ }, { message });
52
42
53
43
// Remove onClick handler and destroy the interaction collector
54
44
button .onClick (null );
55
45
```
56
46
57
- | Parameter | Type | Optional | Description |
58
- | --------- | -------------------------------------------------------------- | -------- | ------------------------------------------ ----------- |
59
- | handler | CommandKitButtonBuilderInteractionCollectorDispatch | ❌ | The handler to run when the button is clicked |
60
- | data | CommandKitButtonBuilderInteractionCollectorDispatchContextData | ✅ | The context data to use for the interaction collector |
47
+ | Parameter | Type | Optional | Description |
48
+ | ----------- | ----------- | ----------- | ----------- |
49
+ | handler | CommandKitButtonBuilderInteractionCollectorDispatch | ❌ | The handler to run when the button is clicked |
50
+ | data | CommandKitButtonBuilderInteractionCollectorDispatchContextData | ✅ | The context data to use for the interaction collector |
61
51
62
- - [ Source] ( https://github.com/underctrl-io/commandkit/blob/d276a8377813631933aebfa66545130a52f7a7cb/packages/commandkit/src/components/ButtonKit.ts#L74 )
63
52
53
+ - [ Source] ( https://github.com/underctrl-io/commandkit/blob/6e189b13079ad78949d9ad2ddda0cbfd45677e1d/packages/commandkit/src/components/ButtonKit.ts#L74 )
64
54
### public onEnd(handler): this
55
+ | Parameter | Type | Optional |
56
+ | ----------- | ----------- | ----------- |
57
+ | handler | CommandKitButtonBuilderOnEnd | ❌ |
65
58
66
- | Parameter | Type | Optional |
67
- | --------- | ---------------------------- | -------- |
68
- | handler | CommandKitButtonBuilderOnEnd | ❌ |
69
-
70
- - [ Source] ( https://github.com/underctrl-io/commandkit/blob/d276a8377813631933aebfa66545130a52f7a7cb/packages/commandkit/src/components/ButtonKit.ts#L98 )
71
59
60
+ - [ Source] ( https://github.com/underctrl-io/commandkit/blob/6e189b13079ad78949d9ad2ddda0cbfd45677e1d/packages/commandkit/src/components/ButtonKit.ts#L98 )
72
61
### public setCustomId(customId): this
73
-
74
62
Sets the custom id for this button.
75
63
76
- | Parameter | Type | Optional | Description |
77
- | --------- | ------------------------------------------------------------------------------------------------- | -------- | -------------------- |
78
- | customId | [ string] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String ) | ❌ | The custom id to use |
79
64
80
- ### public setDisabled(disabled?): this
81
65
66
+ | Parameter | Type | Optional | Description |
67
+ | ----------- | ----------- | ----------- | ----------- |
68
+ | customId | [ string] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String ) | ❌ | The custom id to use |
69
+ ### public setDisabled(disabled?): this
82
70
Sets whether this button is disabled.
83
71
84
- | Parameter | Type | Optional | Description |
85
- | --------- | --------------------------------------------------------------------------------------------------- | -------- | ------------------------------ |
86
- | disabled | [ boolean] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean ) | ✅ | Whether to disable this button |
87
72
88
- ### public setEmoji(emoji): this
89
73
74
+ | Parameter | Type | Optional | Description |
75
+ | ----------- | ----------- | ----------- | ----------- |
76
+ | disabled | [ boolean] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean ) | ✅ | Whether to disable this button |
77
+ ### public setEmoji(emoji): this
90
78
Sets the emoji to display on this button.
91
79
92
- | Parameter | Type | Optional | Description |
93
- | --------- | ------------------------------------------------------------------------------------------------------------------- | -------- | ---------------- |
94
- | emoji | [ ComponentEmojiResolvable] ( https://discord.js.org/docs/packages/discord.js/main/ComponentEmojiResolvable:TypeAlias ) | ❌ | The emoji to use |
95
80
96
- ### public setLabel(label): this
97
81
82
+ | Parameter | Type | Optional | Description |
83
+ | ----------- | ----------- | ----------- | ----------- |
84
+ | emoji | [ ComponentEmojiResolvable] ( https://discord.js.org/docs/packages/discord.js/main/ComponentEmojiResolvable:TypeAlias ) | ❌ | The emoji to use |
85
+ ### public setLabel(label): this
98
86
Sets the label for this button.
99
87
100
- | Parameter | Type | Optional | Description |
101
- | --------- | ------------------------------------------------------------------------------------------------- | -------- | ---------------- |
102
- | label | [ string] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String ) | ❌ | The label to use |
103
88
104
- ### public setSKUId(skuId): this
105
89
90
+ | Parameter | Type | Optional | Description |
91
+ | ----------- | ----------- | ----------- | ----------- |
92
+ | label | [ string] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String ) | ❌ | The label to use |
93
+ ### public setSKUId(skuId): this
106
94
Sets the SKU id that represents a purchasable SKU for this button.
107
95
108
- | Parameter | Type | Optional | Description |
109
- | --------- | ------------------------------------------------------------------------------------------------- | -------- | ----------------- |
110
- | skuId | [ string] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String ) | ❌ | The SKU id to use |
111
96
112
- ### public setStyle(style): this
113
97
98
+ | Parameter | Type | Optional | Description |
99
+ | ----------- | ----------- | ----------- | ----------- |
100
+ | skuId | [ string] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String ) | ❌ | The SKU id to use |
101
+ ### public setStyle(style): this
114
102
Sets the style of this button.
115
103
116
- | Parameter | Type | Optional | Description |
117
- | --------- | --------------------------------------------------------------------------------------- | -------- | ---------------- |
118
- | style | [ ButtonStyle] ( https://discord-api-types.dev/api/discord-api-types-v10/enum/ButtonStyle ) | ❌ | The style to use |
119
104
120
- ### public setURL(url): this
121
105
106
+ | Parameter | Type | Optional | Description |
107
+ | ----------- | ----------- | ----------- | ----------- |
108
+ | style | [ ButtonStyle] ( https://discord-api-types.dev/api/discord-api-types-v10/enum/ButtonStyle ) | ❌ | The style to use |
109
+ ### public setURL(url): this
122
110
Sets the URL for this button.
123
111
124
- | Parameter | Type | Optional | Description |
125
- | --------- | ------------------------------------------------------------------------------------------------- | -------- | -------------- |
126
- | url | [ string] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String ) | ❌ | The URL to use |
127
112
128
- ### public toJSON(): [ APIButtonComponent] ( https://discord-api-types.dev/api/discord-api-types-v10#APIButtonComponent )
129
113
114
+ | Parameter | Type | Optional | Description |
115
+ | ----------- | ----------- | ----------- | ----------- |
116
+ | url | [ string] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String ) | ❌ | The URL to use |
117
+ ### public toJSON(): [ APIButtonComponent] ( https://discord-api-types.dev/api/discord-api-types-v10#APIButtonComponent )
130
118
ComponentBuilder.toJSON
131
-
132
119
### public static from(other): ButtonBuilder
133
-
134
- | Parameter | Type | Optional |
135
- | --------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- | --- |
136
- | other | [ APIButtonComponent] ( https://discord-api-types.dev/api/discord-api-types-v10#APIButtonComponent ) | JSONEncodable\< [ APIButtonComponent] ( https://discord-api-types.dev/api/discord-api-types-v10#APIButtonComponent ) > | ❌ |
120
+ | Parameter | Type | Optional |
121
+ | ----------- | ----------- | ----------- |
122
+ | other | [ APIButtonComponent] ( https://discord-api-types.dev/api/discord-api-types-v10#APIButtonComponent ) | JSONEncodable\< [ APIButtonComponent] ( https://discord-api-types.dev/api/discord-api-types-v10#APIButtonComponent ) > | ❌ |
0 commit comments