mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
feat: Add support for API command types in ApplicationCommandManager (#6621)
This commit is contained in:
@@ -100,7 +100,7 @@ class ApplicationCommandManager extends CachedManager {
|
||||
|
||||
/**
|
||||
* Creates an application command.
|
||||
* @param {ApplicationCommandData} command The command
|
||||
* @param {ApplicationCommandData|APIApplicationCommand} command The command
|
||||
* @param {Snowflake} [guildId] The guild's id to create this command in,
|
||||
* ignored when using a {@link GuildApplicationCommandManager}
|
||||
* @returns {Promise<ApplicationCommand>}
|
||||
@@ -122,7 +122,7 @@ class ApplicationCommandManager extends CachedManager {
|
||||
|
||||
/**
|
||||
* Sets all the commands for this application or guild.
|
||||
* @param {ApplicationCommandData[]} commands The commands
|
||||
* @param {ApplicationCommandData[]|APIApplicationCommand[]} commands The commands
|
||||
* @param {Snowflake} [guildId] The guild's id to create the commands in,
|
||||
* ignored when using a {@link GuildApplicationCommandManager}
|
||||
* @returns {Promise<Collection<Snowflake, ApplicationCommand>>}
|
||||
@@ -155,7 +155,7 @@ class ApplicationCommandManager extends CachedManager {
|
||||
/**
|
||||
* Edits an application command.
|
||||
* @param {ApplicationCommandResolvable} command The command to edit
|
||||
* @param {ApplicationCommandData} data The data to update the command with
|
||||
* @param {ApplicationCommandData|APIApplicationCommand} data The data to update the command with
|
||||
* @param {Snowflake} [guildId] The guild's id where the command registered,
|
||||
* ignored when using a {@link GuildApplicationCommandManager}
|
||||
* @returns {Promise<ApplicationCommand>}
|
||||
@@ -171,7 +171,9 @@ class ApplicationCommandManager extends CachedManager {
|
||||
const id = this.resolveId(command);
|
||||
if (!id) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable');
|
||||
|
||||
const patched = await this.commandPath({ id, guildId }).patch({ data: this.constructor.transformCommand(data) });
|
||||
const patched = await this.commandPath({ id, guildId }).patch({
|
||||
data: this.constructor.transformCommand(data),
|
||||
});
|
||||
return this._add(patched, !guildId, guildId);
|
||||
}
|
||||
|
||||
@@ -200,7 +202,7 @@ class ApplicationCommandManager extends CachedManager {
|
||||
|
||||
/**
|
||||
* Transforms an {@link ApplicationCommandData} object into something that can be used with the API.
|
||||
* @param {ApplicationCommandData} command The command to transform
|
||||
* @param {ApplicationCommandData|APIApplicationCommand} command The command to transform
|
||||
* @returns {APIApplicationCommand}
|
||||
* @private
|
||||
*/
|
||||
@@ -210,7 +212,7 @@ class ApplicationCommandManager extends CachedManager {
|
||||
description: command.description,
|
||||
type: typeof command.type === 'number' ? command.type : ApplicationCommandTypes[command.type],
|
||||
options: command.options?.map(o => ApplicationCommand.transformOption(o)),
|
||||
default_permission: command.defaultPermission,
|
||||
default_permission: command.defaultPermission ?? command.default_permission,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user