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

@@ -41,12 +41,15 @@ public class Shard
private TimeSpan _reconnectDelay = TimeSpan.Zero;
private Task? _worker;
public Shard(GatewaySettings settings, ShardInfo info, IGatewayRatelimiter ratelimiter, string url, ILogger logger)
private GatewayStatusUpdate? _presence { get; init; }
public Shard(GatewaySettings settings, ShardInfo info, IGatewayRatelimiter ratelimiter, string url, ILogger logger, GatewayStatusUpdate? presence = null)
{
_jsonSerializerOptions = new JsonSerializerOptions().ConfigureForMyriad();
_settings = settings;
_info = info;
_presence = presence;
_ratelimiter = ratelimiter;
_url = url;
_logger = logger.ForContext<Shard>().ForContext("ShardId", info.ShardId);
@@ -164,7 +167,8 @@ public class Shard
},
Shard = _info,
Token = _settings.Token,
LargeThreshold = 50
LargeThreshold = 50,
Presence = _presence,
}
});