mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
Cancel early when rate limited
This commit is contained in:
parent
f8d0fb2f4b
commit
20789411f6
1 changed files with 5 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -74,6 +75,10 @@ namespace PluralKit.Bot
|
|||
using var response = await _client.PostAsync($"{DiscordConfig.APIUrl}webhooks/{webhook.Id}/{webhook.Token}?wait=true", mfd);
|
||||
timerCtx.Dispose();
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.TooManyRequests)
|
||||
// Rate limits should be respected, we bail early
|
||||
throw new WebhookExecutionErrorOnDiscordsEnd();
|
||||
|
||||
var responseString = await response.Content.ReadAsStringAsync();
|
||||
|
||||
JObject responseJson;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue