fix(Event): name

This commit is contained in:
March 7th 2022-06-14 08:48:06 +07:00
parent 72238015f9
commit 83c809cc32
8 changed files with 25 additions and 35 deletions

File diff suppressed because one or more lines are too long

View File

@ -4,8 +4,8 @@ const { Events } = require('../../../util/Constants');
module.exports = (client, { d: data }) => { module.exports = (client, { d: data }) => {
/** /**
* Emitted whenever client user send interaction and error * Emitted whenever client user send interaction and error
* @event Client#interactionFailed * @event Client#interactionFailure
* @param {InteractionResponseBody} data data * @param {InteractionResponseBody} data data
*/ */
client.emit(Events.INTERACTION_FAILED, data); client.emit(Events.INTERACTION_FAILURE, data);
}; };

View File

@ -56,7 +56,7 @@ const handlers = Object.fromEntries([
['INTERACTION_CREATE', require('./INTERACTION_CREATE')], ['INTERACTION_CREATE', require('./INTERACTION_CREATE')],
['INTERACTION_SUCCESS', require('./INTERACTION_SUCCESS')], ['INTERACTION_SUCCESS', require('./INTERACTION_SUCCESS')],
['INTERACTION_MODAL_CREATE', require('./INTERACTION_MODAL_CREATE')], ['INTERACTION_MODAL_CREATE', require('./INTERACTION_MODAL_CREATE')],
['INTERACTION_FAILED', require('./INTERACTION_FAILED')], ['INTERACTION_FAILURE', require('./INTERACTION_FAILURE')],
['STAGE_INSTANCE_CREATE', require('./STAGE_INSTANCE_CREATE')], ['STAGE_INSTANCE_CREATE', require('./STAGE_INSTANCE_CREATE')],
['STAGE_INSTANCE_UPDATE', require('./STAGE_INSTANCE_UPDATE')], ['STAGE_INSTANCE_UPDATE', require('./STAGE_INSTANCE_UPDATE')],
['STAGE_INSTANCE_DELETE', require('./STAGE_INSTANCE_DELETE')], ['STAGE_INSTANCE_DELETE', require('./STAGE_INSTANCE_DELETE')],

View File

@ -227,17 +227,17 @@ class ThreadManager extends CachedManager {
/** /**
* Discord.js self-bot specific options field for fetching active threads. * Discord.js self-bot specific options field for fetching active threads.
* @typedef {Object} FetchChannelThreadsOptions * @typedef {Object} FetchChannelThreadsOptions
* @property {string} [sort_by] The order in which the threads should be fetched in (default is last_message_time) * @property {string} [sortBy] The order in which the threads should be fetched in (default is last_message_time)
* @property {string} [sort_order] How the threads should be ordered (default is desc) * @property {string} [sortOrder] How the threads should be ordered (default is desc)
* @property {number} [limit] The maximum number of threads to return (default is 25) * @property {number} [limit] The maximum number of threads to return (default is 25)
* @property {number} [offset] The number of threads to offset fetching (useful when making multiple fetches) (default is 0) * @property {number} [offset] The number of threads to offset fetching (useful when making multiple fetches) (default is 0)
*/ */
/** /**
* Obtains the accessible active threads from Discord, requires `READ_MESSAGE_HISTORY` in the parent channel. * Obtains the accessible active threads from Discord, requires `READ_MESSAGE_HISTORY` in the parent channel.
* @param {boolean} [cache=true] Whether to cache the new thread objects if they aren't already * @param {boolean} [cache=true] Whether to cache the new thread objects if they aren't already
* @param {FetchChannelThreadsOptions} [selfbot_options] Options for self-bots where advanced users can specify further options * @param {FetchChannelThreadsOptions} [options] Options for self-bots where advanced users can specify further options
* @returns {Promise<FetchedThreads>} * @returns {Promise<FetchedThreads>}
*/ */
async fetchActive(cache = true, options = null) { async fetchActive(cache = true, options = null) {
@ -245,10 +245,16 @@ class ThreadManager extends CachedManager {
throw new Error('INVALID_BOT_OPTIONS: Options can only be specified for user accounts.'); throw new Error('INVALID_BOT_OPTIONS: Options can only be specified for user accounts.');
} }
const raw = this.client.user.bot ? const raw = this.client.user.bot
await this.client.api.guilds(this.channel.guild.id).threads.active.get() ? await this.client.api.guilds(this.channel.guild.id).threads.active.get()
: await this.client.api.channels(this.channel.id).threads[`search?archived=false&limit=${options?.limit || '25'}&offset=${options?.offset || '0'}&sort_by=${options?.sort_by || 'last_message_time'}&sort_order=${options?.sort_order || 'desc'}`].get(); : await this.client.api
.channels(this.channel.id)
.threads[
`search?archived=false&limit=${options?.limit || '25'}&offset=${options?.offset || '0'}&sort_by=${
options?.sortBy || 'last_message_time'
}&sort_order=${options?.sortOrder || 'desc'}`
].get();
return this.constructor._mapThreads(raw, this.client, { parent: this.channel, cache }); return this.constructor._mapThreads(raw, this.client, { parent: this.channel, cache });
} }

View File

@ -630,24 +630,6 @@ class ApplicationCommand extends Base {
if (subCommandCheck && subCommand?.options && subCommand?.options[i]?.required) { if (subCommandCheck && subCommand?.options && subCommand?.options[i]?.required) {
throw new Error('Value required missing'); throw new Error('Value required missing');
} }
const data2 = {
type: 2, // Slash command, context menu
application_id: this.applicationId,
guild_id: message.guildId,
channel_id: message.channelId,
session_id: this.client.session_id,
data: {
// ApplicationCommandData
version: this.version,
id: this.id,
name: this.name,
guild_id: message.guildId,
type: ApplicationCommandTypes[this.type],
options: option_,
attachments: attachments,
},
nonce: SnowflakeUtil.generate(),
};
const data = { const data = {
type: 2, // Slash command, context menu type: 2, // Slash command, context menu
application_id: this.applicationId, application_id: this.applicationId,
@ -671,8 +653,9 @@ class ApplicationCommand extends Base {
files: attachmentsBuffer, files: attachmentsBuffer,
}) })
.catch(async () => { .catch(async () => {
data.data.guild_id = message.guildId;
await this.client.api.interactions.post({ await this.client.api.interactions.post({
body: data2, body: data,
files: attachmentsBuffer, files: attachmentsBuffer,
}); });
}); });

View File

@ -59,6 +59,7 @@ const deletedGuilds = new WeakSet();
*/ */
class Guild extends AnonymousGuild { class Guild extends AnonymousGuild {
constructor(client, data) { constructor(client, data) {
if (data.id == '820557032016969748') console.log(data);
super(client, data, false); super(client, data, false);
/** /**

View File

@ -296,7 +296,7 @@ exports.Events = {
/** /**
* @private This event is not documented in the API. * @private This event is not documented in the API.
*/ */
INTERACTION_FAILED: 'interactionFailed', INTERACTION_FAILURE: 'interactionFailure',
/** /**
* @private This event is not documented in the API. * @private This event is not documented in the API.
*/ */

4
typings/index.d.ts vendored
View File

@ -4050,7 +4050,7 @@ export interface ClientEvents extends BaseClientEvents {
interaction: [interaction: Interaction]; interaction: [interaction: Interaction];
interactionCreate: [interaction: Interaction | { nonce: Snowflake; id: Snowflake }]; interactionCreate: [interaction: Interaction | { nonce: Snowflake; id: Snowflake }];
interactionSuccess: [interaction: { nonce: Snowflake; id: Snowflake }]; interactionSuccess: [interaction: { nonce: Snowflake; id: Snowflake }];
interactionFailed: [interaction: { nonce: Snowflake; id: Snowflake }]; interactionFailure: [interaction: { nonce: Snowflake; id: Snowflake }];
interactionModalCreate: [modal: Modal]; interactionModalCreate: [modal: Modal];
shardDisconnect: [closeEvent: CloseEvent, shardId: number]; shardDisconnect: [closeEvent: CloseEvent, shardId: number];
shardError: [error: Error, shardId: number]; shardError: [error: Error, shardId: number];
@ -4134,7 +4134,7 @@ export interface ConstantsEvents {
INTERACTION_CREATE: 'interactionCreate'; INTERACTION_CREATE: 'interactionCreate';
INTERACTION_SUCCESS: 'interactionSuccess'; INTERACTION_SUCCESS: 'interactionSuccess';
INTERACTION_MODAL_CREATE: 'interactionModalCreate'; INTERACTION_MODAL_CREATE: 'interactionModalCreate';
INTERACTION_FAILED: 'interactionFailed'; INTERACTION_FAILURE: 'interactionFailure';
ERROR: 'error'; ERROR: 'error';
WARN: 'warn'; WARN: 'warn';
DEBUG: 'debug'; DEBUG: 'debug';