pretend to be a real client a little better

This commit is contained in:
ouwou
2020-12-14 03:05:16 -05:00
parent 33ed25b2f6
commit 22578921b9
10 changed files with 134 additions and 43 deletions

View File

@@ -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<PermissionOverwrite> Channel::GetOverwrite(Snowflake id) const {
return Abaddon::Get().GetDiscordClient().GetPermissionOverwrite(ID, id);
}
std::vector<User> Channel::GetDMRecipients() const {
const auto &discord = Abaddon::Get().GetDiscordClient();
if (Recipients.has_value())
return *Recipients;
if (RecipientIDs.has_value()) {
std::vector<User> 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<User>();
}