diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-05-09 02:55:35 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-05-09 02:55:35 -0400 |
commit | e6a20e59840a111ab94aaa55974bb43989571344 (patch) | |
tree | 11148b68f896ec1244007a3c7b110ca717f88f27 /discord | |
parent | ae3b25674635257b70f5ad59b71abaf0019c6b4e (diff) | |
download | abaddon-portaudio-e6a20e59840a111ab94aaa55974bb43989571344.tar.gz abaddon-portaudio-e6a20e59840a111ab94aaa55974bb43989571344.zip |
add ability to remove relationships
Diffstat (limited to 'discord')
-rw-r--r-- | discord/discord.cpp | 12 | ||||
-rw-r--r-- | discord/discord.hpp | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/discord/discord.cpp b/discord/discord.cpp index 21e2780..e82ba1b 100644 --- a/discord/discord.cpp +++ b/discord/discord.cpp @@ -691,6 +691,12 @@ std::optional<GuildApplicationData> DiscordClient::GetGuildApplication(Snowflake return it->second; } +void DiscordClient::RemoveRelationship(Snowflake id, sigc::slot<void(bool success)> callback) { + m_http.MakeDELETE("/users/@me/relationships/" + std::to_string(id), [this, callback](const http::response_type &response) { + callback(CheckCode(response)); + }); +} + bool DiscordClient::CanModifyRole(Snowflake guild_id, Snowflake role_id, Snowflake user_id) const { const auto guild = *GetGuild(guild_id); if (guild.OwnerID == user_id) return true; @@ -862,6 +868,12 @@ std::unordered_set<Snowflake> DiscordClient::GetRelationships(RelationshipType t return ret; } +std::optional<RelationshipType> DiscordClient::GetRelationship(Snowflake id) const { + if (auto it = m_user_relationships.find(id); it != m_user_relationships.end()) + return it->second; + return std::nullopt; +} + void DiscordClient::HandleGatewayMessageRaw(std::string str) { // handles multiple zlib compressed messages, calling HandleGatewayMessage when a full message is received std::vector<uint8_t> buf(str.begin(), str.end()); diff --git a/discord/discord.hpp b/discord/discord.hpp index a8d1503..29e47b0 100644 --- a/discord/discord.hpp +++ b/discord/discord.hpp @@ -138,6 +138,7 @@ public: void ModifyEmojiName(Snowflake guild_id, Snowflake emoji_id, const Glib::ustring &name, sigc::slot<void(bool success)> callback); void DeleteEmoji(Snowflake guild_id, Snowflake emoji_id, sigc::slot<void(bool success)> callback); std::optional<GuildApplicationData> GetGuildApplication(Snowflake guild_id) const; + void RemoveRelationship(Snowflake id, sigc::slot<void(bool success)> callback); bool CanModifyRole(Snowflake guild_id, Snowflake role_id) const; bool CanModifyRole(Snowflake guild_id, Snowflake role_id, Snowflake user_id) const; @@ -180,6 +181,7 @@ public: std::unordered_map<Snowflake, RelationshipType> GetRelationships() const; std::unordered_set<Snowflake> GetRelationships(RelationshipType type) const; + std::optional<RelationshipType> GetRelationship(Snowflake id) const; private: static const constexpr int InflateChunkSize = 0x10000; |