Skip to content

Commit

Permalink
store stage instances on connect
Browse files Browse the repository at this point in the history
  • Loading branch information
ouwou committed Apr 16, 2024
1 parent 02fd49b commit 870f050
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/discord/discord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,13 @@ void DiscordClient::ProcessNewGuild(GuildData &guild) {
return;
}

if (guild.StageInstances.has_value()) {
for (const auto &stage : *guild.StageInstances) {
m_stage_instances[stage.ID] = stage;
m_channel_to_stage_instance[stage.ChannelID] = stage.ID;
}
}

m_store.BeginTransaction();

m_store.SetGuild(guild.ID, guild);
Expand Down
1 change: 1 addition & 0 deletions src/discord/guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void from_json(const nlohmann::json &j, GuildData &m) {
JS_O("preferred_locale", m.PreferredLocale);
JS_ON("public_updates_channel_id", m.PublicUpdatesChannelID);
JS_O("max_video_channel_users", m.MaxVideoChannelUsers);
JS_ON("stage_instances", m.StageInstances);
JS_O("approximate_member_count", tmp);
if (tmp.has_value())
m.ApproximateMemberCount = std::stol(*tmp);
Expand Down
2 changes: 2 additions & 0 deletions src/discord/guild.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "role.hpp"
#include "channel.hpp"
#include "emoji.hpp"
#include "stage.hpp"
#include <vector>
#include <string>
#include <unordered_set>
Expand Down Expand Up @@ -90,6 +91,7 @@ struct GuildData {
std::optional<int> ApproximateMemberCount;
std::optional<int> ApproximatePresenceCount;
std::optional<std::vector<ChannelData>> Threads; // only with permissions to view, id only
std::optional<std::vector<StageInstance>> StageInstances;

// undocumented
// std::map<std::string, Unknown> GuildHashes;
Expand Down

0 comments on commit 870f050

Please sign in to comment.