Skip to content

Commit 8904831

Browse files
committed
fix(ApplicationCommand): remove false positives in equals
This fixes a bug where having a local command that doesn't declare integrationTypes explicitly would cause it to not be equal to the command returned by Discord as they send a default value of [ 0 ] fix: use Object.keys() fix: default to client config and use enum fix: also change default value in this
1 parent 02fbb70 commit 8904831

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/discord.js/src/structures/ApplicationCommand.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const { DiscordSnowflake } = require('@sapphire/snowflake');
4-
const { ApplicationCommandOptionType } = require('discord-api-types/v10');
4+
const { ApplicationCommandOptionType, ApplicationIntegrationType } = require('discord-api-types/v10');
55
const isEqual = require('fast-deep-equal');
66
const { ApplicationCommandPermissionsManager } = require('../managers/ApplicationCommandPermissionsManager.js');
77
const { PermissionsBitField } = require('../util/PermissionsBitField.js');
@@ -445,7 +445,18 @@ class ApplicationCommand extends Base {
445445
command.descriptionLocalizations ?? command.description_localizations ?? {},
446446
this.descriptionLocalizations ?? {},
447447
) ||
448-
!isEqual(command.integrationTypes ?? command.integration_types ?? [], this.integrationTypes ?? []) ||
448+
// [0] is the default value sent by Discord
449+
!isEqual(
450+
command.integrationTypes ??
451+
command.integration_types ??
452+
(this.client.application.integrationTypesConfig
453+
? Object.keys(this.client.application.integrationTypesConfig)
454+
: [ApplicationIntegrationType.GuildInstall]),
455+
this.integrationTypes ??
456+
(this.client.application.integrationTypesConfig
457+
? Object.keys(this.client.application.integrationTypesConfig)
458+
: [ApplicationIntegrationType.GuildInstall]),
459+
) ||
449460
!isEqual(command.contexts ?? [], this.contexts ?? []) ||
450461
('handler' in command && command.handler !== this.handler)
451462
) {

0 commit comments

Comments
 (0)