D++ (DPP)  10.0.30
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...
 
virtual ~interaction_response ()=default
 Destroy the interaction response object. More...
 
interaction_responseadd_autocomplete_choice (const command_option_choice &achoice)
 Add a command option choice. More...
 
std::string build_json (bool with_id=false) const
 Convert object to json string. 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...
 

Public Attributes

std::vector< command_option_choiceautocomplete_choices {}
 Array of up to 25 autocomplete choices. More...
 
message msg {}
 Message tied to this response. More...
 
interaction_response_type type {}
 Response type from dpp::interaction_response_type. 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

References dpp::json_interface< T >::fill_from_json().

Here is the call graph for this function:

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

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

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.


The documentation for this struct was generated from the following files: