Catalogger.NET/Catalogger.Backend/Bot/ShardedDiscordService.cs
2024-08-24 19:02:19 +02:00

13 lines
No EOL
450 B
C#

using Remora.Discord.Gateway.Results;
namespace Catalogger.Backend.Bot;
public class ShardedDiscordService(ShardedGatewayClient client, IHostApplicationLifetime lifetime) : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var result = await client.RunAsync(stoppingToken);
if (result.Error is GatewayError { IsCritical: true })
lifetime.StopApplication();
}
}