Catalogger.NET/Catalogger.Backend/Bot/ShardedDiscordService.cs
2024-10-09 17:35:11 +02:00

14 lines
455 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();
}
}