mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +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
|
* The options of this command
|
||||||
*
|
*
|
||||||
* @type {ApplicationCommandOption[]}
|
* @type {?ApplicationCommandOption[]}
|
||||||
*/
|
*/
|
||||||
this.options = data.options.map(option => this.constructor.transformOption(option, true));
|
this.options = data.options.map(option => this.constructor.transformOption(option, true));
|
||||||
} else {
|
} else {
|
||||||
this.options ??= [];
|
this.options ??= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('default_member_permissions' in data) {
|
if ('default_member_permissions' in data) {
|
||||||
@@ -436,9 +436,7 @@ class ApplicationCommand extends Base {
|
|||||||
('version' in command && command.version !== this.version) ||
|
('version' in command && command.version !== this.version) ||
|
||||||
(command.type && command.type !== this.type) ||
|
(command.type && command.type !== this.type) ||
|
||||||
('nsfw' in command && command.nsfw !== this.nsfw) ||
|
('nsfw' in command && command.nsfw !== this.nsfw) ||
|
||||||
// Future proof for options being nullable
|
command.options?.length !== this.options?.length ||
|
||||||
// TODO: remove ?? 0 on each when nullable
|
|
||||||
(command.options?.length ?? 0) !== (this.options?.length ?? 0) ||
|
|
||||||
defaultMemberPermissions !== (this.defaultMemberPermissions?.bitfield ?? null) ||
|
defaultMemberPermissions !== (this.defaultMemberPermissions?.bitfield ?? null) ||
|
||||||
!isEqual(command.nameLocalizations ?? command.name_localizations ?? {}, this.nameLocalizations ?? {}) ||
|
!isEqual(command.nameLocalizations ?? command.name_localizations ?? {}, this.nameLocalizations ?? {}) ||
|
||||||
!isEqual(
|
!isEqual(
|
||||||
@@ -452,6 +450,7 @@ class ApplicationCommand extends Base {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't need to check both because we already checked the lengths above
|
||||||
if (command.options) {
|
if (command.options) {
|
||||||
return this.constructor.optionsEqual(this.options, command.options, enforceOptionOrder);
|
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 name: string;
|
||||||
public nameLocalizations: LocalizationMap | null;
|
public nameLocalizations: LocalizationMap | null;
|
||||||
public nameLocalized: string | null;
|
public nameLocalized: string | null;
|
||||||
public options: (ApplicationCommandOption & { descriptionLocalized?: string; nameLocalized?: string })[];
|
public options: (ApplicationCommandOption & { descriptionLocalized?: string; nameLocalized?: string })[] | null;
|
||||||
public permissions: ApplicationCommandPermissionsManager<
|
public permissions: ApplicationCommandPermissionsManager<
|
||||||
PermissionsFetchType,
|
PermissionsFetchType,
|
||||||
PermissionsFetchType,
|
PermissionsFetchType,
|
||||||
|
|||||||
Reference in New Issue
Block a user