Browse Source

fix vanity url code and banner switchup

a mistake was made somewhere, that's all I know for sure
pull/1319/head
Chris Johnston 6 years ago
parent
commit
29dfe43236
5 changed files with 39 additions and 20 deletions
  1. +7
    -7
      src/Discord.Net.Core/CDN.cs
  2. +16
    -6
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  3. +2
    -0
      src/Discord.Net.Rest/API/Common/Guild.cs
  4. +8
    -4
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  5. +6
    -3
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 7
- 7
src/Discord.Net.Core/CDN.cs View File

@@ -78,18 +78,18 @@ namespace Discord
=> iconId != null ? $"{DiscordConfig.CDNUrl}channel-icons/{channelId}/{iconId}.jpg" : null; => iconId != null ? $"{DiscordConfig.CDNUrl}channel-icons/{channelId}/{iconId}.jpg" : null;


/// <summary> /// <summary>
/// Returns a guild vanity URL.
/// Returns a guild banner URL.
/// </summary> /// </summary>
/// <param name="guildId">The guild snowflake identifier.</param> /// <param name="guildId">The guild snowflake identifier.</param>
/// <param name="vanityId">The vanity image identifier.</param>
/// <param name="size">The size of the image to return in horizontal pixels. This can be any power of two between 16 and 2048.</param>
/// <param name="bannerId">The banner image identifier.</param>
/// <param name="size">The size of the image to return in horizontal pixels. This can be any power of two between 16 and 2048 inclusive.</param>
/// <returns> /// <returns>
/// A URL pointing to the guild's vanity image.
/// A URL pointing to the guild's banner image.
/// </returns> /// </returns>
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; return null;
} }
/// <summary> /// <summary>


+ 16
- 6
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -204,19 +204,29 @@ namespace Discord
/// </returns> /// </returns>
PremiumTier PremiumTier { get; } PremiumTier PremiumTier { get; }
/// <summary> /// <summary>
/// Gets the identifier for this guilds vanity image.
/// Gets the identifier for this guilds banner image.
/// </summary>
/// <returns>
/// An identifier for the banner image; <c>null</c> if none is set.
/// </returns>
string BannerId { get; }
/// <summary>
/// Gets the URL of this guild's banner image.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// An identifier for the vanity image; <c>null</c> if none is set.
/// This is referred to as the vanity image in the API.
/// </remarks> /// </remarks>
string VanityId { get; }
/// <returns>
/// A URL pointing to the guild's banner image; <c>null</c> if none is set.
/// </returns>
string BannerUrl { get; }
/// <summary> /// <summary>
/// Gets the URL of this guild's vanity image.
/// Gets the code for this guild's vanity invite URL.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A URL pointing to the guild's vanity image; <c>null</c> if none is set.
/// A string containing the vanity invite code for this guild; <c>null</c> if none is set.
/// </returns> /// </returns>
string VanityUrl { get; }
string VanityURLCode { get; }
/// <summary> /// <summary>
/// Gets the flags for the types of system channels that are disabled. /// Gets the flags for the types of system channels that are disabled.
/// </summary> /// </summary>


+ 2
- 0
src/Discord.Net.Rest/API/Common/Guild.cs View File

@@ -49,6 +49,8 @@ namespace Discord.API
public PremiumTier PremiumTier { get; set; } public PremiumTier PremiumTier { get; set; }
[JsonProperty("vanity_url_code")] [JsonProperty("vanity_url_code")]
public string VanityURLCode { get; set; } public string VanityURLCode { get; set; }
[JsonProperty("banner")]
public string Banner { get; set; }
[JsonProperty("description")] [JsonProperty("description")]
public string Description { get; set; } public string Description { get; set; }
// this value is inverted, flags set will turn OFF features // this value is inverted, flags set will turn OFF features


