| D++ (DPP) C++ Discord API Bot Library

Search
Loading...
Searching...
No Matches
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:
[legend]
Collaboration diagram for dpp::interaction_response:
[legend]

## Public Member Functions

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

## Public Attributes

std::vector< command_option_choice > | autocomplete_choices {}
| Array of up to 25 autocomplete choices.
message | msg {}
| Message tied to this response.
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.

## Protected Member Functions

virtual interaction_response & | fill_from_json_impl (nlohmann::json *j)
| Fill object properties from JSON.
virtual json | to_json_impl (bool with_id=false) const
| Build json for this object.

## 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

  t | Type 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

  t | Type of reply
  m | Message 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

  t | Type of reply
  m | Message to reply with

## ◆ ~interaction_response()

virtual dpp::interaction_response::~interaction_response | ( |  | ) |

virtual default

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

  achoice | command 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

inline inherited

Convert object to json string.

Parameters

  with_id | Whether 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 | ) |

inline inherited

Convert object from nlohmann::json.

Parameters

  j | nlohmann::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 | ) |

protected virtual

Fill object properties from JSON.

Parameters

  j | JSON 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

inline inherited

Convert object to nlohmann::json.

Parameters

  with_id | Whether 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

protected virtual

Build json for this object.

Returns
  json JSON object

Reimplemented in dpp::interaction_modal_response.

## Friends And Related Symbol 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 9.0.13 D++ Library version 9.0.12 D++ Library version 9.0.11 D++ Library version 9.0.10 D++ Library version 9.0.9 D++ Library version 9.0.8 D++ Library version 9.0.7 D++ Library version 9.0.6 D++ Library version 9.0.5 D++ Library version 9.0.4 D++ Library version 9.0.3 D++ Library version 9.0.2 D++ Library version 9.0.1 D++ Library version 9.0.0 D++ Library version 1.0.2 D++ Library version 1.0.1 D++ Library version 1.0.0