diff --git a/packages/discord.js/src/structures/ApplicationCommand.js b/packages/discord.js/src/structures/ApplicationCommand.js index e78e4ecad12c..2f99c1ca92e0 100644 --- a/packages/discord.js/src/structures/ApplicationCommand.js +++ b/packages/discord.js/src/structures/ApplicationCommand.js @@ -136,11 +136,11 @@ class ApplicationCommand extends Base { /** * The options of this command * - * @type {ApplicationCommandOption[]} + * @type {?ApplicationCommandOption[]} */ this.options = data.options.map(option => this.constructor.transformOption(option, true)); } else { - this.options ??= []; + this.options ??= null; } if ('default_member_permissions' in data) { @@ -436,9 +436,7 @@ class ApplicationCommand extends Base { ('version' in command && command.version !== this.version) || (command.type && command.type !== this.type) || ('nsfw' in command && command.nsfw !== this.nsfw) || - // Future proof for options being nullable - // TODO: remove ?? 0 on each when nullable - (command.options?.length ?? 0) !== (this.options?.length ?? 0) || + command.options?.length !== this.options?.length || defaultMemberPermissions !== (this.defaultMemberPermissions?.bitfield ?? null) || !isEqual(command.nameLocalizations ?? command.name_localizations ?? {}, this.nameLocalizations ?? {}) || !isEqual( @@ -452,6 +450,7 @@ class ApplicationCommand extends Base { return false; } + // Don't need to check both because we already checked the lengths above if (command.options) { return this.constructor.optionsEqual(this.options, command.options, enforceOptionOrder); } diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 7d95a19e3e39..3468a855cb90 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -417,7 +417,7 @@ export class ApplicationCommand extends Base { public name: string; public nameLocalizations: LocalizationMap | null; public nameLocalized: string | null; - public options: (ApplicationCommandOption & { descriptionLocalized?: string; nameLocalized?: string })[]; + public options: (ApplicationCommandOption & { descriptionLocalized?: string; nameLocalized?: string })[] | null; public permissions: ApplicationCommandPermissionsManager< PermissionsFetchType, PermissionsFetchType,