diff --git a/DisCatSharp/Entities/Guild/DiscordGuildPreview.cs b/DisCatSharp/Entities/Guild/DiscordGuildPreview.cs index 2c7e3d294..24bf3f61b 100644 --- a/DisCatSharp/Entities/Guild/DiscordGuildPreview.cs +++ b/DisCatSharp/Entities/Guild/DiscordGuildPreview.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; +using DisCatSharp.Attributes; using DisCatSharp.Enums; using DisCatSharp.Net; using DisCatSharp.Net.Serialization; @@ -16,11 +17,17 @@ namespace DisCatSharp.Entities; /// public class DiscordGuildPreview : SnowflakeObject { + /// + /// Gets the emojis. + /// [JsonProperty("emojis", NullValueHandling = NullValueHandling.Ignore), JsonConverter(typeof(SnowflakeArrayAsDictionaryJsonConverter))] - internal ConcurrentDictionary EmojisInternal; + internal ConcurrentDictionary EmojisInternal = []; + /// + /// Gets the stickers. + /// [JsonProperty("stickers", NullValueHandling = NullValueHandling.Ignore), JsonConverter(typeof(SnowflakeArrayAsDictionaryJsonConverter))] - internal ConcurrentDictionary StickersInternal; + internal ConcurrentDictionary StickersInternal = []; /// /// Initializes a new instance of the class. @@ -38,41 +45,54 @@ internal DiscordGuildPreview() /// Gets the guild icon's hash. /// [JsonProperty("icon", NullValueHandling = NullValueHandling.Ignore)] - public string IconHash { get; internal set; } + public string? IconHash { get; internal set; } /// /// Gets the guild icon's url. /// [JsonIgnore] - public string IconUrl + public string? IconUrl => !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; /// /// Gets the guild splash's hash. /// [JsonProperty("splash", NullValueHandling = NullValueHandling.Ignore)] - public string SplashHash { get; internal set; } + public string? SplashHash { get; internal set; } /// /// Gets the guild splash's url. /// [JsonIgnore] - public string SplashUrl + public string? SplashUrl => !string.IsNullOrWhiteSpace(this.SplashHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.SPLASHES}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.SplashHash}.png?size=1024" : null; /// /// Gets the guild discovery splash's hash. /// [JsonProperty("discovery_splash", NullValueHandling = NullValueHandling.Ignore)] - public string DiscoverySplashHash { get; internal set; } + public string? DiscoverySplashHash { get; internal set; } /// /// Gets the guild discovery splash's url. /// [JsonIgnore] - public string DiscoverySplashUrl + public string? DiscoverySplashUrl => !string.IsNullOrWhiteSpace(this.DiscoverySplashHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.GUILD_DISCOVERY_SPLASHES}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.DiscoverySplashHash}.png?size=1024" : null; + /// + /// Gets the guild home header's hash. + /// + [JsonProperty("home_header", NullValueHandling = NullValueHandling.Ignore)] + public string? HomeHeaderHash { get; internal set; } + + /// + /// Gets the guild home header's url. + /// + [JsonIgnore, RequiresFeature(Attributes.Features.Onboarding, "Requires to have guide enabled.")] + public string? HomeHeaderUrl + => !string.IsNullOrWhiteSpace(this.HomeHeaderHash) ? $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.GUILD_HOME_HEADERS}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.HomeHeaderHash}.jpg?size=1280" : null; + /// /// Gets a collection of this guild's emojis. /// @@ -89,7 +109,7 @@ public string DiscoverySplashUrl /// Gets a collection of this guild's features. /// [JsonProperty("features", NullValueHandling = NullValueHandling.Ignore)] - public IReadOnlyList Features { get; internal set; } + public IReadOnlyList Features { get; internal set; } = []; /// /// Gets the approximate member count. @@ -107,7 +127,7 @@ public string DiscoverySplashUrl /// Gets the description for the guild, if the guild is discoverable. /// [JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)] - public string Description { get; internal set; } + public string? Description { get; internal set; } /// /// Gets the system channel flags for the guild.