Update shard status tracker for new library

This commit is contained in:
Ske
2020-05-01 17:30:12 +02:00
parent d0f1aeb548
commit 48833639e2
3 changed files with 84 additions and 59 deletions

View File

@@ -118,9 +118,6 @@ namespace PluralKit.Bot
public Task Init()
{
// DiscordShardedClient SocketErrored/Ready events also fire whenever an individual shard's respective events fire
_client.SocketErrored += ShardDisconnected;
_client.Ready += ShardReady;
_client.DebugLogger.LogMessageReceived += FrameworkLog;
_client.MessageCreated += args => HandleEvent(eh => eh.HandleMessage(args));
@@ -137,12 +134,6 @@ namespace PluralKit.Bot
return Task.CompletedTask;
}
private Task ShardDisconnected(SocketErrorEventArgs e)
{
_logger.Warning(e.Exception, $"Shard #{e.Client.ShardId} disconnected");
return Task.CompletedTask;
}
private void FrameworkLog(object sender, DebugLogMessageEventArgs args)
{
// Bridge D#+ logging to Serilog
@@ -185,12 +176,6 @@ namespace PluralKit.Bot
}
}
private Task ShardReady(ReadyEventArgs e)
{
_logger.Information("Shard {Shard} connected to {ChannelCount} channels in {GuildCount} guilds", e.Client.ShardId, e.Client.Guilds.Sum(g => g.Value.Channels.Count), e.Client.Guilds.Count);
return Task.CompletedTask;
}
private Task HandleEvent(Func<PKEventHandler, Task> handler)
{
// Inner function so we can await the handler without stalling the entire pipeline