| @@ -6,7 +6,9 @@ namespace Discord | |||||
| { | { | ||||
| public static string GetApplicationIconUrl(ulong appId, string iconId) | public static string GetApplicationIconUrl(ulong appId, string iconId) | ||||
| => iconId != null ? $"{DiscordConfig.CDNUrl}app-icons/{appId}/{iconId}.jpg" : null; | => iconId != null ? $"{DiscordConfig.CDNUrl}app-icons/{appId}/{iconId}.jpg" : null; | ||||
| public static string GetUserAvatarUrl(ulong userId, string avatarId, ushort size, ImageFormat format) | |||||
| public static string GetUserDefaultAvatarUrl(ushort discriminator) | |||||
| => $"{DiscordConfig.CDNUrl}embed/avatars/{discriminator % 5}.png"; | |||||
| public static string GetUserCustomAvatarUrl(ulong userId, string avatarId, ushort size, ImageFormat format) | |||||
| { | { | ||||
| if (avatarId == null) | if (avatarId == null) | ||||
| return null; | return null; | ||||
| @@ -6,7 +6,11 @@ namespace Discord | |||||
| { | { | ||||
| /// <summary> Gets the id of this user's avatar. </summary> | /// <summary> Gets the id of this user's avatar. </summary> | ||||
| string AvatarId { get; } | string AvatarId { get; } | ||||
| /// <summary> Gets the url to this user's avatar. </summary> | |||||
| /// <summary> Gets the url to this user's default avatar. </summary> | |||||
| string GetDefaultAvatarUrl(); | |||||
| /// <summary> Gets the url to this user's custom avatar, if set. </summary> | |||||
| string GetCustomAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128); | |||||
| /// <summary> Gets the url to this user's custom or default avatar depending on which is available. NOTE: Ignores format and size if there is no custom avatar. </summary> | |||||
| string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128); | string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128); | ||||
| /// <summary> Gets the url to this user's default avatar. </summary> | /// <summary> Gets the url to this user's default avatar. </summary> | ||||
| string GetDefaultAvatarUrl(); | string GetDefaultAvatarUrl(); | ||||
| @@ -57,8 +57,12 @@ namespace Discord.Rest | |||||
| public Task<RestDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null) | public Task<RestDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null) | ||||
| => UserHelper.CreateDMChannelAsync(this, Discord, options); | => UserHelper.CreateDMChannelAsync(this, Discord, options); | ||||
| public string GetDefaultAvatarUrl() | |||||
| => CDN.GetUserDefaultAvatarUrl(DiscriminatorValue); | |||||
| public string GetCustomAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | |||||
| => CDN.GetUserCustomAvatarUrl(Id, AvatarId, size, format); | |||||
| public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | ||||
| => CDN.GetUserAvatarUrl(Id, AvatarId, size, format); | |||||
| => GetCustomAvatarUrl(format, size) ?? GetDefaultAvatarUrl(); | |||||
| public string GetDefaultAvatarUrl() | public string GetDefaultAvatarUrl() | ||||
| => CDN.GetDefaultUserAvatarUrl(DiscriminatorValue); | => CDN.GetDefaultUserAvatarUrl(DiscriminatorValue); | ||||
| @@ -1,4 +1,4 @@ | |||||
| using System; | |||||
| using System; | |||||
| using System.Diagnostics; | using System.Diagnostics; | ||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| using Model = Discord.API.Webhook; | using Model = Discord.API.Webhook; | ||||
| @@ -66,7 +66,7 @@ namespace Discord.Rest | |||||
| } | } | ||||
| public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | ||||
| => CDN.GetUserAvatarUrl(Id, AvatarId, size, format); | |||||
| => CDN.GetUserCustomAvatarUrl(Id, AvatarId, size, format); | |||||
| public async Task ModifyAsync(Action<WebhookProperties> func, RequestOptions options = null) | public async Task ModifyAsync(Action<WebhookProperties> func, RequestOptions options = null) | ||||
| { | { | ||||
| @@ -58,8 +58,12 @@ namespace Discord.WebSocket | |||||
| public async Task<IDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null) | public async Task<IDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null) | ||||
| => GlobalUser.DMChannel ?? await UserHelper.CreateDMChannelAsync(this, Discord, options) as IDMChannel; | => GlobalUser.DMChannel ?? await UserHelper.CreateDMChannelAsync(this, Discord, options) as IDMChannel; | ||||
| public string GetDefaultAvatarUrl() | |||||
| => CDN.GetUserDefaultAvatarUrl(DiscriminatorValue); | |||||
| public string GetCustomAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | |||||
| => CDN.GetUserCustomAvatarUrl(Id, AvatarId, size, format); | |||||
| public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | ||||
| => CDN.GetUserAvatarUrl(Id, AvatarId, size, format); | |||||
| => GetCustomAvatarUrl(format, size) ?? GetDefaultAvatarUrl(); | |||||
| public string GetDefaultAvatarUrl() | public string GetDefaultAvatarUrl() | ||||
| => CDN.GetDefaultUserAvatarUrl(DiscriminatorValue); | => CDN.GetDefaultUserAvatarUrl(DiscriminatorValue); | ||||
| @@ -1,4 +1,4 @@ | |||||
| using System; | |||||
| using System; | |||||
| using System.Diagnostics; | using System.Diagnostics; | ||||
| using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
| using Model = Discord.API.Webhook; | using Model = Discord.API.Webhook; | ||||
| @@ -45,7 +45,7 @@ namespace Discord.Webhook | |||||
| } | } | ||||
| public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | public string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) | ||||
| => CDN.GetUserAvatarUrl(Id, AvatarId, size, format); | |||||
| => CDN.GetUserCustomAvatarUrl(Id, AvatarId, size, format); | |||||
| public async Task ModifyAsync(Action<WebhookProperties> func, RequestOptions options = null) | public async Task ModifyAsync(Action<WebhookProperties> func, RequestOptions options = null) | ||||
| { | { | ||||