mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-21 21:54:36 +00:00
Add role removal limit per run
This commit is contained in:
parent
a8d0b4689a
commit
c0b2b9793b
1 changed files with 3 additions and 2 deletions
|
@ -132,9 +132,10 @@ class BirthdayRoleUpdate : BackgroundService {
|
|||
if (!toApply.Contains(user.Id)) removals.Add(user);
|
||||
else no_ops.Add(user.Id);
|
||||
}
|
||||
int removalAllowance = 15; // Limit removals per run, to not get continuously stuck on rate limits in misconfigured servers
|
||||
foreach (var user in removals) {
|
||||
// TODO this gets hit with rate limits sometimes. figure something out.
|
||||
await user.RemoveRoleAsync(r);
|
||||
if (--removalAllowance == 0) break;
|
||||
}
|
||||
|
||||
foreach (var target in toApply) {
|
||||
|
@ -146,7 +147,7 @@ class BirthdayRoleUpdate : BackgroundService {
|
|||
}
|
||||
} catch (Discord.Net.HttpException ex)
|
||||
when (ex.DiscordCode is DiscordErrorCode.MissingPermissions or DiscordErrorCode.InsufficientPermissions) {
|
||||
// Encountered access and/or permission issues despite earlier checks. Quit the loop here.
|
||||
// Encountered access and/or permission issues despite earlier checks. Quit the loop here, don't report error.
|
||||
}
|
||||
return additions;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue