From 5733526bcc4241b9411f6b5fc7c6514f54c9eddd Mon Sep 17 00:00:00 2001 From: POPPIN-FUMI Date: Mon, 13 Nov 2023 17:57:00 +0100 Subject: [PATCH] update deployCommands type --- src/index.ts | 7 ++++++- src/lib/deployCommands.ts | 36 +++++++++++++++--------------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/index.ts b/src/index.ts index f4131da..7633213 100755 --- a/src/index.ts +++ b/src/index.ts @@ -30,4 +30,9 @@ export { ButtonStyleTypes, MessageComponentTypes, } from 'discord-interactions' -export { ComponentType, TextInputStyle, ButtonStyle } from 'discord.js' +export { + ComponentType, + TextInputStyle, + ButtonStyle, + SlashCommandBuilder, +} from 'discord.js' diff --git a/src/lib/deployCommands.ts b/src/lib/deployCommands.ts index 1bb71fc..94dbb03 100644 --- a/src/lib/deployCommands.ts +++ b/src/lib/deployCommands.ts @@ -1,5 +1,5 @@ -import { REST, Routes, ApplicationCommandData } from 'discord.js' - +import { REST, Routes } from 'discord.js' +import { SlashCommandBuilder } from 'discord.js' /** * Deploys application commands to a specific guild. * @@ -9,37 +9,31 @@ import { REST, Routes, ApplicationCommandData } from 'discord.js' * @param {string} token - The token used for authentication with the Discord API. * @param {string} discordClientId - The Discord client ID. * @param {string} guildId - The ID of the guild where commands are being deployed. - * @param {ApplicationCommandData[]} commands - An array of ApplicationCommandData representing the commands to be deployed. + * @param { SlashCommandBuilder[]} commands - An array of SlashCommandBuilder representing the commands to be deployed. * @returns {Promise} A promise that resolves when commands are successfully deployed. * @throws {Error} Will throw an error if there is a problem with the deployment. * * @example * ```typescript - * import { config } from 'dotenv' - * config() - * const run = async () => { - * const token = process.env.DISCORD_TOKEN || '' - * const discordClientId = process.env.DISCORD_CLIENT_ID || '' - * const guildId = process.env.DISCORD_GUILD_ID || '' + * import { commands } from "./commands"; + * import { deployCommands } from "@skeet-framework/discord-utils"; + * import { DISCORD_APPLICATION_ID, DISCORD_GUILD_ID } from "../config"; * - * const commands = [ - * { - * name: 'ping', - * description: 'Replies with pong', - * }, - * ] + * const commandsData = Object.values(commands).map((command) => command.data); * + * const run = async () => { + * const token = process.argv[2] || ''; * try { - * await deployCommands(token, discordClientId, guildId, commands) - * console.log('Commands deployed successfully.') + * await deployCommands(token, DISCORD_APPLICATION_ID, DISCORD_GUILD_ID, commandsData); + * console.log('Commands deployed successfully.'); * } catch (error) { - * console.error(`Error deploying commands: ${error}`) + * console.error(`Error deploying commands: ${error}`); * } - * } + * }; * * run() * .then(() => console.log('Done')) - * .catch((error) => console.error(error)) + * .catch((error) => console.error(error)); * ``` */ @@ -47,7 +41,7 @@ export async function deployCommands( token: string, discordClientId: string, guildId: string, - commands: ApplicationCommandData[], + commands: SlashCommandBuilder[], ): Promise { try { console.log('Started refreshing application (/) commands.')