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

Function main

docpages/example_code/thinking.cpp:3–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include <dpp/dpp.h>
2
3int 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([&bot](const dpp::slashcommand_t& event) {
10 /* Check which command they ran */
11 if (event.command.get_command_name() == "thinking") {
12 /*
13 * true for Ephemeral.
14 * You can set this to false if you want everyone to see the thinking response.
15 */
16 event.thinking(true, [event](const dpp::confirmation_callback_t& callback) {
17 event.edit_original_response(dpp::message("thonk"));
18 });
19
20 }
21 });
22
23 bot.on_ready([&bot](const dpp::ready_t& event) {
24 if (dpp::run_once<struct register_bot_commands>()) {
25 /* Create a new global command on ready event */
26 dpp::slashcommand newcommand("thinking", "Thinking example...", bot.me.id);
27
28 /* Register the command */
29 bot.global_command_create(newcommand);
30 }
31 });
32
33 bot.start(dpp::st_wait);
34
35 return 0;
36}

Callers

nothing calls this directly

Calls 7

cout_loggerFunction · 0.85
get_command_nameMethod · 0.80
global_command_createMethod · 0.80
startMethod · 0.80
messageClass · 0.50
thinkingMethod · 0.45

Tested by

no test coverage detected