Skip to content

Commit

Permalink
feat: added guilds array and count to ready_t (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskowicz1 authored Dec 7, 2023
1 parent 7408958 commit 6a821cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/dpp/dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,16 @@ struct DPP_EXPORT ready_t : public event_dispatch_t {
* @brief shard id
*/
uint32_t shard_id = {};

/**
* @brief Array of guild IDs the bot is in, at the time of this event.
*/
std::vector<snowflake> guilds{};

/**
* @brief The number of guilds the bot is in, at the time of this event.
*/
uint32_t guild_count{0};
};

/**
Expand Down
4 changes: 4 additions & 0 deletions src/dpp/events/ready.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ void ready::handle(discord_client* client, json &j, const std::string &raw) {
dpp::ready_t r(client, raw);
r.session_id = client->sessionid;
r.shard_id = client->shard_id;
for (const auto& guild : j["d"]["guilds"]) {
r.guilds.emplace_back(snowflake_not_null(&guild, "id"));
}
r.guild_count = r.guilds.size();
client->creator->on_ready.call(r);
}
}
Expand Down

0 comments on commit 6a821cb

Please sign in to comment.