D++ (DPP)
C++ Discord API Bot Library
dpp::interaction_response Struct Reference

A response to an interaction, used to reply to a command and initiate a message, which can be hidden from others (ephemeral) or visible to all. More...

#include <appcommand.h>

+ Inheritance diagram for dpp::interaction_response:
+ Collaboration diagram for dpp::interaction_response:

Public Member Functions

 interaction_response ()=default
 Construct a new interaction response object. More...
 
 interaction_response (interaction_response_type t)
 Construct a new interaction response object. More...
 
 interaction_response (interaction_response_type t, const message &m)
 Construct a new interaction response object. More...
 
 interaction_response (interaction_response_type t, message &&m)
 Construct a new interaction response object. More...
 
interaction_responseadd_autocomplete_choice (const command_option_choice &achoice)
 Add a command option choice. More...
 
virtual ~interaction_response ()=default
 Destroy the interaction response object. More...
 
interaction_responsefill_from_json (nlohmann::json *j)
 Convert object from nlohmann::json. More...
 
auto to_json (bool with_id=false) const
 Convert object to nlohmann::json. More...
 
std::string build_json (bool with_id=false) const
 Convert object to json string. More...
 

Public Attributes

interaction_response_type type {}
 Response type from dpp::interaction_response_type. Should be one of ir_pong, ir_channel_message_with_source, or ir_deferred_channel_message_with_source. More...
 
message msg {}
 Message tied to this response. More...
 
std::vector< command_option_choiceautocomplete_choices {}
 Array of up to 25 autocomplete choices. More...
 

Protected Member Functions

virtual interaction_responsefill_from_json_impl (nlohmann::json *j)
 Fill object properties from JSON. More...
 
virtual json to_json_impl (bool with_id=false) const
 Build json for this object. More...
 

Friends

struct json_interface< interaction_response >
 

Detailed Description

A response to an interaction, used to reply to a command and initiate a message, which can be hidden from others (ephemeral) or visible to all.

The dpp::interaction_response object wraps a dpp::message object. To set the message as 'ephemeral' (e.g. only the command issuer can see it) you should add the dpp::m_ephemeral flag to the dpp::message::flags field. e.g.:

mymessage.flags |= dpp::m_ephemeral;

Constructor & Destructor Documentation

◆ interaction_response() [1/4]

dpp::interaction_response::interaction_response ( )
default

Construct a new interaction response object.

◆ interaction_response() [2/4]

dpp::interaction_response::interaction_response ( interaction_response_type  t)

Construct a new interaction response object.

Parameters
tType of reply

◆ interaction_response() [3/4]

dpp::interaction_response::interaction_response ( interaction_response_type  t,
const message m 
)

Construct a new interaction response object.

Parameters
tType of reply
mMessage to reply with

◆ interaction_response() [4/4]

dpp::interaction_response::interaction_response ( interaction_response_type  t,
message &&  m 
)

Construct a new interaction response object.

Parameters
tType of reply
mMessage to reply with

◆ ~interaction_response()

virtual dpp::interaction_response::~interaction_response ( )
virtualdefault

Destroy the interaction response object.

Member Function Documentation

◆ add_autocomplete_choice()

interaction_response & dpp::interaction_response::add_autocomplete_choice ( const command_option_choice achoice)

Add a command option choice.

Parameters
achoicecommand option choice to add
Returns
interaction_response& Reference to self

◆ build_json()

std::string dpp::json_interface< interaction_response >::build_json ( bool  with_id = false) const
inlineinherited

Convert object to json string.

Parameters
with_idWhether to include the ID or not
Note
Some fields are conditionally filled, do not rely on all fields being present
Returns
std::string Json built from the structure

◆ fill_from_json()

interaction_response & dpp::json_interface< interaction_response >::fill_from_json ( nlohmann::json *  j)
inlineinherited

Convert object from nlohmann::json.

Parameters
jnlohmann::json object
Returns
T& Reference to self for fluent calling

◆ fill_from_json_impl()

virtual interaction_response & dpp::interaction_response::fill_from_json_impl ( nlohmann::json *  j)
protectedvirtual

Fill object properties from JSON.

Parameters
jJSON to fill from
Returns
interaction_response& Reference to self

Reimplemented in dpp::interaction_modal_response.

◆ to_json()

auto dpp::json_interface< interaction_response >::to_json ( bool  with_id = false) const
inlineinherited

Convert object to nlohmann::json.

Parameters
with_idWhether to include the ID or not
Note
Some fields are conditionally filled, do not rely on all fields being present
Returns
json Json built from the structure

◆ to_json_impl()

virtual json dpp::interaction_response::to_json_impl ( bool  with_id = false) const
protectedvirtual

Build json for this object.

Returns
json JSON object

Reimplemented in dpp::interaction_modal_response.

Friends And Related Function Documentation

◆ json_interface< interaction_response >

friend struct json_interface< interaction_response >
friend

Member Data Documentation

◆ autocomplete_choices

std::vector<command_option_choice> dpp::interaction_response::autocomplete_choices {}

Array of up to 25 autocomplete choices.

◆ msg

message dpp::interaction_response::msg {}

Message tied to this response.

◆ type

interaction_response_type dpp::interaction_response::type {}

Response type from dpp::interaction_response_type. Should be one of ir_pong, ir_channel_message_with_source, or ir_deferred_channel_message_with_source.

D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0