diff --git a/src/structures/ApplicationCommand.js b/src/structures/ApplicationCommand.js index 24c4231..5ca66a8 100644 --- a/src/structures/ApplicationCommand.js +++ b/src/structures/ApplicationCommand.js @@ -3,8 +3,8 @@ const { setTimeout } = require('node:timers'); const { findBestMatch } = require('string-similarity'); const Base = require('./Base'); +const MessagePayload = require('./MessagePayload'); const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager'); -const MessageAttachment = require('../structures/MessageAttachment'); const { ApplicationCommandOptionTypes, ApplicationCommandTypes, @@ -12,7 +12,6 @@ const { Events, InteractionTypes, } = require('../util/Constants'); -const DataResolver = require('../util/DataResolver'); const Permissions = require('../util/Permissions'); const SnowflakeUtil = require('../util/SnowflakeUtil'); const { lazy } = require('../util/Util'); @@ -602,7 +601,7 @@ class ApplicationCommand extends Base { * Send Slash command to channel * @param {Message} message Discord Message * @param {Array} subCommandArray SubCommand Array - * @param {Array} options The options to Slash Command + * @param {Array} options The options to Slash Command * @returns {Promise} */ // eslint-disable-next-line consistent-return @@ -786,16 +785,18 @@ class ApplicationCommand extends Base { }; }; async function addDataFromAttachment(data) { - if (!(data instanceof MessageAttachment)) { - throw new TypeError('The attachment data must be a Discord.MessageAttachment'); + const data_ = await MessagePayload.resolveFile(data); + if (!data_.file) { + throw new TypeError( + 'The attachment data must be a BufferResolvable or Stream or FileOptions of MessageAttachment', + ); } const id = attachments.length; attachments.push({ id: id, - filename: data.name, + filename: data_.name, }); - const resource = await DataResolver.resolveFile(data.attachment); - attachmentsBuffer.push({ attachment: data.attachment, name: data.name, file: resource }); + attachmentsBuffer.push(data_); return id; } const getDataPost = (dataAdd = [], nonce, autocomplete = false) => { diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index 7c29876..bf77efa 100644 --- a/src/structures/interfaces/TextBasedChannel.js +++ b/src/structures/interfaces/TextBasedChannel.js @@ -439,7 +439,7 @@ class TextBasedChannel { * Send Slash to this channel * @param {UserResolvable} bot Bot user * @param {string} commandString Command name (and sub / group formats) - * @param {...?string|string[]} args Command arguments + * @param {...?any|any[]} args Command arguments * @returns {Promise} * @example * // Send Slash to this channel diff --git a/typings/index.d.ts b/typings/index.d.ts index 430802b..eb54ff8 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -510,7 +510,7 @@ export class ApplicationCommand extends Base { public static sendSlashCommand( message: Message, subCommandArray?: string[], - options?: string[], + options?: any[], ): Promise; public static sendContextMenu(message: Message): Promise; }