@@ -51,11 +51,18 @@ namespace Discord | |||||
/// </summary> | /// </summary> | ||||
/// <param name="guildId">The guild snowflake identifier.</param> | /// <param name="guildId">The guild snowflake identifier.</param> | ||||
/// <param name="iconId">The icon identifier.</param> | /// <param name="iconId">The icon identifier.</param> | ||||
/// <param name="size">The size of the image to return in. This can be any power of two between 16 and 2048.</param> | |||||
/// <param name="format">The format to return.</param> | |||||
/// <returns> | /// <returns> | ||||
/// A URL pointing to the guild's icon. | |||||
/// A URL pointing to the guild's icon in the specified size. | |||||
/// </returns> | /// </returns> | ||||
public static string GetGuildIconUrl(ulong guildId, string iconId) | |||||
=> iconId != null ? $"{DiscordConfig.CDNUrl}icons/{guildId}/{iconId}.jpg" : null; | |||||
public static string GetGuildIconUrl(ulong guildId, string iconId, ushort size, ImageFormat format) | |||||
{ | |||||
if (iconId == null) | |||||
return null; | |||||
string extension = FormatToExtension(format, iconId); | |||||
return $"{DiscordConfig.CDNUrl}icons/{guildId}/{iconId}.{extension}?size={size}"; | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// Returns a guild splash URL. | /// Returns a guild splash URL. | ||||
/// </summary> | /// </summary> | ||||
@@ -72,7 +72,7 @@ namespace Discord | |||||
/// <returns> | /// <returns> | ||||
/// A URL pointing to the guild's icon; <c>null</c> if none is set. | /// A URL pointing to the guild's icon; <c>null</c> if none is set. | ||||
/// </returns> | /// </returns> | ||||
string IconUrl { get; } | |||||
string GetIconUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128); | |||||
/// <summary> | /// <summary> | ||||
/// Gets the ID of this guild's splash image. | /// Gets the ID of this guild's splash image. | ||||
/// </summary> | /// </summary> | ||||
@@ -59,7 +59,8 @@ namespace Discord.Rest | |||||
[Obsolete("DefaultChannelId is deprecated, use GetDefaultChannelAsync")] | [Obsolete("DefaultChannelId is deprecated, use GetDefaultChannelAsync")] | ||||
public ulong DefaultChannelId => Id; | public ulong DefaultChannelId => Id; | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string IconUrl => CDN.GetGuildIconUrl(Id, IconId); | |||||
public string GetIconUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | |||||
=> CDN.GetGuildIconUrl(Id, IconId, size, format); | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | ||||
@@ -97,7 +97,8 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); | public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); | ||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string IconUrl => CDN.GetGuildIconUrl(Id, IconId); | |||||
public string GetIconUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | |||||
=> CDN.GetGuildIconUrl(Id, IconId, size, format); | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId); | ||||
/// <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> | ||||