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("😄").
set_style(dpp::cos_danger).
set_id("myid")
)
)
);
}
});
});
bot.start(false);
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:221
@ ir_channel_message_with_source
respond to an interaction with a message
Definition: slashcommand.h:166
Create message.
Definition: dispatcher.h:682
message * msg
Definition: dispatcher.h:688
std::string content
Definition: message.h:853
When the feature is functioning, the code below will produce buttons on the reply message like in the image below: