summaryrefslogtreecommitdiff
path: root/discord/discord.cpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-04-14 02:11:36 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2021-04-14 02:11:36 -0400
commit9733ae54c386f347e338c7854869ba2e57b113cb (patch)
tree9954638cbd0b7172e7822b0bdf799c02eb41d0df /discord/discord.cpp
parent9a7a468607d0e289c8a42adfa13bc2e9f65e9696 (diff)
downloadabaddon-portaudio-9733ae54c386f347e338c7854869ba2e57b113cb.tar.gz
abaddon-portaudio-9733ae54c386f347e338c7854869ba2e57b113cb.zip
update rate limit indicator on failed message send
this happens when you start the client while already rate-limited
Diffstat (limited to 'discord/discord.cpp')
-rw-r--r--discord/discord.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/discord/discord.cpp b/discord/discord.cpp
index 00597f9..e0889cc 100644
--- a/discord/discord.cpp
+++ b/discord/discord.cpp
@@ -353,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);
+ }
}
}