mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-06 20:15:19 +03:00
handle merged_members in ready object
this way you dont have to load a channel to make the client aware of your permissions
This commit is contained in:
@@ -780,15 +780,27 @@ void DiscordClient::HandleGatewayReady(const GatewayMessage &msg) {
|
||||
ProcessNewGuild(g);
|
||||
|
||||
m_store.BeginTransaction();
|
||||
|
||||
for (const auto &dm : data.PrivateChannels) {
|
||||
m_store.SetChannel(dm.ID, dm);
|
||||
if (dm.Recipients.has_value())
|
||||
for (const auto &recipient : *dm.Recipients)
|
||||
m_store.SetUser(recipient.ID, recipient);
|
||||
}
|
||||
|
||||
if (data.Users.has_value())
|
||||
for (const auto &user : *data.Users)
|
||||
m_store.SetUser(user.ID, user);
|
||||
|
||||
if (data.MergedMembers.has_value()) {
|
||||
for (int i = 0; i < data.MergedMembers->size(); i++) {
|
||||
const auto guild_id = data.Guilds[i].ID;
|
||||
for (const auto &member : data.MergedMembers.value()[i]) {
|
||||
m_store.SetGuildMember(guild_id, *member.UserID, member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_store.EndTransaction();
|
||||
|
||||
m_session_id = data.SessionID;
|
||||
|
||||
@@ -9,6 +9,7 @@ void from_json(const nlohmann::json &j, GuildMember &m) {
|
||||
JS_ON("premium_since", m.PremiumSince);
|
||||
JS_D("deaf", m.IsDeafened);
|
||||
JS_D("mute", m.IsMuted);
|
||||
JS_O("user_id", m.UserID);
|
||||
}
|
||||
|
||||
std::vector<RoleData> GuildMember::GetSortedRoles() const {
|
||||
|
||||
@@ -14,6 +14,7 @@ struct GuildMember {
|
||||
std::optional<std::string> PremiumSince; // null
|
||||
bool IsDeafened;
|
||||
bool IsMuted;
|
||||
std::optional<Snowflake> UserID; // present in merged_members
|
||||
|
||||
std::vector<RoleData> GetSortedRoles() const;
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ void from_json(const nlohmann::json &j, ReadyEventData &m) {
|
||||
JS_D("user_settings", m.Settings);
|
||||
JS_D("private_channels", m.PrivateChannels);
|
||||
JS_O("users", m.Users);
|
||||
JS_ON("merged_members", m.MergedMembers);
|
||||
}
|
||||
|
||||
void to_json(nlohmann::json &j, const IdentifyProperties &m) {
|
||||
|
||||
@@ -170,6 +170,7 @@ struct ReadyEventData {
|
||||
std::optional<std::string> AnalyticsToken;
|
||||
std::optional<int> FriendSuggestionCount;
|
||||
UserSettings Settings;
|
||||
std::optional<std::vector<std::vector<GuildMember>>> MergedMembers;
|
||||
// std::vector<Unknown> ConnectedAccounts; // opt
|
||||
// std::map<std::string, Unknown> Consents; // opt
|
||||
// std::vector<Unknown> Experiments; // opt
|
||||
|
||||
Reference in New Issue
Block a user