store READY user data into client

This commit is contained in:
ouwou 2020-08-30 02:00:14 -04:00
parent af4f659aaa
commit facb89012a
2 changed files with 9 additions and 0 deletions

View File

@ -51,6 +51,12 @@ const UserSettingsData &DiscordClient::GetUserSettings() const {
return m_user_settings;
}
const UserData &DiscordClient::GetUserData() const {
std::scoped_lock<std::mutex> guard(m_mutex);
assert(m_ready_received);
return m_user_data;
}
std::vector<std::pair<Snowflake, GuildData>> DiscordClient::GetUserSortedGuilds() const {
std::vector<std::pair<Snowflake, GuildData>> sorted_guilds;
@ -283,6 +289,7 @@ void DiscordClient::HandleGatewayReady(const GatewayMessage &msg) {
}
m_abaddon->DiscordNotifyReady();
m_user_data = data.User;
m_user_settings = data.UserSettings;
}

View File

@ -62,6 +62,7 @@ public:
using Messages_t = std::unordered_map<Snowflake, MessageData>;
const Guilds_t &GetGuilds() const;
const UserData &GetUserData() const;
const UserSettingsData &GetUserSettings() const;
std::vector<std::pair<Snowflake, GuildData>> GetUserSortedGuilds() const;
std::unordered_set<const MessageData *> GetMessagesForChannel(Snowflake id) const;
@ -110,6 +111,7 @@ private:
void StoreChannel(Snowflake id, const ChannelData &c);
Channels_t m_channels;
UserData m_user_data;
UserSettingsData m_user_settings;
Websocket m_websocket;