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:384
@ ir_channel_message_with_source
respond to an interaction with a message
Definition: slashcommand.h:218
Create message.
Definition: dispatcher.h:1156
message msg
message that was created (sent).
Definition: dispatcher.h:1165
std::string content
Definition: message.h:1020
When the feature is functioning, the code below will produce buttons on the reply message like in the image below: