feat: Update sendSlash (Attachments)
This commit is contained in:
parent
0c6ba7a211
commit
41f414b13a
@ -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<string>} subCommandArray SubCommand Array
|
||||
* @param {Array<string>} options The options to Slash Command
|
||||
* @param {Array<any>} options The options to Slash Command
|
||||
* @returns {Promise<InteractionResponse>}
|
||||
*/
|
||||
// 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) => {
|
||||
|
@ -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<InteractionResponse>}
|
||||
* @example
|
||||
* // Send Slash to this channel
|
||||
|
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@ -510,7 +510,7 @@ export class ApplicationCommand<PermissionsFetchType = {}> extends Base {
|
||||
public static sendSlashCommand(
|
||||
message: Message,
|
||||
subCommandArray?: string[],
|
||||
options?: string[],
|
||||
options?: any[],
|
||||
): Promise<InteractionResponse>;
|
||||
public static sendContextMenu(message: Message): Promise<InteractionResponse>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user