You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

SocketPresence.cs 925 B

12345678910111213141516171819202122232425262728
  1. using System.Diagnostics;
  2. using Model = Discord.API.Presence;
  3. namespace Discord.WebSocket
  4. {
  5. //TODO: C#7 Candidate for record type
  6. [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
  7. public struct SocketPresence : IPresence
  8. {
  9. public UserStatus Status { get; }
  10. public Activity? Activity { get; }
  11. internal SocketPresence(UserStatus status, Activity? game)
  12. {
  13. Status = status;
  14. Activity = game;
  15. }
  16. internal static SocketPresence Create(Model model)
  17. {
  18. return new SocketPresence(model.Status, model.Activity != null ? model.Activity.ToEntity() : (Activity?)null);
  19. }
  20. public override string ToString() => Status.ToString();
  21. private string DebuggerDisplay => $"{Status}{(Activity != null ? $", {Activity.Value.Name} ({Activity.Value.Type})" : "")}";
  22. internal SocketPresence Clone() => this;
  23. }
  24. }