From bbfd2adf6cea48dca256f29e614ddde434edf51a Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Sat, 12 Jan 2019 09:54:15 -0800 Subject: [PATCH] Add locale property to the user model adds the locale property to the user model, which appears not to be specified for bots --- src/Discord.Net.Core/Entities/Users/IUser.cs | 7 +++++++ src/Discord.Net.Rest/API/Common/User.cs | 2 ++ src/Discord.Net.Rest/Entities/Users/RestUser.cs | 4 ++++ src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs | 7 +++++++ 4 files changed, 20 insertions(+) diff --git a/src/Discord.Net.Core/Entities/Users/IUser.cs b/src/Discord.Net.Core/Entities/Users/IUser.cs index 6f78a5ab9..2ad23a518 100644 --- a/src/Discord.Net.Core/Entities/Users/IUser.cs +++ b/src/Discord.Net.Core/Entities/Users/IUser.cs @@ -134,5 +134,12 @@ namespace Discord /// The type of Nitro subscription the user subscribes to, or null if this value could not be determined. /// PremiumType? PremiumType { get; } + /// + /// The user's chosen language option. + /// + /// + /// The value of the user's chosen language option, if provided. + /// + string Locale { get; } } } diff --git a/src/Discord.Net.Rest/API/Common/User.cs b/src/Discord.Net.Rest/API/Common/User.cs index 1a124ea6e..e1a5d2915 100644 --- a/src/Discord.Net.Rest/API/Common/User.cs +++ b/src/Discord.Net.Rest/API/Common/User.cs @@ -27,5 +27,7 @@ namespace Discord.API public Optional Flags { get; set; } [JsonProperty("premium_type")] public Optional PremiumType { get; set; } + [JsonProperty("locale")] + public Optional Locale { get; set; } } } diff --git a/src/Discord.Net.Rest/Entities/Users/RestUser.cs b/src/Discord.Net.Rest/Entities/Users/RestUser.cs index 4b3d90002..7d9f8a4b7 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestUser.cs @@ -36,6 +36,8 @@ namespace Discord.Rest public int Flags { get; private set; } /// public PremiumType? PremiumType { get; private set; } + /// + public string Locale { get; private set; } internal RestUser(BaseDiscordClient discord, ulong id) : base(discord, id) @@ -67,6 +69,8 @@ namespace Discord.Rest Flags = model.Flags.Value; if (model.PremiumType.IsSpecified) PremiumType = model.PremiumType.Value; + if (model.Locale.IsSpecified) + Locale = model.Locale.Value; } /// diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs index b48f52947..be64c2db0 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs @@ -42,6 +42,8 @@ namespace Discord.WebSocket public int Flags { get; internal set; } /// public PremiumType? PremiumType { get; internal set; } + /// + public string Locale { get; internal set; } /// /// Gets mutual guilds shared with this user. /// @@ -89,6 +91,11 @@ namespace Discord.WebSocket PremiumType = model.PremiumType.Value; hasChanges = true; } + if (model.Locale.IsSpecified && model.Locale.Value != Locale) + { + Locale = model.Locale.Value; + hasChanges = true; + } return hasChanges; }