Discord's newest features support sending buttons alongside messages, which when clicked by the user trigger an interaction which is routed by D++ as an on_button_click event. To make use of this, use code as in this example.
#include <dpp/dpp.h>
#include <iostream>
#include <dpp/message.h>
int main() {
bot.message_create(
dpp::message(event.msg.channel_id, "this text has buttons").add_component(
dpp::component().add_component(
dpp::component().set_label("Click me!").
set_type(dpp::cot_button).
set_emoji(u8"😄").
set_style(dpp::cos_danger).
set_id("myid")
)
)
);
}
});
event.reply(
"You clicked: " + event.
custom_id);
});
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:271
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
@ i_message_content
Intent for receipt of message content.
Definition: intents.h:64
@ i_default_intents
Default D++ intents (all non-privileged intents)
Definition: intents.h:72
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:254
Create message.
Definition: dispatcher.h:1354
message msg
message that was created (sent).
Definition: dispatcher.h:1363
std::string content
Definition: message.h:1115
When the feature is functioning, the code below will produce buttons on the reply message like in the image below: