mirror of
https://onedev.fprog.nl/DiscordClient
synced 2025-12-29 06:28:37 +01:00
Extract delay to a reusable function.
This commit is contained in:
parent
0dcfc7c516
commit
68e55d9b02
|
|
@ -15,6 +15,13 @@ if (token == null)
|
|||
DiscordContext db = new DiscordContext();
|
||||
DiscordUserClient client = new DiscordUserClient(token);
|
||||
|
||||
static async Task TooManyRequestsDelay()
|
||||
{
|
||||
int seconds = 60;
|
||||
Console.WriteLine($"Too many requests. Sleeping for extra {seconds} seconds.");
|
||||
await Task.Delay(TimeSpan.FromSeconds(seconds));
|
||||
}
|
||||
|
||||
int finalCode = await CommandLine
|
||||
.Parser.Default.ParseArguments<DeleteOptions, ScanOptions>(args)
|
||||
.MapResult(
|
||||
|
|
@ -46,8 +53,7 @@ int finalCode = await CommandLine
|
|||
|
||||
if (response.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
|
||||
{
|
||||
Console.WriteLine("Too many requests. Sleeping for extra 20 seconds.");
|
||||
await Task.Delay(TimeSpan.FromSeconds(20));
|
||||
await TooManyRequestsDelay();
|
||||
}
|
||||
|
||||
db.Update(message);
|
||||
|
|
|
|||
Loading…
Reference in a new issue