feat: Update sendSlash (Attachments)
This commit is contained in:
parent
0c6ba7a211
commit
41f414b13a
@ -3,8 +3,8 @@
|
|||||||
const { setTimeout } = require('node:timers');
|
const { setTimeout } = require('node:timers');
|
||||||
const { findBestMatch } = require('string-similarity');
|
const { findBestMatch } = require('string-similarity');
|
||||||
const Base = require('./Base');
|
const Base = require('./Base');
|
||||||
|
const MessagePayload = require('./MessagePayload');
|
||||||
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
|
const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
|
||||||
const MessageAttachment = require('../structures/MessageAttachment');
|
|
||||||
const {
|
const {
|
||||||
ApplicationCommandOptionTypes,
|
ApplicationCommandOptionTypes,
|
||||||
ApplicationCommandTypes,
|
ApplicationCommandTypes,
|
||||||
@ -12,7 +12,6 @@ const {
|
|||||||
Events,
|
Events,
|
||||||
InteractionTypes,
|
InteractionTypes,
|
||||||
} = require('../util/Constants');
|
} = require('../util/Constants');
|
||||||
const DataResolver = require('../util/DataResolver');
|
|
||||||
const Permissions = require('../util/Permissions');
|
const Permissions = require('../util/Permissions');
|
||||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||||
const { lazy } = require('../util/Util');
|
const { lazy } = require('../util/Util');
|
||||||
@ -602,7 +601,7 @@ class ApplicationCommand extends Base {
|
|||||||
* Send Slash command to channel
|
* Send Slash command to channel
|
||||||
* @param {Message} message Discord Message
|
* @param {Message} message Discord Message
|
||||||
* @param {Array<string>} subCommandArray SubCommand Array
|
* @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>}
|
* @returns {Promise<InteractionResponse>}
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line consistent-return
|
// eslint-disable-next-line consistent-return
|
||||||
@ -786,16 +785,18 @@ class ApplicationCommand extends Base {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
async function addDataFromAttachment(data) {
|
async function addDataFromAttachment(data) {
|
||||||
if (!(data instanceof MessageAttachment)) {
|
const data_ = await MessagePayload.resolveFile(data);
|
||||||
throw new TypeError('The attachment data must be a Discord.MessageAttachment');
|
if (!data_.file) {
|
||||||
|
throw new TypeError(
|
||||||
|
'The attachment data must be a BufferResolvable or Stream or FileOptions of MessageAttachment',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const id = attachments.length;
|
const id = attachments.length;
|
||||||
attachments.push({
|
attachments.push({
|
||||||
id: id,
|
id: id,
|
||||||
filename: data.name,
|
filename: data_.name,
|
||||||
});
|
});
|
||||||
const resource = await DataResolver.resolveFile(data.attachment);
|
attachmentsBuffer.push(data_);
|
||||||
attachmentsBuffer.push({ attachment: data.attachment, name: data.name, file: resource });
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
const getDataPost = (dataAdd = [], nonce, autocomplete = false) => {
|
const getDataPost = (dataAdd = [], nonce, autocomplete = false) => {
|
||||||
|
@ -439,7 +439,7 @@ class TextBasedChannel {
|
|||||||
* Send Slash to this channel
|
* Send Slash to this channel
|
||||||
* @param {UserResolvable} bot Bot user
|
* @param {UserResolvable} bot Bot user
|
||||||
* @param {string} commandString Command name (and sub / group formats)
|
* @param {string} commandString Command name (and sub / group formats)
|
||||||
* @param {...?string|string[]} args Command arguments
|
* @param {...?any|any[]} args Command arguments
|
||||||
* @returns {Promise<InteractionResponse>}
|
* @returns {Promise<InteractionResponse>}
|
||||||
* @example
|
* @example
|
||||||
* // Send Slash to this channel
|
* // 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(
|
public static sendSlashCommand(
|
||||||
message: Message,
|
message: Message,
|
||||||
subCommandArray?: string[],
|
subCommandArray?: string[],
|
||||||
options?: string[],
|
options?: any[],
|
||||||
): Promise<InteractionResponse>;
|
): Promise<InteractionResponse>;
|
||||||
public static sendContextMenu(message: Message): Promise<InteractionResponse>;
|
public static sendContextMenu(message: Message): Promise<InteractionResponse>;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user