1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-19 08:23:35 +03:00
Octobot/src/Services/BackgroundGuildDataSaverService.cs
Macintosh II 804bcd6e68
Rebrand to Octobot (#128)
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>
2023-09-30 18:58:32 +05:00

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);
}
}
}