[Feature] Support for the new username system (#2696)
* update a lot of stuff * update CDN for new avatar calculation * whoops, forgot to commit * handle `null` values * Remove duplicate line Co-authored-by: Dmitry <dimson-n@users.noreply.github.com> * updates * Apply suggestions from code review Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com> * Apply suggestion Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com> * update `SocketThreadUSer` --------- Co-authored-by: Dmitry <dimson-n@users.noreply.github.com> Co-authored-by: Quin Lynch <49576606+quinchs@users.noreply.github.com>
This commit is contained in:
@@ -30,6 +30,8 @@ namespace Discord.Rest
|
||||
public Color? AccentColor { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public UserProperties? PublicFlags { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public string GlobalName { get; internal set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
||||
@@ -85,13 +87,15 @@ namespace Discord.Rest
|
||||
if (model.AccentColor.IsSpecified)
|
||||
AccentColor = model.AccentColor.Value;
|
||||
if (model.Discriminator.IsSpecified)
|
||||
DiscriminatorValue = ushort.Parse(model.Discriminator.Value, NumberStyles.None, CultureInfo.InvariantCulture);
|
||||
DiscriminatorValue = ushort.Parse(model.Discriminator.GetValueOrDefault(null) ?? "0", NumberStyles.None, CultureInfo.InvariantCulture);
|
||||
if (model.Bot.IsSpecified)
|
||||
IsBot = model.Bot.Value;
|
||||
if (model.Username.IsSpecified)
|
||||
Username = model.Username.Value;
|
||||
if (model.PublicFlags.IsSpecified)
|
||||
PublicFlags = model.PublicFlags.Value;
|
||||
if (model.GlobalName.IsSpecified)
|
||||
GlobalName = model.GlobalName.Value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -121,7 +125,9 @@ namespace Discord.Rest
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GetDefaultAvatarUrl()
|
||||
=> CDN.GetDefaultUserAvatarUrl(DiscriminatorValue);
|
||||
=> DiscriminatorValue != 0
|
||||
? CDN.GetDefaultUserAvatarUrl(DiscriminatorValue)
|
||||
: CDN.GetDefaultUserAvatarUrl(Id);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Username#Discriminator of the user.
|
||||
|
||||
Reference in New Issue
Block a user