![]() |
D++ (DPP)
C++ Discord API Bot Library
|
An interaction represents a user running a command and arrives via the dpp::cluster::on_interaction_create event. This is further split into the events on_form_submit, on_slashcommand, on_user_context_menu, on_button_click, on_select_menu, etc. More...
#include <appcommand.h>
Public Member Functions | |
interaction () | |
Construct a new interaction object. More... | |
virtual | ~interaction ()=default |
Destroy the interaction object. More... | |
std::string | build_json (bool with_id=false) const |
Build a json string for this object. More... | |
interaction & | fill_from_json (nlohmann::json *j) |
Fill object properties from JSON. More... | |
autocomplete_interaction | get_autocomplete_interaction () const |
Get the autocomplete interaction object. More... | |
const dpp::channel & | get_channel () const |
Get the channel this command originated on. More... | |
command_interaction | get_command_interaction () const |
Get the command interaction object. More... | |
std::string | get_command_name () const |
Get the command name for a command interaction. More... | |
component_interaction | get_component_interaction () const |
Get the component interaction object. More... | |
const dpp::message & | get_context_message () const |
Get the message this action refers to if it is a context menu command. More... | |
double | get_creation_time () const |
Get the creation time of this object according to Discord. More... | |
const dpp::guild & | get_guild () const |
Get the guild this command originated on. More... | |
const dpp::user & | get_issuing_user () const |
Get the user who issued this command. More... | |
const dpp::attachment & | get_resolved_attachment (snowflake id) const |
Get an uploaded attachment associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls. More... | |
const dpp::channel & | get_resolved_channel (snowflake id) const |
Get a channel associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls. More... | |
const dpp::guild_member & | get_resolved_member (snowflake id) const |
Get a guild member associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls. More... | |
const dpp::message & | get_resolved_message (snowflake id) const |
Get a message associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls. More... | |
const dpp::permission & | get_resolved_permission (snowflake id) const |
Get a permission associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls. More... | |
const dpp::role & | get_resolved_role (snowflake id) const |
Get a role associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls. More... | |
const dpp::user & | get_resolved_user (snowflake id) const |
Get a user associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls. More... | |
bool | operator!= (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
bool | operator== (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
Public Attributes | |
permission | app_permissions |
Permissions of the bot in the channel/guild where this command was issued. More... | |
snowflake | application_id |
id of the application this interaction is for More... | |
cache_policy_t | cache_policy |
Cache policy from cluster. More... | |
snowflake | channel_id |
Optional: the channel it was sent from. More... | |
std::variant< command_interaction, component_interaction, autocomplete_interaction > | data |
Optional: the command data payload. More... | |
snowflake | guild_id |
Optional: the guild it was sent from. More... | |
std::string | guild_locale |
Guild's locale (language) - for guild interactions only. More... | |
snowflake | id |
Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID, and an incrementing value. Only the timestamp is relevant to us as useful metadata. More... | |
std::string | locale |
User's locale (language) More... | |
guild_member | member |
Optional: guild member data for the invoking user, including permissions. More... | |
snowflake | message_id |
Originating message id for context menu actions. More... | |
message | msg |
Originating message for context menu actions. More... | |
command_resolved | resolved |
Resolved user/role etc. More... | |
std::string | token |
a continuation token for responding to the interaction More... | |
uint8_t | type |
the type of interaction (dpp::interaction_type) More... | |
user | usr |
User object for the invoking user. More... | |
uint8_t | version |
read-only property, always 1 More... | |
An interaction represents a user running a command and arrives via the dpp::cluster::on_interaction_create event. This is further split into the events on_form_submit, on_slashcommand, on_user_context_menu, on_button_click, on_select_menu, etc.
dpp::interaction::interaction | ( | ) |
Construct a new interaction object.
|
virtualdefault |
Destroy the interaction object.
|
virtual |
Build a json string for this object.
with_id | True if to include the ID in the JSON |
Reimplemented from dpp::json_interface< interaction >.
interaction & dpp::interaction::fill_from_json | ( | nlohmann::json * | j | ) |
Fill object properties from JSON.
j | JSON to fill from |
autocomplete_interaction dpp::interaction::get_autocomplete_interaction | ( | ) | const |
Get the autocomplete interaction object.
dpp::logic_exception | if the interaction is not for an autocomplete |
const dpp::channel & dpp::interaction::get_channel | ( | ) | const |
Get the channel this command originated on.
dpp::logic_error | Command originated from a DM or channel not in cache |
command_interaction dpp::interaction::get_command_interaction | ( | ) | const |
Get the command interaction object.
dpp::logic_exception | if the interaction is not for a command |
std::string dpp::interaction::get_command_name | ( | ) | const |
Get the command name for a command interaction.
component_interaction dpp::interaction::get_component_interaction | ( | ) | const |
Get the component interaction object.
dpp::logic_exception | if the interaction is not for a component |
const dpp::message & dpp::interaction::get_context_message | ( | ) | const |
Get the message this action refers to if it is a context menu command.
|
inherited |
Get the creation time of this object according to Discord.
const dpp::guild & dpp::interaction::get_guild | ( | ) | const |
Get the guild this command originated on.
dpp::logic_error | Command originated from a DM or guild not in cache |
const dpp::user & dpp::interaction::get_issuing_user | ( | ) | const |
Get the user who issued this command.
const dpp::attachment & dpp::interaction::get_resolved_attachment | ( | snowflake | id | ) | const |
Get an uploaded attachment associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls.
id | Attachment snowflake ID to find |
dpp::logic_exception | on object not found in resolved set |
const dpp::channel & dpp::interaction::get_resolved_channel | ( | snowflake | id | ) | const |
Get a channel associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls.
id | Channel snowflake ID to find |
dpp::logic_exception | on object not found in resolved set |
const dpp::guild_member & dpp::interaction::get_resolved_member | ( | snowflake | id | ) | const |
Get a guild member associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls.
id | User snowflake ID to find |
dpp::logic_exception | on object not found in resolved set |
const dpp::message & dpp::interaction::get_resolved_message | ( | snowflake | id | ) | const |
Get a message associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls.
id | Message snowflake ID to find |
dpp::logic_exception | on object not found in resolved set |
const dpp::permission & dpp::interaction::get_resolved_permission | ( | snowflake | id | ) | const |
Get a permission associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls.
id | User snowflake ID to find |
dpp::logic_exception | on object not found in resolved set |
Get a role associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls.
id | Role snowflake ID to find |
dpp::logic_exception | on object not found in resolved set |
Get a user associated with the slash command from the resolved list. The resolved list contains associated structures for this command and does not use the cache or require any extra API calls.
id | User snowflake ID to find |
dpp::logic_exception | on object not found in resolved set |
|
noexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
|
noexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
permission dpp::interaction::app_permissions |
Permissions of the bot in the channel/guild where this command was issued.
snowflake dpp::interaction::application_id |
id of the application this interaction is for
cache_policy_t dpp::interaction::cache_policy |
Cache policy from cluster.
snowflake dpp::interaction::channel_id |
Optional: the channel it was sent from.
std::variant<command_interaction, component_interaction, autocomplete_interaction> dpp::interaction::data |
Optional: the command data payload.
snowflake dpp::interaction::guild_id |
Optional: the guild it was sent from.
std::string dpp::interaction::guild_locale |
Guild's locale (language) - for guild interactions only.
|
inherited |
Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID, and an incrementing value. Only the timestamp is relevant to us as useful metadata.
std::string dpp::interaction::locale |
User's locale (language)
guild_member dpp::interaction::member |
Optional: guild member data for the invoking user, including permissions.
snowflake dpp::interaction::message_id |
Originating message id for context menu actions.
message dpp::interaction::msg |
Originating message for context menu actions.
command_resolved dpp::interaction::resolved |
Resolved user/role etc.
std::string dpp::interaction::token |
a continuation token for responding to the interaction
uint8_t dpp::interaction::type |
the type of interaction (dpp::interaction_type)
user dpp::interaction::usr |
User object for the invoking user.
uint8_t dpp::interaction::version |
read-only property, always 1