1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-20 00:43:36 +03:00

fix(scheduled events update): run update synchronously to avoid rate limit race conditions

This commit is contained in:
Octol1ttle 2023-09-30 19:49:46 +05:00
parent 804bcd6e68
commit f4387deef7
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF

View file

@ -34,20 +34,15 @@ public sealed class ScheduledEventUpdateService : BackgroundService
protected override async Task ExecuteAsync(CancellationToken ct)
{
using var timer = new PeriodicTimer(TimeSpan.FromSeconds(1));
var tasks = new List<Task>();
while (await timer.WaitForNextTickAsync(ct))
{
var guildIds = _guildData.GetGuildIds();
tasks.AddRange(guildIds.Select(async id =>
foreach (var id in guildIds)
{
var tickResult = await TickScheduledEventsAsync(id, ct);
_logger.LogResult(tickResult, $"Error in scheduled events update for guild {id}.");
}));
await Task.WhenAll(tasks);
tasks.Clear();
}
}
}