mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 08:03:30 +01:00
refactor(ApplicationCommand)!: make options nullable (#11167)
BREAKING CHANGE: ApplicationCommand#options is now nullable Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
2
packages/discord.js/typings/index.d.ts
vendored
2
packages/discord.js/typings/index.d.ts
vendored
@@ -419,7 +419,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,
|
||||
|
||||
Reference in New Issue
Block a user