2024-08-24 19:02:19 +02:00
|
|
|
using Remora.Discord.Gateway.Results;
|
|
|
|
|
|
|
|
|
|
namespace Catalogger.Backend.Bot;
|
|
|
|
|
|
2024-10-09 17:35:11 +02:00
|
|
|
public class ShardedDiscordService(ShardedGatewayClient client, IHostApplicationLifetime lifetime)
|
|
|
|
|
: BackgroundService
|
2024-08-24 19:02:19 +02:00
|
|
|
{
|
|
|
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
|
|
|
{
|
|
|
|
|
var result = await client.RunAsync(stoppingToken);
|
|
|
|
|
if (result.Error is GatewayError { IsCritical: true })
|
|
|
|
|
lifetime.StopApplication();
|
|
|
|
|
}
|
2024-10-09 17:35:11 +02:00
|
|
|
}
|