Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions packages/discord.js/src/structures/ApplicationCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ export class ApplicationCommand<PermissionsFetchType = {}> 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,
Expand Down