From 29dfe43236acdfe624646d50c856eeaae256dd52 Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Wed, 12 Jun 2019 20:56:10 -0700 Subject: [PATCH] fix vanity url code and banner switchup a mistake was made somewhere, that's all I know for sure --- src/Discord.Net.Core/CDN.cs | 14 ++++++------ .../Entities/Guilds/IGuild.cs | 22 ++++++++++++++----- src/Discord.Net.Rest/API/Common/Guild.cs | 2 ++ .../Entities/Guilds/RestGuild.cs | 12 ++++++---- .../Entities/Guilds/SocketGuild.cs | 9 +++++--- 5 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/Discord.Net.Core/CDN.cs b/src/Discord.Net.Core/CDN.cs index ec508297b..32ffbba90 100644 --- a/src/Discord.Net.Core/CDN.cs +++ b/src/Discord.Net.Core/CDN.cs @@ -78,18 +78,18 @@ namespace Discord => iconId != null ? $"{DiscordConfig.CDNUrl}channel-icons/{channelId}/{iconId}.jpg" : null; /// - /// Returns a guild vanity URL. + /// Returns a guild banner URL. /// /// The guild snowflake identifier. - /// The vanity image identifier. - /// The size of the image to return in horizontal pixels. This can be any power of two between 16 and 2048. + /// The banner image identifier. + /// The size of the image to return in horizontal pixels. This can be any power of two between 16 and 2048 inclusive. /// - /// A URL pointing to the guild's vanity image. + /// A URL pointing to the guild's banner image. /// - public static string GetGuildVanityUrl(ulong guildId, string vanityId, ushort? size = null) + public static string GetGuildBannerUrl(ulong guildId, string bannerId, ushort? size = null) { - if (!string.IsNullOrEmpty(vanityId)) - return $"{DiscordConfig.CDNUrl}banners/{guildId}/{vanityId}.jpg" + (size.HasValue ? $"?size={size}" : string.Empty); + if (!string.IsNullOrEmpty(bannerId)) + return $"{DiscordConfig.CDNUrl}banners/{guildId}/{bannerId}.jpg" + (size.HasValue ? $"?size={size}" : string.Empty); return null; } /// diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs index 429861900..ae868acad 100644 --- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs +++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs @@ -204,19 +204,29 @@ namespace Discord /// PremiumTier PremiumTier { get; } /// - /// Gets the identifier for this guilds vanity image. + /// Gets the identifier for this guilds banner image. + /// + /// + /// An identifier for the banner image; null if none is set. + /// + string BannerId { get; } + /// + /// Gets the URL of this guild's banner image. /// /// - /// An identifier for the vanity image; null if none is set. + /// This is referred to as the vanity image in the API. /// - string VanityId { get; } + /// + /// A URL pointing to the guild's banner image; null if none is set. + /// + string BannerUrl { get; } /// - /// Gets the URL of this guild's vanity image. + /// Gets the code for this guild's vanity invite URL. /// /// - /// A URL pointing to the guild's vanity image; null if none is set. + /// A string containing the vanity invite code for this guild; null if none is set. /// - string VanityUrl { get; } + string VanityURLCode { get; } /// /// Gets the flags for the types of system channels that are disabled. /// diff --git a/src/Discord.Net.Rest/API/Common/Guild.cs b/src/Discord.Net.Rest/API/Common/Guild.cs index e30203c25..eb85a6324 100644 --- a/src/Discord.Net.Rest/API/Common/Guild.cs +++ b/src/Discord.Net.Rest/API/Common/Guild.cs @@ -49,6 +49,8 @@ namespace Discord.API public PremiumTier PremiumTier { get; set; } [JsonProperty("vanity_url_code")] public string VanityURLCode { get; set; } + [JsonProperty("banner")] + public string Banner { get; set; } [JsonProperty("description")] public string Description { get; set; } // this value is inverted, flags set will turn OFF features diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index 0a14cbd44..f090f9f03 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -55,7 +55,9 @@ namespace Discord.Rest /// public PremiumTier PremiumTier { get; private set; } /// - public string VanityId { get; private set; } + public string BannerId { get; private set; } + /// + public string VanityURLCode { get; private set; } /// public SystemChannelMessageDeny SystemChannelFlags { get; private set; } /// @@ -73,7 +75,7 @@ namespace Discord.Rest /// public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); /// - public string VanityUrl => CDN.GetGuildVanityUrl(Id, VanityId); + public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId); /// /// Gets the built-in role containing all users in this guild. @@ -117,10 +119,12 @@ namespace Discord.Rest ExplicitContentFilter = model.ExplicitContentFilter; ApplicationId = model.ApplicationId; PremiumTier = model.PremiumTier; - VanityId = model.VanityURLCode; + VanityURLCode = model.VanityURLCode; + BannerId = model.Banner; SystemChannelFlags = model.SystemChannelFlags; Description = model.Description; - PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault(); + if (model.PremiumSubscriptionCount.IsSpecified) + PremiumSubscriptionCount = model.PremiumSubscriptionCount.Value; if (model.Emojis != null) { diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index a580a284e..d5cbfdd64 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -96,7 +96,9 @@ namespace Discord.WebSocket /// public PremiumTier PremiumTier { get; private set; } /// - public string VanityId { get; private set; } + public string BannerId { get; private set; } + /// + public string VanityURLCode { get; private set; } /// public SystemChannelMessageDeny SystemChannelFlags { get; private set; } /// @@ -111,7 +113,7 @@ namespace Discord.WebSocket /// public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); /// - public string VanityUrl => CDN.GetGuildVanityUrl(Id, VanityId); + public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId); /// Indicates whether the client has all the members downloaded to the local guild cache. public bool HasAllMembers => MemberCount == DownloadedMemberCount;// _downloaderPromise.Task.IsCompleted; /// Indicates whether the guild cache is synced to this guild. @@ -367,7 +369,8 @@ namespace Discord.WebSocket ExplicitContentFilter = model.ExplicitContentFilter; ApplicationId = model.ApplicationId; PremiumTier = model.PremiumTier; - VanityId = model.VanityURLCode; + VanityURLCode = model.VanityURLCode; + BannerId = model.Banner; SystemChannelFlags = model.SystemChannelFlags; Description = model.Description; PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault();