mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +01:00
refactor!: Remove deprecations (#10647)
refactor: remove deprecations BREAKING CHANGE: `ApplicationCommand#dmPermission` has been removed. Use `ApplicationCommand#contexts` instead. BREAKING CHANGE: `ApplicationCommandData#dmPermission` has been removed. Use `ApplicationCommandData#contexts` instead. BREAKING CHANGE: `ApplicationCommandData#setDMPermission` has been removed. BREAKING CHANGE: `Message#setcon` has been removed. Use `Message#interactionMetadata` instead.
This commit is contained in:
@@ -258,7 +258,6 @@ class ApplicationCommandManager extends CachedManager {
|
|||||||
type: command.type,
|
type: command.type,
|
||||||
options: command.options?.map(option => ApplicationCommand.transformOption(option)),
|
options: command.options?.map(option => ApplicationCommand.transformOption(option)),
|
||||||
default_member_permissions,
|
default_member_permissions,
|
||||||
dm_permission: command.dmPermission ?? command.dm_permission,
|
|
||||||
integration_types: command.integrationTypes ?? command.integration_types,
|
integration_types: command.integrationTypes ?? command.integration_types,
|
||||||
contexts: command.contexts,
|
contexts: command.contexts,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -140,18 +140,6 @@ class ApplicationCommand extends Base {
|
|||||||
this.defaultMemberPermissions ??= null;
|
this.defaultMemberPermissions ??= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('dm_permission' in data) {
|
|
||||||
/**
|
|
||||||
* Whether the command can be used in DMs
|
|
||||||
* <info>This property is always `null` on guild commands</info>
|
|
||||||
* @type {?boolean}
|
|
||||||
* @deprecated Use {@link ApplicationCommand#contexts} instead.
|
|
||||||
*/
|
|
||||||
this.dmPermission = data.dm_permission;
|
|
||||||
} else {
|
|
||||||
this.dmPermission ??= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('integration_types' in data) {
|
if ('integration_types' in data) {
|
||||||
/**
|
/**
|
||||||
* Installation context(s) where the command is available
|
* Installation context(s) where the command is available
|
||||||
@@ -224,7 +212,6 @@ class ApplicationCommand extends Base {
|
|||||||
* @property {ApplicationCommandOptionData[]} [options] Options for the command
|
* @property {ApplicationCommandOptionData[]} [options] Options for the command
|
||||||
* @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions
|
* @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions
|
||||||
* a member needs in order to run the command
|
* a member needs in order to run the command
|
||||||
* @property {boolean} [dmPermission] Whether the command is enabled in DMs
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -341,15 +328,6 @@ class ApplicationCommand extends Base {
|
|||||||
return this.edit({ defaultMemberPermissions });
|
return this.edit({ defaultMemberPermissions });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Edits the DM permission of this ApplicationCommand
|
|
||||||
* @param {boolean} [dmPermission=true] Whether the command can be used in DMs
|
|
||||||
* @returns {Promise<ApplicationCommand>}
|
|
||||||
*/
|
|
||||||
setDMPermission(dmPermission = true) {
|
|
||||||
return this.edit({ dmPermission });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits the options of this ApplicationCommand
|
* Edits the options of this ApplicationCommand
|
||||||
* @param {ApplicationCommandOptionData[]} options The options to set for this command
|
* @param {ApplicationCommandOptionData[]} options The options to set for this command
|
||||||
@@ -386,7 +364,6 @@ class ApplicationCommand extends Base {
|
|||||||
if (command.id && this.id !== command.id) return false;
|
if (command.id && this.id !== command.id) return false;
|
||||||
|
|
||||||
let defaultMemberPermissions = null;
|
let defaultMemberPermissions = null;
|
||||||
let dmPermission = command.dmPermission ?? command.dm_permission;
|
|
||||||
|
|
||||||
if ('default_member_permissions' in command) {
|
if ('default_member_permissions' in command) {
|
||||||
defaultMemberPermissions = command.default_member_permissions
|
defaultMemberPermissions = command.default_member_permissions
|
||||||
@@ -412,7 +389,6 @@ class ApplicationCommand extends Base {
|
|||||||
// TODO: remove ?? 0 on each when nullable
|
// TODO: remove ?? 0 on each when nullable
|
||||||
(command.options?.length ?? 0) !== (this.options?.length ?? 0) ||
|
(command.options?.length ?? 0) !== (this.options?.length ?? 0) ||
|
||||||
defaultMemberPermissions !== (this.defaultMemberPermissions?.bitfield ?? null) ||
|
defaultMemberPermissions !== (this.defaultMemberPermissions?.bitfield ?? null) ||
|
||||||
(dmPermission !== undefined && dmPermission !== this.dmPermission) ||
|
|
||||||
!isEqual(command.nameLocalizations ?? command.name_localizations ?? {}, this.nameLocalizations ?? {}) ||
|
!isEqual(command.nameLocalizations ?? command.name_localizations ?? {}, this.nameLocalizations ?? {}) ||
|
||||||
!isEqual(
|
!isEqual(
|
||||||
command.descriptionLocalizations ?? command.description_localizations ?? {},
|
command.descriptionLocalizations ?? command.description_localizations ?? {},
|
||||||
|
|||||||
@@ -413,33 +413,6 @@ class Message extends Base {
|
|||||||
this.interactionMetadata ??= null;
|
this.interactionMetadata ??= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Partial data of the interaction that a message is a reply to
|
|
||||||
* @typedef {Object} MessageInteraction
|
|
||||||
* @property {Snowflake} id The interaction's id
|
|
||||||
* @property {InteractionType} type The type of the interaction
|
|
||||||
* @property {string} commandName The name of the interaction's application command,
|
|
||||||
* as well as the subcommand and subcommand group, where applicable
|
|
||||||
* @property {User} user The user that invoked the interaction
|
|
||||||
* @deprecated Use {@link Message#interactionMetadata} instead.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (data.interaction) {
|
|
||||||
/**
|
|
||||||
* Partial data of the interaction that this message is a reply to
|
|
||||||
* @type {?MessageInteraction}
|
|
||||||
* @deprecated Use {@link Message#interactionMetadata} instead.
|
|
||||||
*/
|
|
||||||
this.interaction = {
|
|
||||||
id: data.interaction.id,
|
|
||||||
type: data.interaction.type,
|
|
||||||
commandName: data.interaction.name,
|
|
||||||
user: this.client.users._add(data.interaction.user),
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
this.interaction ??= null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.poll) {
|
if (data.poll) {
|
||||||
/**
|
/**
|
||||||
* The poll that was sent with the message
|
* The poll that was sent with the message
|
||||||
|
|||||||
14
packages/discord.js/typings/index.d.ts
vendored
14
packages/discord.js/typings/index.d.ts
vendored
@@ -429,8 +429,6 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
|
|||||||
public description: string;
|
public description: string;
|
||||||
public descriptionLocalizations: LocalizationMap | null;
|
public descriptionLocalizations: LocalizationMap | null;
|
||||||
public descriptionLocalized: string | null;
|
public descriptionLocalized: string | null;
|
||||||
/** @deprecated Use {@link ApplicationCommand.contexts} instead */
|
|
||||||
public dmPermission: boolean | null;
|
|
||||||
public guild: Guild | null;
|
public guild: Guild | null;
|
||||||
public guildId: Snowflake | null;
|
public guildId: Snowflake | null;
|
||||||
public get manager(): ApplicationCommandManager;
|
public get manager(): ApplicationCommandManager;
|
||||||
@@ -460,7 +458,6 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
|
|||||||
public setDefaultMemberPermissions(
|
public setDefaultMemberPermissions(
|
||||||
defaultMemberPermissions: PermissionResolvable | null,
|
defaultMemberPermissions: PermissionResolvable | null,
|
||||||
): Promise<ApplicationCommand<PermissionsFetchType>>;
|
): Promise<ApplicationCommand<PermissionsFetchType>>;
|
||||||
public setDMPermission(dmPermission?: boolean): Promise<ApplicationCommand<PermissionsFetchType>>;
|
|
||||||
public setOptions(
|
public setOptions(
|
||||||
options: readonly ApplicationCommandOptionData[],
|
options: readonly ApplicationCommandOptionData[],
|
||||||
): Promise<ApplicationCommand<PermissionsFetchType>>;
|
): Promise<ApplicationCommand<PermissionsFetchType>>;
|
||||||
@@ -2207,8 +2204,6 @@ export class Message<InGuild extends boolean = boolean> extends Base {
|
|||||||
public get guild(): If<InGuild, Guild>;
|
public get guild(): If<InGuild, Guild>;
|
||||||
public get hasThread(): boolean;
|
public get hasThread(): boolean;
|
||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
/** @deprecated Use {@link Message.interactionMetadata} instead. */
|
|
||||||
public interaction: MessageInteraction | null;
|
|
||||||
public interactionMetadata: MessageInteractionMetadata | null;
|
public interactionMetadata: MessageInteractionMetadata | null;
|
||||||
public get member(): GuildMember | null;
|
public get member(): GuildMember | null;
|
||||||
public mentions: MessageMentions<InGuild>;
|
public mentions: MessageMentions<InGuild>;
|
||||||
@@ -4694,7 +4689,6 @@ export type AllowedThreadTypeForTextChannel = ChannelType.PublicThread | Channel
|
|||||||
export interface BaseApplicationCommandData {
|
export interface BaseApplicationCommandData {
|
||||||
name: string;
|
name: string;
|
||||||
nameLocalizations?: LocalizationMap;
|
nameLocalizations?: LocalizationMap;
|
||||||
dmPermission?: boolean;
|
|
||||||
defaultMemberPermissions?: PermissionResolvable | null;
|
defaultMemberPermissions?: PermissionResolvable | null;
|
||||||
nsfw?: boolean;
|
nsfw?: boolean;
|
||||||
contexts?: readonly InteractionContextType[];
|
contexts?: readonly InteractionContextType[];
|
||||||
@@ -6338,14 +6332,6 @@ export interface MessageInteractionMetadata {
|
|||||||
triggeringInteractionMetadata: MessageInteractionMetadata | null;
|
triggeringInteractionMetadata: MessageInteractionMetadata | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @deprecated Use {@link MessageInteractionMetadata} instead. */
|
|
||||||
export interface MessageInteraction {
|
|
||||||
id: Snowflake;
|
|
||||||
type: InteractionType;
|
|
||||||
commandName: string;
|
|
||||||
user: User;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MessageMentionsHasOptions {
|
export interface MessageMentionsHasOptions {
|
||||||
ignoreDirect?: boolean;
|
ignoreDirect?: boolean;
|
||||||
ignoreRoles?: boolean;
|
ignoreRoles?: boolean;
|
||||||
|
|||||||
@@ -705,7 +705,6 @@ client.on('clientReady', async client => {
|
|||||||
await client.application?.commands.edit(globalCommandId, { defaultMemberPermissions: null });
|
await client.application?.commands.edit(globalCommandId, { defaultMemberPermissions: null });
|
||||||
await globalCommand?.edit({ defaultMemberPermissions: null });
|
await globalCommand?.edit({ defaultMemberPermissions: null });
|
||||||
await globalCommand?.setDefaultMemberPermissions(null);
|
await globalCommand?.setDefaultMemberPermissions(null);
|
||||||
await guildCommandFromGlobal?.edit({ dmPermission: false });
|
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await client.guilds.cache.get(testGuildId)?.commands.fetch(guildCommandId, { guildId: testGuildId });
|
await client.guilds.cache.get(testGuildId)?.commands.fetch(guildCommandId, { guildId: testGuildId });
|
||||||
|
|||||||
Reference in New Issue
Block a user