MCPcopy Create free account
hub / github.com/brainboxdotcc/DPP / main

Function main

docpages/example_code/context_menus.cpp:4–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include <iostream>
3
4int 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}

Callers

nothing calls this directly

Calls 7

cout_loggerFunction · 0.85
get_command_nameMethod · 0.80
get_userMethod · 0.80
guild_command_createMethod · 0.80
startMethod · 0.80
replyMethod · 0.45
get_mentionMethod · 0.45

Tested by

no test coverage detected