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.
- Note
- Please be aware that this feature is currently in a closed beta. There is no way to get access to this at present to test this or see buttons in your bot. When this is released, this functionality of the library will work as expected.
#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_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:154
@ ir_channel_message_with_source
Definition: slashcommand.h:141
Create message.
Definition: dispatcher.h:617
message * msg
Definition: dispatcher.h:623
std::string content
Definition: message.h:529
When the feature is functioning, the code below will produce buttons on the reply message like in the image below: