Skip to content

Interaction

Interaction ⇐ Base

Represents an interaction with a user in a Discord server.

Kind: global class
Extends: Base

new Interaction(data, guildId, client)

Constructs a new instance of the Interaction class.

ParamTypeDescription
dataObjectThe data object containing information about the interaction.
guildIdstringThe ID of the guild where the interaction occurred.
clientClientThe client instance.

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

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

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

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

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

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

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

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

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

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

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

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

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) ⇒

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.

ParamTypeDescription
namestringThe name of the option to retrieve the value for.

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)>

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.

ParamTypeDescription
dataObjectThe data to send as the reply.

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.

ParamTypeDescription
optionsObjectThe options for creating the message payload.

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.

ParamTypeDescription
optionsObjectThe options for the modal form submission.

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>

Edits the reply message of a webhook interaction.

Kind: instance method of Interaction
Returns: Promise.<Message> - A promise that resolves with the edited message.

ParamTypeDescription
optionsObjectThe options for editing the reply message.

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:

  • Error If there was an error sending the follow-up message.
ParamTypeDescription
optionsobjectThe options for the follow-up message.