Debian Codegraph @

docpages/example_code/setting_status2.cpp

raw symbols SCIP
1 #include <dpp/dpp.h>
2
3 int main() {
4 /* Create the bot */
5 dpp::cluster bot("token");
6
7 bot.on_log(dpp::utility::cout_logger());
8
9 bot.on_ready([&bot](const dpp::ready_t& event) {
10 /* We put our status updating inside "run_once" so that multiple shards don't try do this as "set_presence" updates all the shards. */
11 if (dpp::run_once<struct register_bot_commands>()) {
12 /* We update the presence now as the timer will do the first execution after the x amount of seconds we specify */
13 bot.set_presence(dpp::presence(dpp::presence_status::ps_online, dpp::activity_type::at_game, "with " + std::to_string(event.guild_count) + " guilds!"));
14
15 /* Create a timer that runs every 120 seconds, that sets the status */
16 bot.start_timer([&bot](const dpp::timer& timer) {
17 bot.set_presence(dpp::presence(dpp::presence_status::ps_online, dpp::activity_type::at_game, "with " + std::to_string(dpp::get_guild_cache()->count()) + " guilds!"));
18 }, 120);
19 }
20 });
21
22 bot.start(dpp::st_wait);
23
24 return 0;
25 }