diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-04-15 02:35:36 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2021-04-15 02:35:36 -0400 |
commit | cd8cd97c9b1fb297f4bf455135d0e0e690358c53 (patch) | |
tree | 1ae78c800072bb8154596566b1898ba232e9422c /discord/discord.cpp | |
parent | 0aaebf9ea77eede8a347aa71b95e86686d04a854 (diff) | |
parent | f5df43194e19be7995d753c5e9dd0a5a9365f24a (diff) | |
download | abaddon-portaudio-cd8cd97c9b1fb297f4bf455135d0e0e690358c53.tar.gz abaddon-portaudio-cd8cd97c9b1fb297f4bf455135d0e0e690358c53.zip |
Merge branch 'slowmode'
Diffstat (limited to 'discord/discord.cpp')
-rw-r--r-- | discord/discord.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/discord/discord.cpp b/discord/discord.cpp index 17ea74c..1dc8fe9 100644 --- a/discord/discord.cpp +++ b/discord/discord.cpp @@ -261,6 +261,14 @@ bool DiscordClient::HasGuildPermission(Snowflake user_id, Snowflake guild_id, Pe return (base & perm) == perm; } +bool DiscordClient::HasAnyChannelPermission(Snowflake user_id, Snowflake channel_id, Permission perm) const { + const auto channel = m_store.GetChannel(channel_id); + if (!channel.has_value()) return false; + const auto base = ComputePermissions(user_id, *channel->GuildID); + const auto overwrites = ComputeOverwrites(base, user_id, channel_id); + return (overwrites & perm) != Permission::NONE; +} + bool DiscordClient::HasChannelPermission(Snowflake user_id, Snowflake channel_id, Permission perm) const { const auto channel = m_store.GetChannel(channel_id); if (!channel.has_value()) return false; @@ -345,7 +353,16 @@ bool DiscordClient::CanManageMember(Snowflake guild_id, Snowflake actor, Snowfla void DiscordClient::ChatMessageCallback(std::string nonce, const http::response_type &response) { if (!CheckCode(response)) { - m_signal_message_send_fail.emit(nonce); + if (response.status_code == http::TooManyRequests) { + try { // not sure if this body is guaranteed + RateLimitedResponse r = nlohmann::json::parse(response.text); + m_signal_message_send_fail.emit(nonce, r.RetryAfter); + } catch (...) { + m_signal_message_send_fail.emit(nonce, 0); + } + } else { + m_signal_message_send_fail.emit(nonce, 0); + } } } |