diff --git a/src/structures/Interaction.js b/src/structures/Interaction.js index 7e54a64d040c..1f0567177172 100644 --- a/src/structures/Interaction.js +++ b/src/structures/Interaction.js @@ -74,6 +74,18 @@ class Interaction extends Base { * @type {?Readonly} */ this.memberPermissions = data.member?.permissions ? new Permissions(data.member.permissions).freeze() : null; + + /** + * The locale of the user who invoked this interaction + * @type {string} + */ + this.locale = data.locale; + + /** + * The preferred locale from the guild this interaction was sent in + * @type {?string} + */ + this.guildLocale = data.guild_locale ?? null; } /** diff --git a/typings/index.d.ts b/typings/index.d.ts index ee6e9fa2bdf9..b6adc8950050 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -469,10 +469,9 @@ export type KeyedEnum = { [Key in keyof K]: T | string; }; -export type EnumValueMapped, T extends Partial>> = T & - { - [Key in keyof T as E[Key]]: T[Key]; - }; +export type EnumValueMapped, T extends Partial>> = T & { + [Key in keyof T as E[Key]]: T[Key]; +}; export type MappedChannelCategoryTypes = EnumValueMapped< typeof ChannelTypes, @@ -1330,6 +1329,8 @@ export class Interaction extends Base { public user: User; public version: number; public memberPermissions: CacheTypeReducer>; + public locale: string; + public guildLocale: CacheTypeReducer; public inGuild(): this is Interaction<'present'>; public inCachedGuild(): this is Interaction<'cached'>; public inRawGuild(): this is Interaction<'raw'>; diff --git a/typings/index.test-d.ts b/typings/index.test-d.ts index ccfbc3a3f243..51c99000187d 100644 --- a/typings/index.test-d.ts +++ b/typings/index.test-d.ts @@ -949,12 +949,17 @@ client.on('interactionCreate', async interaction => { expectAssignable(interaction.member); expectNotType>(interaction); expectAssignable(interaction); + expectType(interaction.guildLocale); } else if (interaction.inRawGuild()) { expectAssignable(interaction.member); expectNotAssignable>(interaction); + expectType(interaction.guildLocale); + } else if (interaction.inGuild()) { + expectType(interaction.guildLocale); } else { expectType(interaction.member); expectNotAssignable>(interaction); + expectType(interaction.guildId); } if (interaction.isContextMenu()) {