Add a setting to control whether to respect advisory rate limits (#1342)

This commit is contained in:
Oleksii Holub
2025-05-12 19:52:47 +03:00
committed by GitHub
parent 1506afc4a2
commit 612ae2e894
8 changed files with 148 additions and 28 deletions

View File

@@ -27,8 +27,19 @@ public abstract class DiscordCommandBase : ICommand
)]
public bool IsBotToken { get; init; } = false;
[CommandOption(
"respect-rate-limits",
Description = "Whether to respect advisory rate limits. "
+ "If disabled, only hard rate limits (i.e. 429 responses) will be respected."
)]
public bool ShouldRespectRateLimits { get; init; } = true;
private DiscordClient? _discordClient;
protected DiscordClient Discord => _discordClient ??= new DiscordClient(Token);
protected DiscordClient Discord =>
_discordClient ??= new DiscordClient(
Token,
ShouldRespectRateLimits ? RateLimitPreference.RespectAll : RateLimitPreference.IgnoreAll
);
public virtual ValueTask ExecuteAsync(IConsole console)
{