From 1a656854c0eee78e9496e4fd610579cbc3ffc606 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Wed, 6 Jul 2022 19:40:11 +0700 Subject: [PATCH] fix(applicationcommandmanager): explicitly allow passing builders to methods (v13) v13.9 #8229 --- src/managers/ApplicationCommandManager.js | 25 +++++++++++++++++++---- typings/index.d.ts | 15 +++++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/managers/ApplicationCommandManager.js b/src/managers/ApplicationCommandManager.js index 6f700f1..58f6298 100644 --- a/src/managers/ApplicationCommandManager.js +++ b/src/managers/ApplicationCommandManager.js @@ -55,6 +55,13 @@ class ApplicationCommandManager extends CachedManager { * @typedef {ApplicationCommand|Snowflake} ApplicationCommandResolvable */ + /* eslint-disable max-len */ + /** + * Data that resolves to the data of an ApplicationCommand + * @typedef {ApplicationCommandDataResolvable|SlashCommandBuilder|ContextMenuCommandBuilder} ApplicationCommandDataResolvable + */ + /* eslint-enable max-len */ + /** * Options used to fetch data from Discord * @typedef {Object} BaseFetchOptions @@ -111,7 +118,7 @@ class ApplicationCommandManager extends CachedManager { /** * Creates an application command. - * @param {ApplicationCommandData|APIApplicationCommand} command The command + * @param {ApplicationCommandDataResolvable} command The command * @param {Snowflake} [guildId] The guild's id to create this command in, * ignored when using a {@link GuildApplicationCommandManager} * @returns {Promise} @@ -134,7 +141,7 @@ class ApplicationCommandManager extends CachedManager { /** * Sets all the commands for this application or guild. - * @param {ApplicationCommandData[]|APIApplicationCommand[]} commands The commands + * @param {ApplicationCommandDataResolvable[]} commands The commands * @param {Snowflake} [guildId] The guild's id to create the commands in, * ignored when using a {@link GuildApplicationCommandManager} * @returns {Promise>} @@ -165,7 +172,7 @@ class ApplicationCommandManager extends CachedManager { /** * Edits an application command. * @param {ApplicationCommandResolvable} command The command to edit - * @param {Partial} data The data to update the command with + * @param {Partial} 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} @@ -214,7 +221,7 @@ class ApplicationCommandManager extends CachedManager { /** * Transforms an {@link ApplicationCommandData} object into something that can be used with the API. - * @param {ApplicationCommandData|APIApplicationCommand} command The command to transform + * @param {ApplicationCommandDataResolvable} command The command to transform * @returns {APIApplicationCommand} * @private */ @@ -247,3 +254,13 @@ class ApplicationCommandManager extends CachedManager { } module.exports = ApplicationCommandManager; + +/** + * @external SlashCommandBuilder + * @see {@link https://discord.js.org/#/docs/builders/main/class/SlashCommandBuilder} + */ + +/** + * @external ContextMenuCommandBuilder + * @see {@link https://discord.js.org/#/docs/builders/main/class/ContextMenuCommandBuilder} + */ diff --git a/typings/index.d.ts b/typings/index.d.ts index c16021e..3bb277b 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3,13 +3,16 @@ import { bold, channelMention, codeBlock, + ContextMenuCommandBuilder, formatEmoji, hideLinkEmbed, hyperlink, inlineCode, italic, + JSONEncodable, quote, roleMention, + SlashCommandBuilder, spoiler, strikethrough, time, @@ -3208,7 +3211,11 @@ export abstract class CachedManager extends DataManager, @@ -3251,9 +3258,7 @@ export class ApplicationCommandManager< commands: ApplicationCommandDataResolvable[], guildId: Snowflake, ): Promise>; - private static transformCommand( - command: ApplicationCommandData, - ): Omit; + private static transformCommand(command: ApplicationCommandDataResolvable): RESTPostAPIApplicationCommandsJSONBody; } export class ApplicationCommandPermissionsManager< @@ -3369,7 +3374,7 @@ export class GuildApplicationCommandManager extends ApplicationCommandManager; public edit( command: ApplicationCommandResolvable, - data: ApplicationCommandDataResolvable, + data: Partial, ): Promise; public fetch(id: Snowflake, options?: FetchGuildApplicationCommandFetchOptions): Promise; public fetch(options: FetchGuildApplicationCommandFetchOptions): Promise>;