Interaction
Interaction ⇐ Base
Section titled “Interaction ⇐ Base”Represents an interaction with a user in a Discord server.
Kind: global class
Extends: Base
- Interaction ⇐
Base- new Interaction(data, guildId, client)
- .guild ⇒
- .member ⇒
Member|null - .user ⇒
User|null - .isChatInput() ⇒
boolean - .isCommand() ⇒
boolean - .isUser() ⇒
boolean - .isMessage() ⇒
boolean - .isButton() ⇒
boolean - .isModal() ⇒
boolean - .isAutocomplete() ⇒
boolean - .isSelect() ⇒
boolean - .isContext() ⇒
boolean - .isDM() ⇒
boolean - .getValue(name) ⇒
- .fetchReply() ⇒
Promise.<Message> - .reply(data) ⇒
Promise.<(Message|null)> - .deferReply(options) ⇒
Promise - .modalSubmit(options) ⇒
Promise - .deleteReply() ⇒
Promise.<Message> - .editReply(options) ⇒
Promise.<Message> - .followUp(options) ⇒
Promise.<Message>
new Interaction(data, guildId, client)
Section titled “new Interaction(data, guildId, client)”Constructs a new instance of the Interaction class.
| Param | Type | Description |
|---|---|---|
| data | Object | The data object containing information about the interaction. |
| guildId | string | The ID of the guild where the interaction occurred. |
| client | Client | The client instance. |
interaction.guild ⇒
Section titled “interaction.guild ⇒”Retrieves the guild associated with this guildId.
Kind: instance property of Interaction
Returns: The guild object if found, otherwise null.
interaction.member ⇒ Member | null
Section titled “interaction.member ⇒ Member | null”Get the member associated with this instance.
Kind: instance property of Interaction
Returns: Member | null - The member object, or null if it is not available.
interaction.user ⇒ User | null
Section titled “interaction.user ⇒ User | null”Get the user associated with this instance.
Kind: instance property of Interaction
Returns: User | null - The user object, or null if it is not available.
interaction.isChatInput() ⇒ boolean
Section titled “interaction.isChatInput() ⇒ boolean”Checks if the command type is a chat input.
Kind: instance method of Interaction
Returns: boolean - - true if the command type is a chat input, false otherwise.
interaction.isCommand() ⇒ boolean
Section titled “interaction.isCommand() ⇒ boolean”Checks if the current object is a command.
Kind: instance method of Interaction
Returns: boolean - - true if the object is a command, false otherwise.
interaction.isUser() ⇒ boolean
Section titled “interaction.isUser() ⇒ boolean”Checks if the command type is “User” or 2.
Kind: instance method of Interaction
Returns: boolean - - true if the command type is “User” or 2, false otherwise.
interaction.isMessage() ⇒ boolean
Section titled “interaction.isMessage() ⇒ boolean”Checks if the command type is “Message” or 3.
Kind: instance method of Interaction
Returns: boolean - - true if the command type is “Message” or 3, false otherwise.
interaction.isButton() ⇒ boolean
Section titled “interaction.isButton() ⇒ boolean”Checks if the component type is a button.
Kind: instance method of Interaction
Returns: boolean - - true if the component type is a button, false otherwise.
interaction.isModal() ⇒ boolean
Section titled “interaction.isModal() ⇒ boolean”Checks if the current instance is a modal.
Kind: instance method of Interaction
Returns: boolean - - Returns true if the instance is a modal, false otherwise.
interaction.isAutocomplete() ⇒ boolean
Section titled “interaction.isAutocomplete() ⇒ boolean”Checks if the current object is an autocomplete.
Kind: instance method of Interaction
Returns: boolean - - True if the object is an autocomplete, false otherwise.
interaction.isSelect() ⇒ boolean
Section titled “interaction.isSelect() ⇒ boolean”Checks if the component type is a select menu.
Kind: instance method of Interaction
Returns: boolean - - true if the component type is a select menu, false otherwise.
interaction.isContext() ⇒ boolean
Section titled “interaction.isContext() ⇒ boolean”Checks if the current context is valid for the given command type.
Kind: instance method of Interaction
Returns: boolean - - true if the context is valid, false otherwise.
interaction.isDM() ⇒ boolean
Section titled “interaction.isDM() ⇒ boolean”Checks if the current channel is a direct message (DM) channel.
Kind: instance method of Interaction
Returns: boolean - - True if the channel is a DM channel, false otherwise.
interaction.getValue(name) ⇒
Section titled “interaction.getValue(name) ⇒”Retrieves the value associated with the given name from the options list.
Kind: instance method of Interaction
Returns: The value associated with the given name.
| Param | Type | Description |
|---|---|---|
| name | string | The name of the option to retrieve the value for. |
interaction.fetchReply() ⇒ Promise.<Message>
Section titled “interaction.fetchReply() ⇒ Promise.<Message>”Fetches the reply message from the Discord API using the provided webhook information.
Kind: instance method of Interaction
Returns: Promise.<Message> - A promise that resolves to the fetched reply message.
interaction.reply(data) ⇒ Promise.<(Message|null)>
Section titled “interaction.reply(data) ⇒ Promise.<(Message|null)>”Sends a reply to an interaction with the provided data.
Kind: instance method of Interaction
Returns: Promise.<(Message|null)> - - A promise that resolves to the sent message, or null if fetchReply is false.
| Param | Type | Description |
|---|---|---|
| data | Object | The data to send as the reply. |
interaction.deferReply(options) ⇒ Promise
Section titled “interaction.deferReply(options) ⇒ Promise”Sends a deferred reply to an interaction.
Kind: instance method of Interaction
Returns: Promise - A promise that resolves when the reply is sent.
| Param | Type | Description |
|---|---|---|
| options | Object | The options for creating the message payload. |
interaction.modalSubmit(options) ⇒ Promise
Section titled “interaction.modalSubmit(options) ⇒ Promise”Submits a modal form by sending a POST request to the specified endpoint.
Kind: instance method of Interaction
Returns: Promise - A promise that resolves when the form submission is complete.
| Param | Type | Description |
|---|---|---|
| options | Object | The options for the modal form submission. |
interaction.deleteReply() ⇒ Promise.<Message>
Section titled “interaction.deleteReply() ⇒ Promise.<Message>”Deletes the reply message associated with the current interaction.
Kind: instance method of Interaction
Returns: Promise.<Message> - A promise that resolves to the deleted message.
interaction.editReply(options) ⇒ Promise.<Message>
Section titled “interaction.editReply(options) ⇒ Promise.<Message>”Edits the reply message of a webhook interaction.
Kind: instance method of Interaction
Returns: Promise.<Message> - A promise that resolves with the edited message.
| Param | Type | Description |
|---|---|---|
| options | Object | The options for editing the reply message. |
interaction.followUp(options) ⇒ Promise.<Message>
Section titled “interaction.followUp(options) ⇒ Promise.<Message>”Sends a follow-up message using the provided options.
Kind: instance method of Interaction
Returns: Promise.<Message> - A promise that resolves to the sent message.
Throws:
ErrorIf there was an error sending the follow-up message.
| Param | Type | Description |
|---|---|---|
| options | object | The options for the follow-up message. |