Debian Codegraph @

docpages/example_code/using_cache.cpp

raw symbols SCIP
1 #include <dpp/dpp.h>
2
3 int main() {
4 /* Create bot */
5 dpp::cluster bot("token", dpp::i_default_intents | dpp::i_guild_members);
6
7 bot.on_log(dpp::utility::cout_logger());
8
9 /* This event is fired when someone removes their reaction from a message */
10 bot.on_message_reaction_remove([&bot](const dpp::message_reaction_remove_t& event) {
11 /* Find the user in the cache using his discord id */
12 dpp::user* reacting_user = dpp::find_user(event.reacting_user_id);
13
14 /* If user not found in cache, log and return */
15 if (!reacting_user) {
16 bot.log(dpp::ll_info, "User with the id " + std::to_string(event.reacting_user_id) + " was not found.");
17 return;
18 }
19
20 bot.log(dpp::ll_info, reacting_user->format_username() + " removed his reaction.");
21 });
22
23 bot.start(dpp::st_wait);
24
25 return 0;
26 }