fix: disconnect all shards when shard manager restarts, don't fetch old timeouts
This commit is contained in:
parent
492283b9c1
commit
0564206bf7
2 changed files with 19 additions and 2 deletions
|
|
@ -115,7 +115,9 @@ public class ShardedGatewayClient(
|
|||
_logger.Information("Started shard {ShardId}/{ShardCount}", shardIndex, TotalShards);
|
||||
}
|
||||
|
||||
return await await Task.WhenAny(tasks);
|
||||
var taskResult = await await Task.WhenAny(tasks);
|
||||
Disconnect();
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
public int ShardIdFor(ulong guildId) => (int)((guildId >> 22) % (ulong)TotalShards);
|
||||
|
|
@ -136,6 +138,17 @@ public class ShardedGatewayClient(
|
|||
client.Dispose();
|
||||
}
|
||||
|
||||
private void Disconnect()
|
||||
{
|
||||
_logger.Information("Disconnecting from Discord");
|
||||
foreach (var shardId in _gatewayClients.Keys)
|
||||
{
|
||||
_logger.Debug("Disposing shard {shardId}", shardId);
|
||||
if (_gatewayClients.Remove(shardId, out var client))
|
||||
client.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private IOptions<DiscordGatewayClientOptions> CloneOptions(
|
||||
DiscordGatewayClientOptions options,
|
||||
int shardId
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue