Compare commits

...

5 Commits

Author SHA1 Message Date
iCrawl
988a51b764 chore(release): version 2022-01-13 18:24:17 +01:00
Rodry
1f4e633ce3 docs(interaction): add locale list link (#7261) 2022-01-13 18:20:35 +01:00
Suneet Tipirneni
233084a601 feat: add Locales to Interactions (#7131)
Co-authored-by: Rodry <38259440+ImRodry@users.noreply.github.com>
2022-01-13 18:18:02 +01:00
iCrawl
ac8c122c2a chore(release): version 2022-01-07 23:57:17 +01:00
ckohen
2dabd82e26 fix(sweepers): provide default for object param (#7182) 2022-01-07 23:53:27 +01:00
7 changed files with 48 additions and 9 deletions

View File

@@ -1,6 +1,26 @@
# Changelog
All notable changes to this project will be documented in this file.
# [13.6.0](https://github.com/discordjs/discord.js/compare/13.5.1...13.6.0) - (2022-01-13)
## Documentation
- **interaction:** Add locale list link (#7261) ([1f4e633](https://github.com/discordjs/discord.js/commit/1f4e633ce3bd0a2398e49d3a9f6eb5ddd5e09ab9))
## Features
- Add Locales to Interactions (#7131) ([233084a](https://github.com/discordjs/discord.js/commit/233084a6018e77b7f9d94446683eef38790ed277))
# [13.5.1](https://github.com/discordjs/discord.js/compare/13.5.0...13.5.1) - (2022-01-07)
## Bug Fixes
- **sweepers:** Provide default for object param (#7182) ([2dabd82](https://github.com/discordjs/discord.js/commit/2dabd82e26134b5050f694f3a9f6524cd3d0c75c))
## Documentation
- **Sweepers:** Fix typo (#7165) ([780b7ed](https://github.com/discordjs/discord.js/commit/780b7ed39f173a77fd9eae396133980826926906))
# [13.5.0](https://github.com/discordjs/discord.js/compare/13.4.0...13.5.0) - (2021-12-29)
## Bug Fixes

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "discord.js",
"version": "14.0.0-dev",
"version": "13.6.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "discord.js",
"version": "14.0.0-dev",
"version": "13.6.0",
"license": "Apache-2.0",
"dependencies": {
"@discordjs/builders": "^0.11.0",

View File

@@ -1,6 +1,6 @@
{
"name": "discord.js",
"version": "14.0.0-dev",
"version": "13.6.0",
"description": "A powerful library for interacting with the Discord API",
"scripts": {
"test": "npm run lint && npm run docs:test && npm run lint:typings && npm run test:typescript",

View File

@@ -74,6 +74,19 @@ class Interaction extends Base {
* @type {?Readonly<Permissions>}
*/
this.memberPermissions = data.member?.permissions ? new Permissions(data.member.permissions).freeze() : null;
/**
* The locale of the user who invoked this interaction
* @type {string}
* @see {@link https://discord.com/developers/docs/dispatch/field-values#predefined-field-values-accepted-locales}
*/
this.locale = data.locale;
/**
* The preferred locale from the guild this interaction was sent in
* @type {?string}
*/
this.guildLocale = data.guild_locale ?? null;
}
/**

View File

@@ -375,11 +375,11 @@ class Sweepers {
* Sweep a direct sub property of all guilds
* @param {string} key The name of the property
* @param {Function} filter Filter function passed to sweep
* @param {SweepEventOptions} [eventOptions] Options for the Client event emitted here
* @param {SweepEventOptions} [eventOptions={}] Options for the Client event emitted here
* @returns {Object} Object containing the number of guilds swept and the number of items swept
* @private
*/
_sweepGuildDirectProp(key, filter, { emit = true, outputName }) {
_sweepGuildDirectProp(key, filter, { emit = true, outputName } = {}) {
if (typeof filter !== 'function') {
throw new TypeError('INVALID_TYPE', 'filter', 'function');
}

9
typings/index.d.ts vendored
View File

@@ -469,10 +469,9 @@ export type KeyedEnum<K, T> = {
[Key in keyof K]: T | string;
};
export type EnumValueMapped<E extends KeyedEnum<T, number>, T extends Partial<Record<keyof E, unknown>>> = T &
{
[Key in keyof T as E[Key]]: T[Key];
};
export type EnumValueMapped<E extends KeyedEnum<T, number>, T extends Partial<Record<keyof E, unknown>>> = T & {
[Key in keyof T as E[Key]]: T[Key];
};
export type MappedChannelCategoryTypes = EnumValueMapped<
typeof ChannelTypes,
@@ -1330,6 +1329,8 @@ export class Interaction<Cached extends CacheType = CacheType> extends Base {
public user: User;
public version: number;
public memberPermissions: CacheTypeReducer<Cached, Readonly<Permissions>>;
public locale: string;
public guildLocale: CacheTypeReducer<Cached, string, string, string>;
public inGuild(): this is Interaction<'present'>;
public inCachedGuild(): this is Interaction<'cached'>;
public inRawGuild(): this is Interaction<'raw'>;

View File

@@ -949,12 +949,17 @@ client.on('interactionCreate', async interaction => {
expectAssignable<GuildMember>(interaction.member);
expectNotType<CommandInteraction<'cached'>>(interaction);
expectAssignable<Interaction>(interaction);
expectType<string>(interaction.guildLocale);
} else if (interaction.inRawGuild()) {
expectAssignable<APIInteractionGuildMember>(interaction.member);
expectNotAssignable<Interaction<'cached'>>(interaction);
expectType<string>(interaction.guildLocale);
} else if (interaction.inGuild()) {
expectType<string>(interaction.guildLocale);
} else {
expectType<APIInteractionGuildMember | GuildMember | null>(interaction.member);
expectNotAssignable<Interaction<'cached'>>(interaction);
expectType<string | null>(interaction.guildId);
}
if (interaction.isContextMenu()) {