mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-14 01:30:13 +00:00
Fix Periodic Methods
This commit is contained in:
parent
c41f2c7c9b
commit
2fd07c9ec9
1 changed files with 9 additions and 4 deletions
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.WebSockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using App.Metrics;
|
using App.Metrics;
|
||||||
|
|
@ -162,7 +163,11 @@ namespace PluralKit.Bot
|
||||||
{
|
{
|
||||||
// Change bot status
|
// Change bot status
|
||||||
var totalGuilds = _client.ShardClients.Values.Sum(c => c.Guilds.Count);
|
var totalGuilds = _client.ShardClients.Values.Sum(c => c.Guilds.Count);
|
||||||
await _client.UpdateStatusAsync(new DiscordActivity($"pk;help | in {totalGuilds} servers"));
|
try // DiscordClient may throw an exception if an update is attempted while reconnecting (e.g just after OP 7 received)
|
||||||
|
{
|
||||||
|
await _client.UpdateStatusAsync(new DiscordActivity($"pk;help | in {totalGuilds} servers"));
|
||||||
|
}
|
||||||
|
catch (WebSocketException) { }
|
||||||
|
|
||||||
// Run webhook rate limit GC every 10 minutes
|
// Run webhook rate limit GC every 10 minutes
|
||||||
if (_periodicUpdateCount++ % 10 == 0)
|
if (_periodicUpdateCount++ % 10 == 0)
|
||||||
|
|
@ -176,9 +181,9 @@ namespace PluralKit.Bot
|
||||||
await Task.WhenAll(((IMetricsRoot) _metrics).ReportRunner.RunAllAsync());
|
await Task.WhenAll(((IMetricsRoot) _metrics).ReportRunner.RunAllAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private Task ShardReady(DiscordSocketClient shardClient)
|
private Task ShardReady(DiscordClient shardClient)
|
||||||
{
|
{
|
||||||
_logger.Information("Shard {Shard} connected to {ChannelCount} channels in {GuildCount} guilds", shardClient.ShardId, shardClient.Guilds.Sum(g => g.Channels.Count), shardClient.Guilds.Count);
|
_logger.Information("Shard {Shard} connected to {ChannelCount} channels in {GuildCount} guilds", shardClient.ShardId, shardClient.Guilds.Sum(g => g.Value.Channels.Count), shardClient.Guilds.Count);
|
||||||
|
|
||||||
if (shardClient.ShardId == 0)
|
if (shardClient.ShardId == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -190,7 +195,7 @@ namespace PluralKit.Bot
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
private Task HandleEvent(Func<PKEventHandler, Task> handler)
|
private Task HandleEvent(Func<PKEventHandler, Task> handler)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue