From b9fb7c536ae6ab46f15c355176edbd5d25db6669 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 10 Sep 2020 23:57:36 -0400 Subject: fix edited/deleted being reset on channel change --- discord/store.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'discord/store.cpp') diff --git a/discord/store.cpp b/discord/store.cpp index 270f16c..fb0bec1 100644 --- a/discord/store.cpp +++ b/discord/store.cpp @@ -24,6 +24,13 @@ void Store::SetGuildMemberData(Snowflake guild_id, Snowflake user_id, const Guil m_members[guild_id][user_id] = data; } +User *Store::GetUser(Snowflake id) { + auto it = m_users.find(id); + if (it == m_users.end()) + return nullptr; + return &it->second; +} + const User *Store::GetUser(Snowflake id) const { auto it = m_users.find(id); if (it == m_users.end()) @@ -31,6 +38,13 @@ const User *Store::GetUser(Snowflake id) const { return &it->second; } +Channel *Store::GetChannel(Snowflake id) { + auto it = m_channels.find(id); + if (it == m_channels.end()) + return nullptr; + return &it->second; +} + const Channel *Store::GetChannel(Snowflake id) const { auto it = m_channels.find(id); if (it == m_channels.end()) @@ -38,6 +52,13 @@ const Channel *Store::GetChannel(Snowflake id) const { return &it->second; } +Guild *Store::GetGuild(Snowflake id) { + auto it = m_guilds.find(id); + if (it == m_guilds.end()) + return nullptr; + return &it->second; +} + const Guild *Store::GetGuild(Snowflake id) const { auto it = m_guilds.find(id); if (it == m_guilds.end()) @@ -45,6 +66,13 @@ const Guild *Store::GetGuild(Snowflake id) const { return &it->second; } +Role *Store::GetRole(Snowflake id) { + auto it = m_roles.find(id); + if (it == m_roles.end()) + return nullptr; + return &it->second; +} + const Role *Store::GetRole(Snowflake id) const { auto it = m_roles.find(id); if (it == m_roles.end()) @@ -52,6 +80,13 @@ const Role *Store::GetRole(Snowflake id) const { return &it->second; } +Message *Store::GetMessage(Snowflake id) { + auto it = m_messages.find(id); + if (it == m_messages.end()) + return nullptr; + return &it->second; +} + const Message *Store::GetMessage(Snowflake id) const { auto it = m_messages.find(id); if (it == m_messages.end()) @@ -59,6 +94,16 @@ const Message *Store::GetMessage(Snowflake id) const { return &it->second; } +GuildMember *Store::GetGuildMemberData(Snowflake guild_id, Snowflake user_id) { + auto git = m_members.find(guild_id); + if (git == m_members.end()) + return nullptr; + auto mit = git->second.find(user_id); + if (mit == git->second.end()) + return nullptr; + return &mit->second; +} + const GuildMember *Store::GetGuildMemberData(Snowflake guild_id, Snowflake user_id) const { auto git = m_members.find(guild_id); if (git == m_members.end()) -- cgit v1.2.3