mirror of
https://onedev.fprog.nl/DiscordClient
synced 2026-01-30 20:23:42 +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();
|
DiscordContext db = new DiscordContext();
|
||||||
DiscordUserClient client = new DiscordUserClient(token);
|
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
|
int finalCode = await CommandLine
|
||||||
.Parser.Default.ParseArguments<DeleteOptions, ScanOptions>(args)
|
.Parser.Default.ParseArguments<DeleteOptions, ScanOptions>(args)
|
||||||
.MapResult(
|
.MapResult(
|
||||||
|
|
@ -46,8 +53,7 @@ int finalCode = await CommandLine
|
||||||
|
|
||||||
if (response.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
|
if (response.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Too many requests. Sleeping for extra 20 seconds.");
|
await TooManyRequestsDelay();
|
||||||
await Task.Delay(TimeSpan.FromSeconds(20));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db.Update(message);
|
db.Update(message);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue