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")
)
)
);
}
});
});
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:236
@ ir_channel_message_with_source
respond to an interaction with a message
Definition: slashcommand.h:219
Create message.
Definition: dispatcher.h:1013
message * msg
message that was created (sent). If you use any parts of this in another thread, take a copy!...
Definition: dispatcher.h:1023
std::string content
Definition: message.h:971
When the feature is functioning, the code below will produce buttons on the reply message like in the image below: