A bot status is pretty cool, and it'd be cooler if you knew how to do it! This tutorial will cover how to set the bot status to say Playing games!
, as well as covering how to set the status to the amount of guilds every two minutes.
First, we'll cover setting the bot status to Playing games!
.
#include <dpp/dpp.h>
int main()
{
});
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:82
Represents user presence, e.g. what game they are playing and if they are online.
Definition: presence.h:317
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
@ ps_online
Online.
Definition: presence.h:69
@ at_game
"Playing ..."
Definition: presence.h:104
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:65
Session ready.
Definition: dispatcher.h:898
If all went well, your bot should now be online and say this on members list!
Now, let's cover setting the bot status to say Playing with x guilds!
every two minutes.
#include <dpp/dpp.h>
int main()
{
if (dpp::run_once<struct register_bot_commands>()) {
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!"));
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!"));
}, 120);
}
});
return 0;
}
DPP_EXPORT cache< class guild > * get_guild_cache()
size_t timer
Represents a timer handle. Returned from cluster::start_timer and used by cluster::stop_timer....
Definition: timer.h:39
If you followed that well, your bot should now say this on members list!
If we then add our bot to another server and wait a bit, we'll see it updates like so: