Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit 6fff322

Browse files
committed
chore: support select menus in modals
1 parent 832bab8 commit 6fff322

15 files changed

+822
-161
lines changed

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
Hello! This is the Change log section of Discord-Modals. Here you can see what things have been changed in the different versions, to be informed. This will be updated every time there are new versions. I hope you enjoy this package :)
44

5-
# v1.3.6 (Stable)
5+
# v1.3.7 (Stable)
6+
7+
**Surprise!** We are back.
8+
9+
**Featured:** Discord Developers announced Select Menus in modals, they are about to finish to develop it, but you can use it now.
10+
**So, now Discord-Modals supports Select Menus in modals!** 🎉
11+
12+
- Chore: Support Select Menus in Modals.
13+
- Chore: Some improvements to FAQ.
14+
- Chore: [Select Menus] Update readme to new examples.
15+
- Chore: [Select Menus] Update docs.
16+
17+
# v1.3.6
618

719
**Probably** this will be the final version of Discord-Modals. Thank you so much for all the support!
820

DOCS.md

Lines changed: 220 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Shows the Modal to the Interaction User.
5454

5555
## Modal
5656
Represents a Modal Form to be shown in response to an Interaction.
57-
- A modal can contain at most **5 Action Rows**. Each of them can contain **1 Text Input Component**.
57+
- A modal can contain at most **5 Action Rows**. Each of them can contain **1 Text Input/Select Menu Component**.
5858

5959
```javascript
6060
new Modal(data)
@@ -80,8 +80,8 @@ The Custom Id of the Modal.
8080
> Returns: [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
8181
8282
#### .components
83-
The Text Input Components of the Modal.
84-
> Returns: [Array<TextInputComponent>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
83+
The Components of the Modal.
84+
> Returns: [Array<TextInputComponent|SelectMenuComponent>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
8585
8686
### Methods
8787

@@ -108,24 +108,24 @@ Sets the Custom Id of the Modal. (Max. 100 characters)
108108
> Returns: [Modal](#modal)
109109
110110
```js
111-
.addComponents(...TextInputComponent)
111+
.addComponents(...components)
112112
```
113113
Adds the Components of the Modal.
114114

115115
| Parameter |Type|Description|
116116
| ------------ | ------------ |------------ |
117-
| *TextInputComponent* |[TextInputComponent](#textinputcomponent)| The Text Input Component to add in the Modal. |
117+
| *Components* |[TextInputComponent](#textinputcomponent) | [SelectMenuComponent](#selectmenucomponent)| The components to add in the Modal. |
118118

119119
> Returns: [Modal](#modal)
120120
121121
```js
122-
.setComponents(...TextInputComponent)
122+
.setComponents(...components)
123123
```
124-
Sets the Components of the Modal.
124+
Adds the Components of the Modal.
125125

126126
| Parameter |Type|Description|
127127
| ------------ | ------------ |------------ |
128-
| *TextInputComponent* |[TextInputComponent](#textinputcomponent)| The Text Input Component to set in the Modal. |
128+
| *Components* |[TextInputComponent](#textinputcomponent) | [SelectMenuComponent](#selectmenucomponent)| The components to set in the Modal. |
129129

130130
> Returns: [Modal](#modal)
131131
@@ -302,6 +302,146 @@ Transforms the TextInputComponent to a plain object.
302302
| SHORT |1 [[Short]](https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-styles)| A single-line input |
303303
| LONG |2 [[Paragraph]](https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-styles)| A multi-line input |
304304

305+
## SelectMenuComponent
306+
> extends [BaseMessageComponent](https://discord.js.org/#/docs/discord.js/stable/class/BaseMessageComponent)
307+
308+
Represents a Select Menu Component of a Modal.
309+
310+
```javascript
311+
new SelectMenuComponent(data)
312+
```
313+
314+
| Properties |Methods|
315+
| ------------ | ------------ |
316+
| `.customId` | `.setCustomId()` |
317+
| `.placeholder` | `.setPlaceholder()` |
318+
| `.minValues` | `.setMinValues()` |
319+
| `.maxValues` | `.setMaxValues()` |
320+
| `.options` | `.addOptions()` |
321+
| `.disabled` | `.setOptions()` |
322+
| | `.spliceOptions()` |
323+
| | `.setDisabled()` |
324+
| | `.toJSON()` |
325+
326+
### Properties
327+
328+
#### .customId
329+
The Custom Id of the Select Menu Component.
330+
> Returns: [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
331+
332+
#### .placeholder
333+
The Placeholder (text when nothing is selected) of the Select Menu Component.
334+
> Returns: [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
335+
336+
#### .minValues
337+
Minimum number of selections allowed for the Select Menu Component.
338+
> Returns: [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
339+
340+
#### .maxValues
341+
Maximum number of selections allowed for the Select Menu Component.
342+
> Returns: [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
343+
344+
#### .options
345+
The Options of the Select Menu Component.
346+
> Returns: Array<[APISelectMenuOption](https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure)>
347+
348+
#### .disabled
349+
If the Select Menu Component is disabled.
350+
> Returns: [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)
351+
352+
### Methods
353+
354+
```js
355+
.setCustomId('menu-customid')
356+
```
357+
Sets the Custom Id of the Select Menu Component. (Max. 100 characters)
358+
359+
| Parameter |Type|Description|
360+
| ------------ | ------------ |------------ |
361+
| *MenuCustomId* |[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)| The Custom Id of the Select Menu Component. |
362+
363+
> Returns: [SelectMenuComponent](#selectmenucomponent)
364+
365+
```js
366+
.setPlaceholder('Menu Placeholder')
367+
```
368+
Sets the Placeholder of the Select Menu Component. (Max. 150 characters)
369+
370+
| Parameter |Type|Description|
371+
| ------------ | ------------ |------------ |
372+
| *MenuPlaceholder* |[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)| The placeholder of the Select Menu Component. |
373+
374+
> Returns: [SelectMenuComponent](#selectmenucomponent)
375+
376+
```js
377+
.setMinValues(Number)
378+
```
379+
Sets the minimum number of selections allowed for the Select Menu Component.
380+
381+
| Parameter |Type|Description|
382+
| ------------ | ------------ |------------ |
383+
| *Number* |[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) (Between 1 - 25)| Number of selections to be required. |
384+
385+
> Returns: [SelectMenuComponent](#selectmenucomponent)
386+
387+
```js
388+
.setMaxValues(Number)
389+
```
390+
Sets the maximum number of selections allowed for the Select Menu Component.
391+
392+
| Parameter |Type|Description|
393+
| ------------ | ------------ |------------ |
394+
| *Number* |[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) (Between 1 - 25)| Number of selections to be allowed. |
395+
396+
> Returns: [SelectMenuComponent](#selectmenucomponent)
397+
398+
```js
399+
.addOptions(...options)
400+
```
401+
Adds options to the Select Menu Component.
402+
403+
| Parameter |Type|Description|
404+
| ------------ | ------------ |------------ |
405+
| *Options* |[APISelectMenuOption](https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure)| The options to add. |
406+
407+
> Returns: [SelectMenuComponent](#selectmenucomponent)
408+
409+
```js
410+
.setOptions(...options)
411+
```
412+
Sets the options of the Select Menu Component.
413+
414+
| Parameter |Type|Description|
415+
| ------------ | ------------ |------------ |
416+
| *Options* |[APISelectMenuOption](https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure)| The options to set. |
417+
418+
> Returns: [SelectMenuComponent](#selectmenucomponent)
419+
420+
```js
421+
.spliceOptions()
422+
```
423+
Removes, replaces, and inserts options in the Select Menu Component.
424+
425+
> Returns: [SelectMenuComponent](#selectmenucomponent)
426+
427+
```js
428+
.setDisabled(Boolean)
429+
```
430+
Sets a Boolean if a Select Menu Component will be disabled.
431+
432+
| Parameter |Type|Description|
433+
| ------------ | ------------ |------------ |
434+
| *Boolean* |[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)| If the Select Menu Component will be disabled. |
435+
436+
> Returns: [SelectMenuComponent](#selectmenucomponent)
437+
438+
```js
439+
.toJSON()
440+
```
441+
Transforms the Select Menu Component to a plain object.
442+
443+
> Returns: [APISelectMenuComponent](https://discord.com/developers/docs/interactions/message-components#select-menus-select-menu-example)
444+
305445
## ModalActionRow
306446
Represents a Modal Action Row, that contains a Text Input Component.
307447

@@ -318,40 +458,39 @@ The type of the Modal Action Row (1).
318458
> Returns: [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)
319459
320460
#### .components
321-
The Text Input Component of this Action Row.
322-
> Returns: [Array<APITextInputComponent>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
461+
The Text Input/Select Menu Component of this Action Row.
462+
> Returns: [Array<APITextInputComponent|APISelectMenuComponent>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
323463
324464
### Methods
325465

326466
```js
327-
.addComponent(TextInputComponent)
467+
.addComponent(component)
328468
```
329-
Adds a Text Input Component.
469+
Adds a Text Input/Select Menu Component.
330470

331471
| Parameter |Type|Description|
332472
| ------------ | ------------ |------------ |
333-
| *TextInputComponent* |[TextInputComponent](#textinputcomponent)| The Text Input Component to add in the Action Row. |
473+
| *Component* |[TextInputComponent](#textinputcomponent)|[SelectMenuComponent](#selectmenucomponent)| The component to add in the Action Row. |
334474

335475
> Returns: [ModalActionRow](#modalactionrow)
336476
337477
```js
338-
.componentToJSON(TextInputComponent)
478+
.componentToJSON(component)
339479
```
340-
Transforms a Text Input Component to a plain object.
480+
Transforms a Text Input/Select Menu Component to a plain object.
341481

342482
| Parameter |Type|Description|
343483
| ------------ | ------------ |------------ |
344-
| *TextInputComponent* |[TextInputComponent](#textinputcomponent)| The Text Input Component to transform. |
484+
| *Component* |[TextInputComponent](#textinputcomponent)|[SelectMenuComponent](#selectmenucomponent)| The component to add in the Action Row. |
345485

346-
> Returns: [APITextInputComponent](https://discord.com/developers/docs/interactions/message-components#text-inputs)
486+
> Returns: [APITextInputComponent](https://discord.com/developers/docs/interactions/message-components#text-inputs) | [APISelectMenuComponent](https://discord.com/developers/docs/interactions/message-components#select-menus-select-menu-example)
347487
348488
```js
349489
.toJSON()
350490
```
351491
Transforms the Modal Action Row to a plain object.
352492

353-
> Returns: [APIModalActionRowComponent<APITextInputComponent>](https://discord.com/developers/docs/interactions/message-components#text-inputs)
354-
493+
> Returns: APIModalActionRowComponent<APITextInputComponent|APISelectMenuComponent>
355494
356495
## ModalSubmitField
357496
Represents a Field of a Modal Submit Interaction.
@@ -376,6 +515,29 @@ The Custom Id of the Modal Submit Field.
376515
The Value of the Modal Submit Field.
377516
> Returns: [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
378517
518+
## ModalSubmitSelectMenu
519+
Represents a Select Menu Component of a Modal Submit Interaction.
520+
521+
| Properties |Methods|
522+
| ------------ | ------------ |
523+
| `.type` | |
524+
| `.customId` | |
525+
| `.values` | |
526+
527+
### Properties
528+
529+
#### .type
530+
The type of the Select Menu Component (SELECT_MENU).
531+
> Returns: [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
532+
533+
#### .customId
534+
The Custom Id of the Select Menu Component.
535+
> Returns: [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)
536+
537+
#### .values
538+
The Values of the Select Menu Component.
539+
> Returns: [Array<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
540+
379541
## ModalSubmitInteraction
380542
> extends [Interaction](https://discord.js.org/#/docs/discord.js/stable/class/Interaction)
381543
@@ -385,17 +547,18 @@ Represents a Modal Submit Interaction.
385547
| ------------ | ------------ |
386548
| `.customId` | `.getTextInputValue()` |
387549
| `.components` | `.getField()` |
388-
| `.fields` | `.deferReply()` |
389-
| `.id` | `.reply()` |
390-
| `.applicationId` | `.fetchReply()` |
391-
| `.channelId` | `.editReply()` |
392-
| `.guildId` | `.deleteReply()` |
393-
| `.user` | `.followUp()` |
394-
| `.member` | `.update()` |
395-
| `.memberPermissions` | `.isFromMessage()` |
396-
| `.locale` | `.isRepliable()` |
397-
| `.guildLocale` | |
398-
| `.message` | |
550+
| `.fields` | `.getSelectMenuValues()` |
551+
| `.selectMenus` | `.getSelectMenu()` |
552+
| `.id` | `.deferReply()` |
553+
| `.applicationId` | `.reply()` |
554+
| `.channelId` | `.fetchReply()` |
555+
| `.guildId` | `.editReply()` |
556+
| `.user` | `.deleteReply()` |
557+
| `.member` | `.followUp()` |
558+
| `.memberPermissions` | `.update()` |
559+
| `.locale` | `.isFromMessage()` |
560+
| `.guildLocale` | `.isRepliable()` |
561+
| `.message` | |
399562
| `.version` | |
400563
| `.webhook` | |
401564
| `.type` | |
@@ -414,6 +577,10 @@ The Action Rows of the modal with the Text Input Components.
414577
The (Fields) Text Input Components of the Modal.
415578
> Returns: [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
416579
580+
#### .selectMenus
581+
The Select Menu Components of the Modal.
582+
> Returns: [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
583+
417584
#### .id
418585
The Id of the Modal Submit Interaction.
419586
> Returns: [Snowflake](https://discord.js.org/#/docs/discord.js/stable/typedef/Snowflake)
@@ -486,6 +653,28 @@ Gets a Modal Submit Field.
486653

487654
> Returns: [ModalSubmitField](#modalsubmitfield)
488655
656+
```js
657+
.getSelectMenuValues('menu-customid')
658+
```
659+
Gets the values of a Select Menu Component.
660+
661+
| Parameter |Type|Description|
662+
| ------------ | ------------ |------------ |
663+
| *MenuCustomId* |[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)| The Custom Id of the Select Menu Component. |
664+
665+
> Returns: [ModalSubmitSelectMenu#values](#modalsubmitselectmenu)
666+
667+
```js
668+
.getSelectMenu('menu-customid')
669+
```
670+
Gets a Select Menu Component.
671+
672+
| Parameter |Type|Description|
673+
| ------------ | ------------ |------------ |
674+
| *MenuCustomId* |[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)| The Custom Id of the Select Menu Component. |
675+
676+
> Returns: [ModalSubmitSelectMenu](#modalsubmitselectmenu)
677+
489678
```js
490679
.isFromMessage()
491680
```
@@ -532,4 +721,4 @@ Discord-Modals integrates some errors to avoid issues and respect the structures
532721

533722
> **Powered by Discord-Modals**
534723
535-
- ❤️ Special thanks to [Leo Ua#4600](https://github.com/Leoxyzua), [polarsito#8964](https://github.com/polarsito) and [Andleo#1700](https://github.com/andleo17) for helping along the way!
724+
- ❤️ Special thanks to [Leo Ua#4600](https://github.com/Leoxyzua), [polarsito#8964](https://github.com/polarsito) and [Andleo#1700](https://github.com/andleo17) for helping along the way!

0 commit comments

Comments
 (0)