feat: update Discord status only on identify

See <https://github.com/discord/discord-api-docs/issues/4073#issuecomment-1016762755>

We still update status when restarting cluster, because it doesn't really matter if the session dies in that case (we're already restarting / going to reidentify)
This commit is contained in:
spiral
2022-01-20 05:52:40 -05:00
parent b586ef5d0a
commit c6e4c862b8
3 changed files with 31 additions and 63 deletions

View File

@@ -16,6 +16,8 @@ public class Cluster
private readonly ConcurrentDictionary<int, Shard> _shards = new();
private IGatewayRatelimiter? _ratelimiter;
public GatewayStatusUpdate DiscordPresence { get; set; }
public Cluster(GatewaySettings gatewaySettings, ILogger logger)
{
_gatewaySettings = gatewaySettings;
@@ -54,7 +56,7 @@ public class Cluster
private void CreateAndAddShard(string url, ShardInfo shardInfo)
{
var shard = new Shard(_gatewaySettings, shardInfo, _ratelimiter!, url, _logger);
var shard = new Shard(_gatewaySettings, shardInfo, _ratelimiter!, url, _logger, DiscordPresence);
shard.OnEventReceived += evt => OnShardEventReceived(shard, evt);
_shards[shardInfo.ShardId] = shard;