DiscordInteraction¶
Extends: None
Represents a Discord interaction.
Description¶
Provides methods for replying, updating and follow up to interactions.
Properties¶
Type | Name | Description |
---|---|---|
String | application_id | The application's id |
String | channel_id | The id of the channel this interaction was sent in |
String | guild_id | The id of the guild this interaction was sent in |
String | id | The interaction's id |
Dictionary | member | If this interaction was sent in a guild, the member which sent it |
Message | message | For components, the message they were attached to |
String | token | The interaction's token |
String | type | The interaction's type |
Dictionary | data | Additional data of this interaction |
Methods¶
Returns | Definition |
---|---|
Variant | defer_reply(options: Dictionary) |
Variant | defer_update(options: Dictionary) |
Variant | delete_follow_up(message: Message) |
Variant | delete_reply() |
Variant | edit_follow_up(message: Message, options: Dictionary) |
Variant | edit_reply(options: Dictionary) |
Message | fetch_reply() |
Variant | follow_up(options: Dictionary) |
bool | in_guild() |
bool | is_button() |
bool | is_message_component() |
bool | is_select_menu() |
bool | is_command() |
bool | is_autocomplete() |
bool | respond_autocomplete(choices: Array) |
Variant | reply(options: Dictionary) |
Variant | update(options: Dictionary) |
Method Descriptions¶
is_message_component()¶
Indicates whether this interaction is a message component.
Returns: bool
is_button()¶
Indicates whether this interaction is a button interaction.
Returns: bool
is_select_menu()¶
Indicates whether this interaction is a select menu interaction.
Returns: bool
is_command()¶
Indicates whether this interaction is an application command interaction.
Returns: bool
is_autocomplete()¶
Indicates whether this interaction is an application command autocomplete interaction.
Returns: bool
respond_autocomplete(choices)¶
Responds to an autocomplete interaction with suggested choices.
Returns: bool Returns
true
if successful otherwisefalse
.
See Discord responding to autocomplete
Type | Parameter | Description |
---|---|---|
Array | choices | The array of choices |
Examples¶
Always respond with two choices
# In DiscordBot.interaction_create
if interaction.is_autocomplete():
var data = interaction.data
print("Autocomplete data: ", data)
# In a real situation you would send different choices based on the current input of the user,
# which can be found in interaction.data
interaction.respond_autocomplete([
ApplicationCommand.choice("Name of the choice 1", "value1"),
ApplicationCommand.choice("Name of the choice 2", "value2"),
])
return
in_guild()¶
Indicates whether this interaction is received from a guild.
Returns: bool
fetch_reply()¶
Fetches the initial reply to this interaction.
Returns: Promise
reply(options)¶
Creates a reply to this interaction.
Returns: Variant
Type | Parameter | Description |
---|---|---|
Dictionary | options | The options for the new reply |
Note
Here the options means the message options. Like embeds, components, content, files, etc. The two new keys are fetch_reply
and ephemeral
.
If fetch_reply
is true, the function will return a Promsise<Message> otherwise the function will return true
.
options: Dictionary
{
fetch_reply: bool, whether to return the new reply or not,
ephemeral: bool, whether the reply should be ephemeral or not,
files: Array, the files to attach to the new reply,
embeds: Array, the embeds to attach to the new reply,
content: String, the content of the new reply,
components: Array, the components to attach to the new reply
}
edit_reply(options)¶
Edits the initial reply to this interaction.
Returns: Variant
Note
options is same as DiscordInteraction.reply()
options.
delete_reply()¶
Deletes the initial reply to this interaction.
Returns: void
defer_reply(options)¶
Defers the reply to this interaction.
Returns: Variant
Note
options is same as DiscordInteraction.reply()
options.
Examples¶
Defer to send an ephemeral reply later
yield(interaction.defer_reply({"ephemeral": true}), "completed")
update(options)¶
Updates the original message of the component on which the interaction was received on.
Returns: Variant
Note
options is same as DiscordInteraction.reply()
options.
Examples¶
Remove the components from the message
yield(interaction.update({
"components": [],
"content": "Components are removed"
}), "completed")
follow_up(options)¶
Send a follow-up message to this interaction.
Returns: Variant
Note
options is same as DiscordInteraction.reply()
options.
edit_follow_up(message, options)¶
Edits a follow-up message to this interaction.
Returns: Variant
Note
options is same as DiscordInteraction.reply()
options.
Type | Parameter | Description |
---|---|---|
[[Message]] | message | The sent follow up message to edit |
Dictionary | options | Additional options same as DiscordInteraction.reply() options |
delete_follow_up(message)¶
Deletes a follow-up message to this interaction.
Returns: Variant
Type | Parameter | Description |
---|---|---|
Message | message | The sent follow up message to delete |
Examples¶
Delete a sent follow up
# inside interaction_create signal
# Send a follow up
var msg = yield(interaction.follow_up({"content": "This will be deleted soon"}), "completed")
# Wait 5s
yield(get_tree().create_timer(5), "timeout")
# Delete the follow up
interaction.delete_follow_up(msg)