13 lines
450 B
C#
13 lines
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();
|
||
|
|
}
|
||
|
|
}
|