1.3.4
Get interaction commands using gateway
This commit is contained in:
@@ -60,7 +60,7 @@ class InteractionCreateAction extends Action {
|
||||
InteractionType = AutocompleteInteraction;
|
||||
break;
|
||||
default:
|
||||
client.emit(Events.DEBUG, `[INTERACTION] Received interaction with unknown type: ${data.type}`);
|
||||
client.emit(Events.DEBUG, `[INTERACTION] Received [BOT] / Send (Selfbot) interactionID ${data.id} with unknown type: ${data.type}`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
if (!data.application_commands[0]) return;
|
||||
for (const command of data.application_commands) {
|
||||
const user = client.users.cache.get(command.application_id);
|
||||
if (!user) continue;
|
||||
user.applications._add(command, true);
|
||||
};
|
||||
};
|
@@ -9,6 +9,7 @@ module.exports = (client, { d: data }) => {
|
||||
const guild = client.guilds.cache.get(data.guild_id);
|
||||
if (!guild) return;
|
||||
const members = new Collection();
|
||||
// Get Member from side Discord Channel (online counting if large server)
|
||||
for (const object of data.ops) {
|
||||
if (object.op == 'SYNC') {
|
||||
for (const member_ of object.items) {
|
||||
|
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
const { Events } = require('../../../util/Constants');
|
||||
|
||||
module.exports = (client, packet) => {
|
||||
client.actions.InteractionCreate.handle(packet.d);
|
||||
if (client.user.bot) client.actions.InteractionCreate.handle(packet.d);
|
||||
else client.emit(Events.INTERACTION_CREATE, packet.d);
|
||||
};
|
||||
|
6
src/client/websocket/handlers/INTERACTION_FAILED.js
Normal file
6
src/client/websocket/handlers/INTERACTION_FAILED.js
Normal file
@@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
const { Events } = require('../../../util/Constants');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
client.emit(Events.INTERACTION_FAILED, data);
|
||||
};
|
6
src/client/websocket/handlers/INTERACTION_SUCCESS.js
Normal file
6
src/client/websocket/handlers/INTERACTION_SUCCESS.js
Normal file
@@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
const { Events } = require('../../../util/Constants');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
client.emit(Events.INTERACTION_SUCCESS, data);
|
||||
};
|
@@ -18,6 +18,10 @@ const handlers = Object.fromEntries([
|
||||
['GUILD_MEMBER_UPDATE', require('./GUILD_MEMBER_UPDATE')],
|
||||
['GUILD_MEMBERS_CHUNK', require('./GUILD_MEMBERS_CHUNK')],
|
||||
['GUILD_MEMBER_LIST_UPDATE', require('./GUILD_MEMBER_LIST_UPDATE.js')],
|
||||
[
|
||||
'GUILD_APPLICATION_COMMANDS_UPDATE',
|
||||
require('./GUILD_APPLICATION_COMMANDS_UPDATE.js'),
|
||||
],
|
||||
['GUILD_INTEGRATIONS_UPDATE', require('./GUILD_INTEGRATIONS_UPDATE')],
|
||||
['GUILD_ROLE_CREATE', require('./GUILD_ROLE_CREATE')],
|
||||
['GUILD_ROLE_DELETE', require('./GUILD_ROLE_DELETE')],
|
||||
@@ -50,6 +54,8 @@ const handlers = Object.fromEntries([
|
||||
['VOICE_SERVER_UPDATE', require('./VOICE_SERVER_UPDATE')],
|
||||
['WEBHOOKS_UPDATE', require('./WEBHOOKS_UPDATE')],
|
||||
['INTERACTION_CREATE', require('./INTERACTION_CREATE')],
|
||||
['INTERACTION_SUCCESS', require('./INTERACTION_SUCCESS')],
|
||||
['INTERACTION_FAILED', require('./INTERACTION_FAILED')],
|
||||
['STAGE_INSTANCE_CREATE', require('./STAGE_INSTANCE_CREATE')],
|
||||
['STAGE_INSTANCE_UPDATE', require('./STAGE_INSTANCE_UPDATE')],
|
||||
['STAGE_INSTANCE_DELETE', require('./STAGE_INSTANCE_DELETE')],
|
||||
|
@@ -84,7 +84,7 @@ class ApplicationCommandManager extends CachedManager {
|
||||
* .catch(console.error);
|
||||
*/
|
||||
async fetch(id, { guildId, cache = true, force = false } = {}) {
|
||||
await this.user.createDM().catch(() => {});
|
||||
// change from user.createDM to opcode (risky action)
|
||||
if (typeof id === 'object') {
|
||||
({ guildId, cache = true } = id);
|
||||
} else if (id) {
|
||||
@@ -92,10 +92,11 @@ class ApplicationCommandManager extends CachedManager {
|
||||
const existing = this.cache.get(id);
|
||||
if (existing) return existing;
|
||||
}
|
||||
await this.user.createDM().catch(() => {});
|
||||
const command = await this.commandPath({ id, guildId }).get();
|
||||
return this._add(command, cache);
|
||||
}
|
||||
|
||||
await this.user.createDM().catch(() => {});
|
||||
const data = await this.commandPath({ guildId }).get();
|
||||
return data.reduce((coll, command) => coll.set(command.id, this._add(command, cache, guildId)), new Collection());
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -347,6 +347,8 @@ exports.Events = {
|
||||
TYPING_START: 'typingStart',
|
||||
WEBHOOKS_UPDATE: 'webhookUpdate',
|
||||
INTERACTION_CREATE: 'interactionCreate',
|
||||
INTERACTION_SUCCESS: 'interactionSuccess',
|
||||
INTERACTION_FAILED: 'interactionFailed',
|
||||
ERROR: 'error',
|
||||
WARN: 'warn',
|
||||
DEBUG: 'debug',
|
||||
|
Reference in New Issue
Block a user