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

Function main

docpages/example_code/setting_status2.cpp:3–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include <dpp/dpp.h>
2
3int 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}

Callers

nothing calls this directly

Calls 6

cout_loggerFunction · 0.85
to_stringFunction · 0.85
set_presenceMethod · 0.80
start_timerMethod · 0.80
countMethod · 0.80
startMethod · 0.80

Tested by

no test coverage detected