diff --git a/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs b/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs index 064d3c4da..8ac08f842 100644 --- a/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs +++ b/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs @@ -49,6 +49,19 @@ namespace Discord /// IUser User { get; } + /// + /// The preferred locale of the invoking User. + /// + string UserLocale { get; } + + /// + /// The preferred locale of the guild this interaction was executed in. if not executed in a guild. + /// + /// + /// Non-community guilds (With no locale setting available) will have en-US as the default value sent by Discord. + /// + string GuildLocale { get; } + /// /// Responds to an Interaction with type . /// diff --git a/src/Discord.Net.Rest/API/Common/Interaction.cs b/src/Discord.Net.Rest/API/Common/Interaction.cs index 7f953384d..1ca08a0f7 100644 --- a/src/Discord.Net.Rest/API/Common/Interaction.cs +++ b/src/Discord.Net.Rest/API/Common/Interaction.cs @@ -37,5 +37,11 @@ namespace Discord.API [JsonProperty("message")] public Optional Message { get; set; } + + [JsonProperty("locale")] + public Optional UserLocale { get; set; } + + [JsonProperty("guild_locale")] + public Optional GuildLocale { get; set; } } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs b/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs index de1fdb7c4..c4d66c642 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/RestInteraction.cs @@ -32,6 +32,12 @@ namespace Discord.Rest /// public RestUser User { get; private set; } + /// + public string UserLocale { get; private set; } + + /// + public string GuildLocale { get; private set; } + /// public DateTimeOffset CreatedAt { get; private set; } @@ -126,6 +132,13 @@ namespace Discord.Rest { Channel = (IRestMessageChannel)await discord.GetChannelAsync(model.ChannelId.Value); } + + UserLocale = model.UserLocale.IsSpecified + ? model.UserLocale.Value + : null; + GuildLocale = model.GuildLocale.IsSpecified + ? model.GuildLocale.Value + : null; } internal string SerializePayload(object payload) diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs index 8250b6825..b53739553 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs @@ -39,6 +39,12 @@ namespace Discord.WebSocket /// public IDiscordInteractionData Data { get; private set; } + /// + public string UserLocale { get; private set; } + + /// + public string GuildLocale { get; private set; } + /// /// The version of this interaction. /// @@ -121,6 +127,13 @@ namespace Discord.WebSocket User = SocketGlobalUser.Create(Discord, Discord.State, model.User.Value); } } + + UserLocale = model.UserLocale.IsSpecified + ? model.UserLocale.Value + : null; + GuildLocale = model.GuildLocale.IsSpecified + ? model.GuildLocale.Value + : null; } ///