From 22578921b9e577c669cd57385df48cfc08fa90eb Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 14 Dec 2020 03:05:16 -0500 Subject: pretend to be a real client a little better --- discord/channel.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'discord/channel.cpp') diff --git a/discord/channel.cpp b/discord/channel.cpp index ca0f06a..7a62953 100644 --- a/discord/channel.cpp +++ b/discord/channel.cpp @@ -15,6 +15,7 @@ void from_json(const nlohmann::json &j, Channel &m) { JS_O("user_limit", m.UserLimit); JS_O("rate_limit_per_user", m.RateLimitPerUser); JS_O("recipients", m.Recipients); + JS_O("recipient_ids", m.RecipientIDs); JS_ON("icon", m.Icon); JS_O("owner_id", m.OwnerID); JS_O("application_id", m.ApplicationID); @@ -45,3 +46,22 @@ void Channel::update_from_json(const nlohmann::json &j) { std::optional Channel::GetOverwrite(Snowflake id) const { return Abaddon::Get().GetDiscordClient().GetPermissionOverwrite(ID, id); } + +std::vector Channel::GetDMRecipients() const { + const auto &discord = Abaddon::Get().GetDiscordClient(); + if (Recipients.has_value()) + return *Recipients; + + if (RecipientIDs.has_value()) { + std::vector ret; + for (const auto &id : *RecipientIDs) { + auto user = discord.GetUser(id); + if (user.has_value()) + ret.push_back(std::move(*user)); + } + + return ret; + } + + return std::vector(); +} -- cgit v1.2.3