Moves the implementation of the Flags, PremiumType, and Locale user fields to ISelfUser classes. In testing, it seemed that normal bot accounts did not have this information supplied to them. When tested with a Bearer token in the Rest client, these fields are set.pull/1237/head
@@ -26,6 +26,34 @@ namespace Discord | |||
/// <c>true</c> if this user has enabled multi-factor authentication on their account; <c>false</c> if not. | |||
/// </returns> | |||
bool IsMfaEnabled { get; } | |||
/// <summary> | |||
/// Gets the flags that are applied to a user's account. | |||
/// </summary> | |||
/// <remarks> | |||
/// This value is determined by bitwise OR-ing <see cref="UserProperties"/> values together. | |||
/// </remarks> | |||
/// <returns> | |||
/// The value of flags for this user. | |||
/// </returns> | |||
UserProperties Flags { get; } | |||
/// <summary> | |||
/// Gets the type of Nitro subscription that is active on this user's account. | |||
/// </summary> | |||
/// <remarks> | |||
/// This information may only be available with the identify OAuth scope. | |||
/// </remarks> | |||
/// <returns> | |||
/// The type of Nitro subscription the user subscribes to, if any. | |||
/// </returns> | |||
PremiumType PremiumType { get; } | |||
/// <summary> | |||
/// Gets the user's chosen language option. | |||
/// </summary> | |||
/// <returns> | |||
/// The IETF language tag of the user's chosen region, if provided. | |||
/// For example, a locale of "English, US" is "en-US", "Chinese (Taiwan)" is "zh-TW", etc. | |||
/// </returns> | |||
string Locale { get; } | |||
/// <summary> | |||
/// Modifies the user's properties. | |||
@@ -112,34 +112,5 @@ namespace Discord | |||
/// contains the DM channel associated with this user. | |||
/// </returns> | |||
Task<IDMChannel> GetOrCreateDMChannelAsync(RequestOptions options = null); | |||
/// <summary> | |||
/// Gets the flags that are applied to a user's account. | |||
/// </summary> | |||
/// <remarks> | |||
/// This value is determined by bitwise OR-ing <see cref="UserProperties"/> values together. | |||
/// </remarks> | |||
/// <returns> | |||
/// The value of flags for this user. | |||
/// </returns> | |||
UserProperties Flags { get; } | |||
/// <summary> | |||
/// Gets the type of Nitro subscription that is active on this user's account. | |||
/// </summary> | |||
/// <remarks> | |||
/// This information may only be available with the identify OAuth scope, | |||
/// meaning that users and bots will not have access to this information. | |||
/// </remarks> | |||
/// <returns> | |||
/// The type of Nitro subscription the user subscribes to, or <c>null</c> if this value could not be determined. | |||
/// </returns> | |||
PremiumType? PremiumType { get; } | |||
/// <summary> | |||
/// Gets the user's chosen language option. | |||
/// </summary> | |||
/// <returns> | |||
/// The IETF language tag of the user's chosen region, if provided. | |||
/// For example, a locale of "English, US" is "en-US", "Chinese (Taiwan)" is "zh-TW", etc. | |||
/// </returns> | |||
string Locale { get; } | |||
} | |||
} |
@@ -24,7 +24,7 @@ namespace Discord.API | |||
[JsonProperty("mfa_enabled")] | |||
public Optional<bool> MfaEnabled { get; set; } | |||
[JsonProperty("flags")] | |||
public Optional<int> Flags { get; set; } | |||
public Optional<UserProperties> Flags { get; set; } | |||
[JsonProperty("premium_type")] | |||
public Optional<PremiumType> PremiumType { get; set; } | |||
[JsonProperty("locale")] | |||
@@ -17,6 +17,12 @@ namespace Discord.Rest | |||
public bool IsVerified { get; private set; } | |||
/// <inheritdoc /> | |||
public bool IsMfaEnabled { get; private set; } | |||
/// <inheritdoc /> | |||
public UserProperties Flags { get; private set; } | |||
/// <inheritdoc /> | |||
public PremiumType PremiumType { get; private set; } | |||
/// <inheritdoc /> | |||
public string Locale { get; private set; } | |||
internal RestSelfUser(BaseDiscordClient discord, ulong id) | |||
: base(discord, id) | |||
@@ -39,6 +45,12 @@ namespace Discord.Rest | |||
IsVerified = model.Verified.Value; | |||
if (model.MfaEnabled.IsSpecified) | |||
IsMfaEnabled = model.MfaEnabled.Value; | |||
if (model.Flags.IsSpecified) | |||
Flags = (UserProperties)model.Flags.Value; | |||
if (model.PremiumType.IsSpecified) | |||
PremiumType = model.PremiumType.Value; | |||
if (model.Locale.IsSpecified) | |||
Locale = model.Locale.Value; | |||
} | |||
/// <inheritdoc /> | |||
@@ -32,12 +32,6 @@ namespace Discord.Rest | |||
public virtual UserStatus Status => UserStatus.Offline; | |||
/// <inheritdoc /> | |||
public virtual bool IsWebhook => false; | |||
/// <inheritdoc /> | |||
public UserProperties Flags { get; private set; } | |||
/// <inheritdoc /> | |||
public PremiumType? PremiumType { get; private set; } | |||
/// <inheritdoc /> | |||
public string Locale { get; private set; } | |||
internal RestUser(BaseDiscordClient discord, ulong id) | |||
: base(discord, id) | |||
@@ -65,12 +59,6 @@ namespace Discord.Rest | |||
IsBot = model.Bot.Value; | |||
if (model.Username.IsSpecified) | |||
Username = model.Username.Value; | |||
if (model.Flags.IsSpecified) | |||
Flags = (UserProperties) model.Flags.Value; | |||
if (model.PremiumType.IsSpecified) | |||
PremiumType = model.PremiumType.Value; | |||
if (model.Locale.IsSpecified) | |||
Locale = model.Locale.Value; | |||
} | |||
/// <inheritdoc /> | |||
@@ -30,6 +30,12 @@ namespace Discord.WebSocket | |||
public override string AvatarId { get { return GlobalUser.AvatarId; } internal set { GlobalUser.AvatarId = value; } } | |||
/// <inheritdoc /> | |||
internal override SocketPresence Presence { get { return GlobalUser.Presence; } set { GlobalUser.Presence = value; } } | |||
/// <inheritdoc /> | |||
public UserProperties Flags { get; internal set; } | |||
/// <inheritdoc /> | |||
public PremiumType PremiumType { get; internal set; } | |||
/// <inheritdoc /> | |||
public string Locale { get; internal set; } | |||
/// <inheritdoc /> | |||
public override bool IsWebhook => false; | |||
@@ -63,6 +69,21 @@ namespace Discord.WebSocket | |||
IsMfaEnabled = model.MfaEnabled.Value; | |||
hasGlobalChanges = true; | |||
} | |||
if (model.Flags.IsSpecified && model.Flags.Value != Flags) | |||
{ | |||
Flags = (UserProperties)model.Flags.Value; | |||
hasGlobalChanges = true; | |||
} | |||
if (model.PremiumType.IsSpecified && model.PremiumType.Value != PremiumType) | |||
{ | |||
PremiumType = model.PremiumType.Value; | |||
hasGlobalChanges = true; | |||
} | |||
if (model.Locale.IsSpecified && model.Locale.Value != Locale) | |||
{ | |||
Locale = model.Locale.Value; | |||
hasGlobalChanges = true; | |||
} | |||
return hasGlobalChanges; | |||
} | |||
@@ -38,12 +38,6 @@ namespace Discord.WebSocket | |||
public IActivity Activity => Presence.Activity; | |||
/// <inheritdoc /> | |||
public UserStatus Status => Presence.Status; | |||
/// <inheritdoc /> | |||
public UserProperties Flags { get; internal set; } | |||
/// <inheritdoc /> | |||
public PremiumType? PremiumType { get; internal set; } | |||
/// <inheritdoc /> | |||
public string Locale { get; internal set; } | |||
/// <summary> | |||
/// Gets mutual guilds shared with this user. | |||
/// </summary> | |||
@@ -81,21 +75,6 @@ namespace Discord.WebSocket | |||
Username = model.Username.Value; | |||
hasChanges = true; | |||
} | |||
if (model.Flags.IsSpecified && model.Flags.Value != (int) Flags) | |||
{ | |||
Flags = (UserProperties) model.Flags.Value; | |||
hasChanges = true; | |||
} | |||
if (model.PremiumType.IsSpecified && model.PremiumType.Value != PremiumType) | |||
{ | |||
PremiumType = model.PremiumType.Value; | |||
hasChanges = true; | |||
} | |||
if (model.Locale.IsSpecified && model.Locale.Value != Locale) | |||
{ | |||
Locale = model.Locale.Value; | |||
hasChanges = true; | |||
} | |||
return hasChanges; | |||
} | |||