+ 8
- 4
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -55,7 +55,9 @@ namespace Discord.Rest
/// <inheritdoc /> /// <inheritdoc />
public PremiumTier PremiumTier { get; private set; } public PremiumTier PremiumTier { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public string VanityId { get; private set; }
public string BannerId { get; private set; }
/// <inheritdoc />
public string VanityURLCode { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public SystemChannelMessageDeny SystemChannelFlags { get; private set; } public SystemChannelMessageDeny SystemChannelFlags { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
@@ -73,7 +75,7 @@ namespace Discord.Rest
/// <inheritdoc /> /// <inheritdoc />
public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId);
/// <inheritdoc /> /// <inheritdoc />
public string VanityUrl => CDN.GetGuildVanityUrl(Id, VanityId);
public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId);


/// <summary> /// <summary>
/// Gets the built-in role containing all users in this guild. /// Gets the built-in role containing all users in this guild.
@@ -117,10 +119,12 @@ namespace Discord.Rest
ExplicitContentFilter = model.ExplicitContentFilter; ExplicitContentFilter = model.ExplicitContentFilter;
ApplicationId = model.ApplicationId; ApplicationId = model.ApplicationId;
PremiumTier = model.PremiumTier; PremiumTier = model.PremiumTier;
VanityId = model.VanityURLCode;
VanityURLCode = model.VanityURLCode;
BannerId = model.Banner;
SystemChannelFlags = model.SystemChannelFlags; SystemChannelFlags = model.SystemChannelFlags;
Description = model.Description; Description = model.Description;
PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault();
if (model.PremiumSubscriptionCount.IsSpecified)
PremiumSubscriptionCount = model.PremiumSubscriptionCount.Value;


if (model.Emojis != null) if (model.Emojis != null)
{ {


+ 6
- 3
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -96,7 +96,9 @@ namespace Discord.WebSocket
/// <inheritdoc /> /// <inheritdoc />
public PremiumTier PremiumTier { get; private set; } public PremiumTier PremiumTier { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public string VanityId { get; private set; }
public string BannerId { get; private set; }
/// <inheritdoc />
public string VanityURLCode { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public SystemChannelMessageDeny SystemChannelFlags { get; private set; } public SystemChannelMessageDeny SystemChannelFlags { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
@@ -111,7 +113,7 @@ namespace Discord.WebSocket
/// <inheritdoc /> /// <inheritdoc />
public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId);
/// <inheritdoc /> /// <inheritdoc />
public string VanityUrl => CDN.GetGuildVanityUrl(Id, VanityId);
public string BannerUrl => CDN.GetGuildBannerUrl(Id, BannerId);
/// <summary> Indicates whether the client has all the members downloaded to the local guild cache. </summary> /// <summary> Indicates whether the client has all the members downloaded to the local guild cache. </summary>
public bool HasAllMembers => MemberCount == DownloadedMemberCount;// _downloaderPromise.Task.IsCompleted; public bool HasAllMembers => MemberCount == DownloadedMemberCount;// _downloaderPromise.Task.IsCompleted;
/// <summary> Indicates whether the guild cache is synced to this guild. </summary> /// <summary> Indicates whether the guild cache is synced to this guild. </summary>
@@ -367,7 +369,8 @@ namespace Discord.WebSocket
ExplicitContentFilter = model.ExplicitContentFilter; ExplicitContentFilter = model.ExplicitContentFilter;
ApplicationId = model.ApplicationId; ApplicationId = model.ApplicationId;
PremiumTier = model.PremiumTier; PremiumTier = model.PremiumTier;
VanityId = model.VanityURLCode;
VanityURLCode = model.VanityURLCode;
BannerId = model.Banner;
SystemChannelFlags = model.SystemChannelFlags; SystemChannelFlags = model.SystemChannelFlags;
Description = model.Description; Description = model.Description;
PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault(); PremiumSubscriptionCount = model.PremiumSubscriptionCount.GetValueOrDefault();


Loading…
Cancel
Save