-
Notifications
You must be signed in to change notification settings - Fork 5
Interaction
Represents a Discord Interaction allowing you to receive and respond to user interactions.
Note that on interactionCreate
event Discord sends partial Guild/Channel/Member objects,
that means, any object obtained with the Interaction may or may not have specific properties set.
Instances of this class should not be constructed by users.
Name | Type | Description |
---|---|---|
appPermissions | Permissions | The permissions the app has in the source location of the interaction. |
applicationId | string | The application's unique snowflake ID. |
channel | Channel/nil | The Channel object the interaction was sent from. Equivalent to Client:getChannel(Interaction.channelId) . Can be GuildTextChannel , GuildVoiceChannel or PrivateChannel . |
channelId | string | The Snowflake ID of the channel the interaction was sent from. Should always be provided, but keep in mind Discord flags it as optional for future-proofing. |
context | number/nil | The context in which this interaction was invoked, see enums.interactionContextType . |
data | table | The raw data of the interaction. See Interaction Data Structure. Should be always available but Discord may not provide it in the future for some scenarios. |
entitlements | table | An array of raw Entitlement objects for monetized apps the user that invoked this interaction has. |
guild | Guild/nil | The Guild object the interaction was sent from. Equivalent to Client:getGuild(Interaction.guildId) . |
guildId | string/nil | The Snowflake ID of the guild the interaction was sent from, if any. |
guildLocale | string | The guild's preferred locale, if the interaction was executed in a guild, see languages for list of possible values. |
integrationOwners | table | Mapping of installation contexts that the interaction was authorized for to related user or guild IDs. See Authorizing Integration Owners Object for details |
locale | string/nil | The locale settings of the user who executed this interaction, see languages for list of possible values. Always available except on PING interactions. |
member | Member/nil | The member who invoked this interaction, if it was invoked in the context of a guild. |
message | Message/nil | The message the components that invoked this interaction are attached to. Only provided for components-based interactions. |
token | string | The interaction token. This is a secret and shouldn't be exposed, if leaked anyone can send messages on behalf of your bot. |
type | number | The Interaction's type, see enums.interactionType . |
user | User/nil | The user that invoked this interaction, should be always available but always check. |
version | string | The interaction version, currently this is always set to 1 . |
Parameter | Type |
---|---|
choices | table |
Responds to an autocomplete interaction.
choices
is an array of tables with the fields name
and value
.
For example: {{name = "choice#1", value = "val1"}, {name = "choice#2", value = "val2"}}
.
See option choice structure for more information on how to set a locale.
Returns true
on success, otherwise false, err
.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type | Optional |
---|---|---|
id | Message-ID-Resolvable | ✔ |
Deletes a previously sent response. If response id
was not provided, original interaction response is deleted instead.
If id
was not provided, the initial interaction response is deleted instead.
Returns true
on success, otherwise false, err
.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type | Optional |
---|---|---|
content | table/string | |
id | Message-ID-Resolvable | ✔ |
Modifies a previously sent interaction response.
If id
was not provided, the initial interaction response is edited instead.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type | Optional |
---|---|---|
id | Message-ID-Resolvable | ✔ |
Fetches a previously sent interaction response.
If id
was not provided, the original interaction response is fetched instead.
This method always makes an HTTP request.
Returns: Message
Parameter | Type |
---|---|
modal | table |
Responds to an interaction by opening a Modal, also known as Text Inputs. By default this method takes the raw structure defined by Discord but other extensions may also provide their own abstraction, see for example discordia-modals.
Returns true
on success, otherwise false, err
.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type | Optional |
---|---|---|
content | string/table | |
isEphemeral | boolean | ✔ |
Sends an interaction reply. An initial response is sent on the first call, if an initial response has already been sent a followup message is sent instead. If the initial response was a deferred response, calling this will edit the deferred message.
Returns Message on success, otherwise nil, err
.
If Interaction.channel
was not available, true
will be returned instead of Message.
This method always makes an HTTP request.
Returns: Message/boolean
Parameter | Type | Optional |
---|---|---|
isEphemeral | boolean | ✔ |
Sends a deferred interaction reply.
Deferred replies can only be sent as initial responses.
A deferred reply displays "Bot is thinking..." to users, and once :reply
is called again, the deferred message will be edited.
Returns Message on success, otherwise nil, err
.
If Interaction.channel
was not available, true
will be returned instead of Message.
This method always makes an HTTP request.
Returns: Message/boolean
Parameter | Type |
---|---|
content | table/string |
Responds to a component-based interaction by editing the message that the component is attached to.
Returns true
on success, otherwise false, err
.
This method always makes an HTTP request.
Returns: boolean
Responds to a component-based interaction by acknowledging the interaction.
Once update
is called, the components message will be edited.
Returns true
on success, otherwise false, err
.
This method always makes an HTTP request.
Returns: boolean