diff --git a/src/StevesBot.Worker/Discord/DiscordGatewayClient.cs b/src/StevesBot.Worker/Discord/DiscordGatewayClient.cs index 49c55bd..3c7a0ba 100644 --- a/src/StevesBot.Worker/Discord/DiscordGatewayClient.cs +++ b/src/StevesBot.Worker/Discord/DiscordGatewayClient.cs @@ -389,7 +389,18 @@ internal sealed class DiscordGatewayClient : IDiscordGatewayClient { var identify = new IdentifyDiscordEvent( _options.AppToken, - _options.Intents + DiscordIntents.All, + new UpdatePresenceData + { + Status = PresenceStatus.Online, + Activities = [ + new() + { + Name = "Helping Stevan", + State = "Helping Stevan" + } + ], + } ); await SendJsonAsync(identify, cancellationToken); diff --git a/src/StevesBot.Worker/Discord/Events/IdentifyDiscordEvent.cs b/src/StevesBot.Worker/Discord/Events/IdentifyDiscordEvent.cs index 3c9759e..6ae95a5 100644 --- a/src/StevesBot.Worker/Discord/Events/IdentifyDiscordEvent.cs +++ b/src/StevesBot.Worker/Discord/Events/IdentifyDiscordEvent.cs @@ -5,30 +5,34 @@ internal sealed record IdentifyDiscordEvent : DiscordEvent [JsonPropertyName("d")] public new IdentifyData Data { get; init; } = new IdentifyData(); - public IdentifyDiscordEvent(string token, long intents) + public IdentifyDiscordEvent(string token, long intents, UpdatePresenceData presence) { OpCode = DiscordOpCodes.Identify; Data = new IdentifyData { Token = token, Intents = intents, + Presence = presence, }; } } -internal record IdentifyData +internal sealed record IdentifyData { [JsonPropertyName("token")] public string Token { get; init; } = string.Empty; [JsonPropertyName("properties")] - public IdentifyProperties Properties { get; init; } = new IdentifyProperties(); + public IdentifyProperties Properties { get; init; } = new(); + + [JsonPropertyName("presence")] + public UpdatePresenceData Presence { get; init; } = new(); [JsonPropertyName("intents")] public long Intents { get; init; } } -internal record IdentifyProperties +internal sealed record IdentifyProperties { [JsonPropertyName("os")] public string Os { get; init; } = Environment.OSVersion.ToString(); @@ -38,4 +42,43 @@ internal record IdentifyProperties [JsonPropertyName("device")] public string Device { get; init; } = Assembly.GetExecutingAssembly().GetName().FullName; +} + +// TODO: Move this to an update presence event file + +internal sealed record UpdatePresenceData +{ + [JsonPropertyName("since")] + public long? Since { get; init; } = null; + + [JsonPropertyName("activities")] + public List Activities { get; init; } = []; + + [JsonPropertyName("status")] + public string Status { get; init; } = PresenceStatus.Online; + + [JsonPropertyName("afk")] + public bool Afk { get; init; } +} + +internal static class PresenceStatus +{ + public const string Online = "online"; +} + +internal sealed record Activity +{ + [JsonPropertyName("name")] + public string Name { get; init; } = string.Empty; + + [JsonPropertyName("type")] + public int Type { get; init; } = ActivityType.Custom; + + [JsonPropertyName("state")] + public string? State { get; init; } +} + +internal static class ActivityType +{ + public const int Custom = 4; } \ No newline at end of file diff --git a/src/StevesBot.Worker/Discord/Events/ReadyDiscordEvent.cs b/src/StevesBot.Worker/Discord/Events/ReadyDiscordEvent.cs index 9313866..0a1a5fc 100644 --- a/src/StevesBot.Worker/Discord/Events/ReadyDiscordEvent.cs +++ b/src/StevesBot.Worker/Discord/Events/ReadyDiscordEvent.cs @@ -1,12 +1,12 @@ namespace StevesBot.Worker.Discord.Events; -internal record ReadyDiscordEvent : DispatchDiscordEvent +internal sealed record ReadyDiscordEvent : DispatchDiscordEvent { [JsonPropertyName("d")] public new ReadyData Data { get; init; } = new ReadyData(); } -internal record ReadyData +internal sealed record ReadyData { [JsonPropertyName("v")] public int Version { get; init; }