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.

RpcGuild.cs 1.1 KiB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections.Generic;
  2. using System.Collections.Immutable;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using Model = Discord.API.Rpc.Guild;
  6. namespace Discord.Rpc
  7. {
  8. [DebuggerDisplay(@"{DebuggerDisplay,nq}")]
  9. public class RpcGuild : RpcEntity<ulong>
  10. {
  11. public string Name { get; private set; }
  12. public string IconUrl { get; private set; }
  13. public IReadOnlyCollection<RpcGuildUser> Users { get; private set; }
  14. internal RpcGuild(DiscordRpcClient discord, ulong id)
  15. : base(discord, id)
  16. {
  17. }
  18. internal static RpcGuild Create(DiscordRpcClient discord, Model model)
  19. {
  20. var entity = new RpcGuild(discord, model.Id);
  21. entity.Update(model);
  22. return entity;
  23. }
  24. internal void Update(Model model)
  25. {
  26. Name = model.Name;
  27. IconUrl = model.IconUrl;
  28. Users = model.Members.Select(x => RpcGuildUser.Create(Discord, x)).ToImmutableArray();
  29. }
  30. public override string ToString() => Name;
  31. private string DebuggerDisplay => $"{Name} ({Id})";
  32. }
  33. }