Skip to content

Commit 2ff40fb

Browse files
committed
Handle ratelimit
1 parent 8ad7cb0 commit 2ff40fb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libs/utilities/notifier.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ def self.notify(title, description, color, webhook = :message_webhook)
100100
embed = { title: title, description: description, color: color }
101101
body = { embeds: [embed] }.to_json
102102

103-
HttpClient.post(config[webhook], { headers: config[:headers], body: body })
103+
resp = HttpClient.post(config[webhook], { headers: config[:headers], body: body })
104+
105+
ratelimit_remaining = resp.headers['x-ratelimit-remaining']&.to_i
106+
ratelimit_reset_after = resp.headers['x-ratelimit-reset-after']&.to_i
107+
108+
sleep(ratelimit_reset_after) if ratelimit_remaining.zero?
104109
end
105110
end
106111
end

0 commit comments

Comments
 (0)