|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Globalization; |
| 4 | + |
| 5 | +using DisCatSharp.Enums; |
| 6 | +using DisCatSharp.Net; |
| 7 | + |
| 8 | +using Newtonsoft.Json; |
| 9 | + |
| 10 | +namespace DisCatSharp.Entities; |
| 11 | + |
| 12 | +/// <summary> |
| 13 | +/// Represents a Discord guild profile. |
| 14 | +/// </summary> |
| 15 | +public sealed class DiscordGuildProfile : SnowflakeObject |
| 16 | +{ |
| 17 | + /// <summary> |
| 18 | + /// Gets the guild name. |
| 19 | + /// </summary> |
| 20 | + [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] |
| 21 | + public string Name { get; internal set; } |
| 22 | + |
| 23 | + /// <summary> |
| 24 | + /// Gets the guild icon's hash. |
| 25 | + /// </summary> |
| 26 | + [JsonProperty("icon", NullValueHandling = NullValueHandling.Include)] |
| 27 | + public string? IconHash { get; internal set; } |
| 28 | + |
| 29 | + /// <summary> |
| 30 | + /// Gets the guild icon's url. |
| 31 | + /// </summary> |
| 32 | + [JsonIgnore] |
| 33 | + public string? IconUrl |
| 34 | + => !string.IsNullOrWhiteSpace(this.IconHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.ICONS}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.IconHash}.{(this.IconHash.StartsWith("a_", StringComparison.Ordinal) ? "gif" : "png")}?size=1024" : null; |
| 35 | + |
| 36 | + /// <summary> |
| 37 | + /// Gets the guild banner's hash. |
| 38 | + /// </summary> |
| 39 | + [JsonProperty("banner", NullValueHandling = NullValueHandling.Include)] |
| 40 | + public string? BannerHash { get; internal set; } |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Gets the guild banner's url. |
| 44 | + /// </summary> |
| 45 | + [JsonIgnore] |
| 46 | + public string? BannerUrl |
| 47 | + => !string.IsNullOrWhiteSpace(this.BannerHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Uri}{Endpoints.BANNERS}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.BannerHash}.{(this.BannerHash.StartsWith("a_", StringComparison.Ordinal) ? "gif" : "png")}" : null; |
| 48 | + |
| 49 | + /// <summary> |
| 50 | + /// Gets the guild custom banner's hash. |
| 51 | + /// </summary> |
| 52 | + [JsonProperty("custom_banner", NullValueHandling = NullValueHandling.Include)] |
| 53 | + public string? CustomBannerHash { get; internal set; } |
| 54 | + |
| 55 | + /// <summary> |
| 56 | + /// Gets the guild custom banner's url. |
| 57 | + /// </summary> |
| 58 | + [JsonIgnore] |
| 59 | + public string? CustomBannerUrl |
| 60 | + => !string.IsNullOrWhiteSpace(this.CustomBannerHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Uri}{Endpoints.CUSTOM_BANNERS}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.CustomBannerHash}.{(this.CustomBannerHash.StartsWith("a_", StringComparison.Ordinal) ? "gif" : "png")}" : null; |
| 61 | + |
| 62 | + /// <summary> |
| 63 | + /// Gets the member count. |
| 64 | + /// </summary> |
| 65 | + [JsonProperty("member_count", NullValueHandling = NullValueHandling.Include)] |
| 66 | + public int? MemberCount { get; internal set; } |
| 67 | + |
| 68 | + /// <summary> |
| 69 | + /// Gets the online count. |
| 70 | + /// </summary> |
| 71 | + [JsonProperty("online_count", NullValueHandling = NullValueHandling.Include)] |
| 72 | + public int? OnlineCount { get; internal set; } |
| 73 | + |
| 74 | + /// <summary> |
| 75 | + /// Gets the guild description. |
| 76 | + /// </summary> |
| 77 | + [JsonProperty("description", NullValueHandling = NullValueHandling.Include)] |
| 78 | + public string? Description { get; internal set; } |
| 79 | + |
| 80 | + /// <summary> |
| 81 | + /// Gets the primary brand color. |
| 82 | + /// </summary> |
| 83 | + [JsonProperty("brand_color_primary", NullValueHandling = NullValueHandling.Include)] |
| 84 | + public DiscordColor? BrandColorPrimary { get; internal set; } |
| 85 | + |
| 86 | + /// <summary> |
| 87 | + /// Gets the primary badge color. |
| 88 | + /// </summary> |
| 89 | + [JsonProperty("badge_color_primary", NullValueHandling = NullValueHandling.Include)] |
| 90 | + public DiscordColor? BadgeColorPrimary { get; internal set; } |
| 91 | + |
| 92 | + /// <summary> |
| 93 | + /// Gets the secondary badge color. |
| 94 | + /// </summary> |
| 95 | + [JsonProperty("badge_color_secondary", NullValueHandling = NullValueHandling.Include)] |
| 96 | + public DiscordColor? BadgeColorSecondary { get; internal set; } |
| 97 | + |
| 98 | + /// <summary> |
| 99 | + /// Gets the badge hash. |
| 100 | + /// </summary> |
| 101 | + [JsonProperty("badge_hash", NullValueHandling = NullValueHandling.Include)] |
| 102 | + public string? BadgeHash { get; internal set; } |
| 103 | + |
| 104 | + /// <summary> |
| 105 | + /// Gets the badge url. |
| 106 | + /// </summary> |
| 107 | + [JsonIgnore] |
| 108 | + public string? BadgeUrl |
| 109 | + => !string.IsNullOrWhiteSpace(this.BadgeHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Uri}{Endpoints.BADGES}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.BadgeHash}.png" : null; |
| 110 | + |
| 111 | + /// <summary> |
| 112 | + /// Gets the badge. |
| 113 | + /// </summary> |
| 114 | + [JsonProperty("badge", NullValueHandling = NullValueHandling.Ignore)] |
| 115 | + public int Badge { get; internal set; } = 0; |
| 116 | + |
| 117 | + /// <summary> |
| 118 | + /// Gets the guild tag. |
| 119 | + /// </summary> |
| 120 | + [JsonProperty("tag", NullValueHandling = NullValueHandling.Include)] |
| 121 | + public string? Tag { get; internal set; } |
| 122 | + |
| 123 | + /// <summary> |
| 124 | + /// Gets the game application IDs. |
| 125 | + /// </summary> |
| 126 | + [JsonProperty("game_application_ids", NullValueHandling = NullValueHandling.Ignore)] |
| 127 | + public IReadOnlyList<ulong> GameApplicationIds { get; internal set; } = []; |
| 128 | + |
| 129 | + /// <summary> |
| 130 | + /// Gets the game activities. |
| 131 | + /// </summary> |
| 132 | + [JsonProperty("game_activity", NullValueHandling = NullValueHandling.Ignore)] |
| 133 | + public IReadOnlyDictionary<ulong, DiscordGameActivity> GameActivity { get; internal set; } = new Dictionary<ulong, DiscordGameActivity>(); |
| 134 | + |
| 135 | + /// <summary> |
| 136 | + /// Gets the traits. |
| 137 | + /// </summary> |
| 138 | + [JsonProperty("traits", NullValueHandling = NullValueHandling.Ignore)] |
| 139 | + public IReadOnlyList<DiscordGuildTrait> Traits { get; internal set; } = []; |
| 140 | + |
| 141 | + /// <summary> |
| 142 | + /// Gets the features. |
| 143 | + /// </summary> |
| 144 | + [JsonProperty("features", NullValueHandling = NullValueHandling.Ignore)] |
| 145 | + public IReadOnlyList<string> Features { get; internal set; } = []; |
| 146 | + |
| 147 | + /// <summary> |
| 148 | + /// <para>Gets the visibility.</para> |
| 149 | + /// <para><c>1</c> seems to be the default, for discovery, apply to join and invite only.</para> |
| 150 | + /// <para><c>3</c> seems to be for when you enabled <c>Apply From Profile</c> when having apply to join enabled.</para> |
| 151 | + /// </summary> |
| 152 | + [JsonProperty("visibility", NullValueHandling = NullValueHandling.Ignore)] |
| 153 | + public int Visibility { get; internal set; } |
| 154 | +} |
0 commit comments