Debian Codegraph @

docpages/example_code/components3_rolemenu.cpp

raw symbols SCIP
1 #include <dpp/dpp.h>
2
3 int main() {
4 dpp::cluster bot("token");
5
6 bot.on_log(dpp::utility::cout_logger());
7
8 /* The event is fired when someone issues your commands */
9 bot.on_slashcommand([](const dpp::slashcommand_t& event) {
10 /* Check which command they ran */
11 if (event.command.get_command_name() == "select") {
12 /* Create a message */
13 dpp::message msg(event.command.channel_id, "This text has a select menu!");
14
15 /* Add an action row, and a select menu within the action row.
16 *
17 * By default, max values is 1, meaning people can only pick 1 option.
18 * We're changing this to two, so people can select multiple options!
19 * We'll also set the min_values to 2 so people have to pick another value!
20 */
21 msg.add_component(
22 dpp::component().add_component(
23 dpp::component()
24 .set_type(dpp::cot_role_selectmenu)
25 .set_min_values(2)
26 .set_max_values(2)
27 .set_id("myselectid")
28 )
29 );
30
31 /* Reply to the user with our message. */
32 event.reply(msg);
33 }
34 });
35
36 bot.on_ready([&bot](const dpp::ready_t& event) {
37 if (dpp::run_once<struct register_bot_commands>()) {
38 /* Create and register a command when the bot is ready */
39 bot.global_command_create(dpp::slashcommand("select", "Select something at random!", bot.me.id));
40 }
41 });
42
43 bot.start(dpp::st_wait);
44
45 return 0;
46 }