discordjs-modal v1.0.10
Index
- Description
- Install
- Report a bug
- Incorporate to discord.js
- Uploading the package to the main file
- Working with events
- Send modal
- Documentation
- Structures
- Modal
- Constructor
- Properties
- Methods
- TextInput
- Constructor
- Properties
- Methods
- Modal
- Events
- modal
- Example
- modal
- Types
- ModalOptions
- TextInputOptions
- TextInputStyles
- Structures
Description
discordjs-modal is a dedicated package for developers who want to use the new modals in discord.js
Report a bug
Any bug that occurs while you are using discordjs-modal and the error is produced by discordjs-modal you can report it by contacting me through discord, tag: Risto#5227 Preferably send a screenshot of the console, a brief description of the error and in case of power, a capture or the code where the error is occurring
Incorporate to discord.js
Uploading the package to the main file
const { Client } = require('discord.js') // Get the Client class
const client = new Client({ intents: 32767 }) // Create a new Client
const discordjsModal = require('discordjs-modal') // Define this package
discordjsModal(client); // It is necessary to have your client to be able to know when a modal is executed
client.login('token') // Login with your discord bot
Send Modal
To send the Modal you need to execute an interaction before and the Modal to send. The client is automatically assigned a property which will allow you to send the Modal
Following the previous example where a Modal was created, we would send the Modal as follows:
client.modal.send(interaction, modal)
To receive the Modal you can go to the section event Modal example
Documentation
Structures
Modal
Constructor
new Modal(data)
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
data | ModalOptions or Modal | true | { } | Modal to clone or raw Modal data |
Properties
.title
The title of this Modal
Return: ?string
.custom_id
A unique string that will be sent in the interaction when the Modal is sent
Return: ?string
.components
The components in this Modal
Return: ?Array<TextInput>
Methods
.setTitle(title)
Sets the title of this Modal
Parameter | Type | Description |
---|---|---|
title | string | The title of this Modal |
Return: Modal
.setCustomId(custom_id)
Sets the custom id for this Modal
Parameter | Type | Description |
---|---|---|
custom_id | string | A unique string that will be sent in the interaction when the Modal is sent |
Return: Modal
.addComponents(components)
Adds components to the Modal
Parameter | Type | Description |
---|---|---|
components | Array<TextInput> | The components to add |
Return: Modal
Text Input
Constructor
new TextInput(data)
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
data | TextInputOptions | true | { } | TextInput to clone or raw TextInput data |
Properties
.custom_id
A unique string that will be sent in the interaction when the Modal is sent and TextInput is rellenated
Return ?string
.label
The label for this component
Return: ?string
.style
The style of this TextInput
Return: ?TextInputStyles
.min_length
The minimum input length for a text input, min 0, max 4000
Return: ?number
.max_length
The maximum input length for a text input, min 1, max 4000
Return: ?number
.placeholder
Placeholder text in the input
Return: ?string
.required
Whether the TextInput is required
Return: ?boolean
Parameter | Type | Description |
---|---|---|
custom_id | string | A unique string that will be sent in the interaction when the Modal is sent and TextInput is rellenated |
Return: TextInput
.setLabel(label)
Sets the label of this TextInput
Parameter | Type | Description |
---|---|---|
label | string | The text to be displayed on this TextInput |
Return: TextInput
.setStyle(style)
Sets the style of this TextInput
Parameter | Type | Description |
---|---|---|
style | TextInputStyles | The style of this component |
Return: TextInput
.setMinLength(min_length)
The minimum input length for a text input, min 0, max 4000
Parameter | Type | Description |
---|---|---|
min_length | number | Number of characters to be required |
Return: TextInput
.setMaxLength(max_length)
The maximum input length for a text input, min 1, max 4000
Parameter | Type | Description |
---|---|---|
max_length | number | Number of characters to be allowed |
Return: TextInput
.setPlaceholder(placeholder)
Custom placeholder text if the input is empty, max 100 characters
Parameter | Type | Description |
---|---|---|
placeholder | string | Custom placeholder text |
Return: TextInput
.setRequired(required)
Custom placeholder text if the input is empty, max 100 characters
Parameter | Type | Description |
---|---|---|
required | boolean | Whether the option is required |
Events
This package emits an event when it detects a Modal. You will be shown how to interact with the event
Parameter | Type | Description |
---|---|---|
interaction | Interaction | The received Modal |
Types
Parameter | Type | Optional | Default | Description |
---|---|---|---|---|
title | string | true | none | The title of the popup modal |
custom_id | string | true | none | Identifier for the component, max 100 characters |
components | TextInputOptions | true | none | Between 1 and 5 (inclusive) components that make up the modal |
Name | Value | Description |
---|---|---|
Short | 1 | A single-line input |
Paragraph | 2 | A multi-line input |
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago