mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 04:23:31 +01:00
fix(ApplicationCommand): equal nameLocalizations and descriptionLocalizations (#7802)
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
const { ApplicationCommandOptionType } = require('discord-api-types/v10');
|
const { ApplicationCommandOptionType } = require('discord-api-types/v10');
|
||||||
|
const isEqual = require('fast-deep-equal');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
|
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
|
||||||
|
|
||||||
@@ -339,7 +340,12 @@ class ApplicationCommand extends Base {
|
|||||||
// Future proof for options being nullable
|
// Future proof for options being nullable
|
||||||
// TODO: remove ?? 0 on each when nullable
|
// TODO: remove ?? 0 on each when nullable
|
||||||
(command.options?.length ?? 0) !== (this.options?.length ?? 0) ||
|
(command.options?.length ?? 0) !== (this.options?.length ?? 0) ||
|
||||||
(command.defaultPermission ?? command.default_permission ?? true) !== this.defaultPermission
|
(command.defaultPermission ?? command.default_permission ?? true) !== this.defaultPermission ||
|
||||||
|
!isEqual(command.nameLocalizations ?? command.name_localizations ?? {}, this.nameLocalizations ?? {}) ||
|
||||||
|
!isEqual(
|
||||||
|
command.descriptionLocalizations ?? command.description_localizations ?? {},
|
||||||
|
this.descriptionLocalizations ?? {},
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -398,7 +404,12 @@ class ApplicationCommand extends Base {
|
|||||||
option.options?.length !== existing.options?.length ||
|
option.options?.length !== existing.options?.length ||
|
||||||
(option.channelTypes ?? option.channel_types)?.length !== existing.channelTypes?.length ||
|
(option.channelTypes ?? option.channel_types)?.length !== existing.channelTypes?.length ||
|
||||||
(option.minValue ?? option.min_value) !== existing.minValue ||
|
(option.minValue ?? option.min_value) !== existing.minValue ||
|
||||||
(option.maxValue ?? option.max_value) !== existing.maxValue
|
(option.maxValue ?? option.max_value) !== existing.maxValue ||
|
||||||
|
!isEqual(option.nameLocalizations ?? option.name_localizations ?? {}, existing.nameLocalizations ?? {}) ||
|
||||||
|
!isEqual(
|
||||||
|
option.descriptionLocalizations ?? option.description_localizations ?? {},
|
||||||
|
existing.descriptionLocalizations ?? {},
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -407,7 +418,13 @@ class ApplicationCommand extends Base {
|
|||||||
if (
|
if (
|
||||||
enforceOptionOrder &&
|
enforceOptionOrder &&
|
||||||
!existing.choices.every(
|
!existing.choices.every(
|
||||||
(choice, index) => choice.name === option.choices[index].name && choice.value === option.choices[index].value,
|
(choice, index) =>
|
||||||
|
choice.name === option.choices[index].name &&
|
||||||
|
choice.value === option.choices[index].value &&
|
||||||
|
isEqual(
|
||||||
|
choice.nameLocalizations ?? {},
|
||||||
|
option.choices[index].nameLocalizations ?? option.choices[index].name_localizations ?? {},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user