46 lines
No EOL
1.2 KiB
C#
46 lines
No EOL
1.2 KiB
C#
using Foxcord.Models;
|
|
|
|
namespace Foxcord.Gateway.Events.Commands;
|
|
|
|
public class PresenceUpdateCommand : IGatewayCommand
|
|
{
|
|
public long? Since { get; init; }
|
|
public Activity[] Activities { get; init; } = [];
|
|
public PresenceStatusType Status { get; init; }
|
|
public bool Afk { get; init; }
|
|
|
|
public GatewayPacket ToGatewayPacket()
|
|
{
|
|
return new GatewayPacket
|
|
{
|
|
Opcode = GatewayOpcode.PresenceUpdate,
|
|
Payload = ToPayload()
|
|
};
|
|
}
|
|
|
|
public PresenceUpdatePayload ToPayload()
|
|
{
|
|
var status = Status switch
|
|
{
|
|
PresenceStatusType.Online => "online",
|
|
PresenceStatusType.Dnd => "dnd",
|
|
PresenceStatusType.Idle => "idle",
|
|
PresenceStatusType.Invisible => "invisible",
|
|
PresenceStatusType.Offline => "offline",
|
|
_ => throw new ArgumentOutOfRangeException()
|
|
};
|
|
|
|
return new PresenceUpdatePayload(Since, Activities, status, Afk);
|
|
}
|
|
|
|
public record PresenceUpdatePayload(long? Since, Activity[] Activities, string Status, bool Afk);
|
|
}
|
|
|
|
public enum PresenceStatusType
|
|
{
|
|
Online,
|
|
Dnd,
|
|
Idle,
|
|
Invisible,
|
|
Offline
|
|
} |