Discord.Net/docs/guides/entities/samples/restentities.cs
2024-06-13 17:43:59 +12:00

8 lines
509 B
C#

// RestUser entities expose the accent color and banner of a user.
// This being one of the few use-cases for requesting a RestUser instead of depending on the Socket counterpart.
public static EmbedBuilder WithUserColor(this EmbedBuilder builder, IUser user)
{
var restUser = await _client.Rest.GetUserAsync(user.Id);
return builder.WithColor(restUser.AccentColor ?? Color.Blue);
// The accent color can still be null, so a check for this needs to be done to prevent an exception to be thrown.
}