feat: add sharding support

This commit is contained in:
sam 2024-08-24 19:02:19 +02:00
parent 8f39d85486
commit c42ca3f888
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
7 changed files with 167 additions and 9 deletions

View file

@ -0,0 +1,13 @@
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();
}
}