Skip to content

Commit

Permalink
docs: made changes from comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskowicz1 committed Dec 8, 2023
1 parent f653176 commit 7708958
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 1 addition & 9 deletions docpages/example_code/setting_status2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ int main() {

/* Create a timer that runs every 120 seconds, that sets the status */
bot.start_timer([&bot](const dpp::timer& timer) {
/*
* Because we need to get an up-to-date count, we can't use what was provided in the ready event.
* So, we get the application from the bot and get the approximate guild count from there.
*/
bot.current_application_get([&bot](const dpp::confirmation_callback_t& callback) {
auto app = callback.get<dpp::application>();

bot.set_presence(dpp::presence(dpp::presence_status::ps_online, dpp::activity_type::at_game, "with " + std::to_string(app.approximate_guild_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);
}
});
Expand Down
2 changes: 2 additions & 0 deletions docpages/example_programs/misc/setting_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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.

\note dpp::get_guild_cache requires the bot to have the guild cache enabled, if your bot has this disabled then you can't use that. Instead, you should look to use dpp::cluster::current_application_get and get the `approximate_guild_count` from dpp::application in the callback.

First, we'll cover setting the bot status to `Playing games!`.

\include{cpp} setting_status1.cpp
Expand Down

0 comments on commit 7708958

Please sign in to comment.