mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-19 08:23:35 +03:00
We're moving! --------- Signed-off-by: Macintosh II <mctaylxrs@outlook.com> Signed-off-by: Macintosh II <95250141+mctaylors@users.noreply.github.com> Co-authored-by: Octol1ttle <l1ttleofficial@outlook.com>
23 lines
578 B
C#
23 lines
578 B
C#
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace Octobot.Services;
|
|
|
|
public sealed class BackgroundGuildDataSaverService : BackgroundService
|
|
{
|
|
private readonly GuildDataService _guildData;
|
|
|
|
public BackgroundGuildDataSaverService(GuildDataService guildData)
|
|
{
|
|
_guildData = guildData;
|
|
}
|
|
|
|
protected override async Task ExecuteAsync(CancellationToken ct)
|
|
{
|
|
using var timer = new PeriodicTimer(TimeSpan.FromMinutes(5));
|
|
|
|
while (await timer.WaitForNextTickAsync(ct))
|
|
{
|
|
await _guildData.SaveAsync(ct);
|
|
}
|
|
}
|
|
}
|