Browse Source

Add locale property to the user model

adds the locale property to the user model, which appears not to be
specified for bots
pull/1237/head
Chris Johnston 6 years ago
parent
commit
bbfd2adf6c
4 changed files with 20 additions and 0 deletions
  1. +7
    -0
      src/Discord.Net.Core/Entities/Users/IUser.cs
  2. +2
    -0
      src/Discord.Net.Rest/API/Common/User.cs
  3. +4
    -0
      src/Discord.Net.Rest/Entities/Users/RestUser.cs
  4. +7
    -0
      src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs

+ 7
- 0
src/Discord.Net.Core/Entities/Users/IUser.cs View File

@@ -134,5 +134,12 @@ namespace Discord
/// The type of Nitro subscription the user subscribes to, or null if this value could not be determined. /// The type of Nitro subscription the user subscribes to, or null if this value could not be determined.
/// </returns> /// </returns>
PremiumType? PremiumType { get; } PremiumType? PremiumType { get; }
/// <summary>
/// The user's chosen language option.
/// </summary>
/// <returns>
/// The value of the user's chosen language option, if provided.
/// </returns>
string Locale { get; }
} }
} }

+ 2
- 0
src/Discord.Net.Rest/API/Common/User.cs View File

@@ -27,5 +27,7 @@ namespace Discord.API
public Optional<int> Flags { get; set; } public Optional<int> Flags { get; set; }
[JsonProperty("premium_type")] [JsonProperty("premium_type")]
public Optional<PremiumType> PremiumType { get; set; } public Optional<PremiumType> PremiumType { get; set; }
[JsonProperty("locale")]
public Optional<string> Locale { get; set; }
} }
} }

+ 4
- 0
src/Discord.Net.Rest/Entities/Users/RestUser.cs View File

@@ -36,6 +36,8 @@ namespace Discord.Rest
public int Flags { get; private set; } public int Flags { get; private set; }
/// <inheritdoc /> /// <inheritdoc />
public PremiumType? PremiumType { get; private set; } public PremiumType? PremiumType { get; private set; }
/// <inheritdoc />
public string Locale { get; private set; }


internal RestUser(BaseDiscordClient discord, ulong id) internal RestUser(BaseDiscordClient discord, ulong id)
: base(discord, id) : base(discord, id)
@@ -67,6 +69,8 @@ namespace Discord.Rest
Flags = model.Flags.Value; Flags = model.Flags.Value;
if (model.PremiumType.IsSpecified) if (model.PremiumType.IsSpecified)
PremiumType = model.PremiumType.Value; PremiumType = model.PremiumType.Value;
if (model.Locale.IsSpecified)
Locale = model.Locale.Value;
} }


/// <inheritdoc /> /// <inheritdoc />


+ 7
- 0
src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs View File

@@ -42,6 +42,8 @@ namespace Discord.WebSocket
public int Flags { get; internal set; } public int Flags { get; internal set; }
/// <inheritdoc /> /// <inheritdoc />
public PremiumType? PremiumType { get; internal set; } public PremiumType? PremiumType { get; internal set; }
/// <inheritdoc />
public string Locale { get; internal set; }
/// <summary> /// <summary>
/// Gets mutual guilds shared with this user. /// Gets mutual guilds shared with this user.
/// </summary> /// </summary>
@@ -89,6 +91,11 @@ namespace Discord.WebSocket
PremiumType = model.PremiumType.Value; PremiumType = model.PremiumType.Value;
hasChanges = true; hasChanges = true;
} }
if (model.Locale.IsSpecified && model.Locale.Value != Locale)
{
Locale = model.Locale.Value;
hasChanges = true;
}
return hasChanges; return hasChanges;
} }




Loading…
Cancel
Save