Debian Codegraph @

docpages/example_code/context_menus.cpp

raw symbols SCIP
1 #include <dpp/dpp.h>
2 #include <iostream>
3
4 int main()
5 {
6 dpp::cluster bot("token");
7
8 bot.on_log(dpp::utility::cout_logger());
9
10 /* Use the on_user_context_menu event to look for user context menu actions */
11 bot.on_user_context_menu([](const dpp::user_context_menu_t& event) {
12
13 /* check if the context menu name is High Five */
14 if (event.command.get_command_name() == "high five") {
15 dpp::user user = event.get_user(); // the user who the command has been issued on
16 dpp::user author = event.command.get_issuing_user(); // the user who clicked on the context menu
17 event.reply(author.get_mention() + " slapped " + user.get_mention());
18 }
19 });
20
21 bot.on_ready([&bot](const dpp::ready_t& event) {
22 if (dpp::run_once<struct register_bot_commands>()) {
23 /* Create the command */
24 dpp::slashcommand command;
25 command.set_name("High Five")
26 .set_application_id(bot.me.id)
27 .set_type(dpp::ctxm_user);
28
29 /* Register the command */
30 bot.guild_command_create(command, 857692897221033129); /* Replace this with the guild id you want */
31 }
32 });
33
34 /* Start bot */
35 bot.start(dpp::st_wait);
36
37 return 0;
38 }