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 1.3 kB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Diagnostics;
  2. using Model = Discord.API.Presence;
  3. namespace Discord.WebSocket
  4. {
  5. /// <summary>
  6. /// Represents the WebSocket user's presence status. This may include their online status and their activity.
  7. /// </summary>
  8. [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
  9. public struct SocketPresence : IPresence
  10. {
  11. /// <inheritdoc />
  12. public UserStatus Status { get; }
  13. /// <inheritdoc />
  14. public IActivity Activity { get; }
  15. internal SocketPresence(UserStatus status, IActivity activity)
  16. {
  17. Status = status;
  18. Activity= activity;
  19. }
  20. internal static SocketPresence Create(Model model)
  21. {
  22. return new SocketPresence(model.Status, model.Game?.ToEntity());
  23. }
  24. /// <summary>
  25. /// Gets the status of the user.
  26. /// </summary>
  27. /// <returns>
  28. /// A string that resolves to <see cref="Discord.WebSocket.SocketPresence.Status" />.
  29. /// </returns>
  30. public override string ToString() => Status.ToString();
  31. private string DebuggerDisplay => $"{Status}{(Activity != null ? $", {Activity.Name}": "")}";
  32. internal SocketPresence Clone() => this;
  33. }
  34. }