fix: Add default avatar to WithAuthor extension (#1890)

Adds `??  user.GetDefaultAvatarUrl()` to the avatar icon field.
This commit is contained in:
Quin Lynch
2021-07-10 11:44:32 -03:00
committed by GitHub
parent c5b4b645b8
commit c200861585

View File

@@ -27,7 +27,7 @@ namespace Discord
/// <summary> Fills the embed author field with the provided user's full username and avatar URL. </summary> /// <summary> Fills the embed author field with the provided user's full username and avatar URL. </summary>
public static EmbedBuilder WithAuthor(this EmbedBuilder builder, IUser user) => public static EmbedBuilder WithAuthor(this EmbedBuilder builder, IUser user) =>
builder.WithAuthor($"{user.Username}#{user.Discriminator}", user.GetAvatarUrl()); builder.WithAuthor($"{user.Username}#{user.Discriminator}", user.GetAvatarUrl() ?? user.GetDefaultAvatarUrl());
/// <summary> Converts a <see cref="EmbedType.Rich"/> <see cref="IEmbed"/> object to a <see cref="EmbedBuilder"/>. </summary> /// <summary> Converts a <see cref="EmbedType.Rich"/> <see cref="IEmbed"/> object to a <see cref="EmbedBuilder"/>. </summary>
/// <exception cref="InvalidOperationException">The embed type is not <see cref="EmbedType.Rich"/>.</exception> /// <exception cref="InvalidOperationException">The embed type is not <see cref="EmbedType.Rich"/>.</exception>