added UserDefaultAvatar to IUser (#973)
* added UserDefaultAvatar to IUser * pass ushort as discriminator * removed unneeded ushort.parse
This commit is contained in:
@@ -13,6 +13,10 @@ namespace Discord
|
||||
string extension = FormatToExtension(format, avatarId);
|
||||
return $"{DiscordConfig.CDNUrl}avatars/{userId}/{avatarId}.{extension}?size={size}";
|
||||
}
|
||||
public static string GetDefaultUserAvatarUrl(ushort discriminator)
|
||||
{
|
||||
return $"{DiscordConfig.CDNUrl}embed/avatars/{discriminator % 5}.png";
|
||||
}
|
||||
public static string GetGuildIconUrl(ulong guildId, string iconId)
|
||||
=> iconId != null ? $"{DiscordConfig.CDNUrl}icons/{guildId}/{iconId}.jpg" : null;
|
||||
public static string GetGuildSplashUrl(ulong guildId, string splashId)
|
||||
@@ -37,11 +41,16 @@ namespace Discord
|
||||
format = imageId.StartsWith("a_") ? ImageFormat.Gif : ImageFormat.Png;
|
||||
switch (format)
|
||||
{
|
||||
case ImageFormat.Gif: return "gif";
|
||||
case ImageFormat.Jpeg: return "jpeg";
|
||||
case ImageFormat.Png: return "png";
|
||||
case ImageFormat.WebP: return "webp";
|
||||
default: throw new ArgumentException(nameof(format));
|
||||
case ImageFormat.Gif:
|
||||
return "gif";
|
||||
case ImageFormat.Jpeg:
|
||||
return "jpeg";
|
||||
case ImageFormat.Png:
|
||||
return "png";
|
||||
case ImageFormat.WebP:
|
||||
return "webp";
|
||||
default:
|
||||
throw new ArgumentException(nameof(format));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Discord
|
||||
string AvatarId { get; }
|
||||
/// <summary> Gets the url to this user's avatar. </summary>
|
||||
string GetAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128);
|
||||
/// <summary> Gets the url to this user's default avatar. </summary>
|
||||
string GetDefaultAvatarUrl();
|
||||
/// <summary> Gets the per-username unique id for this user. </summary>
|
||||
string Discriminator { get; }
|
||||
/// <summary> Gets the per-username unique id for this user. </summary>
|
||||
|
||||
Reference in New Issue
Block a user