feat(InteractionCreate): move to an Action handler (#5906)

This commit is contained in:
monbrey
2021-06-25 05:42:56 +10:00
committed by GitHub
parent ee025b0558
commit ea49f7ca74
4 changed files with 51 additions and 34 deletions

View File

@@ -1,36 +1,5 @@
'use strict';
const { Events, InteractionTypes, MessageComponentTypes } = require('../../../util/Constants');
const Structures = require('../../../util/Structures');
module.exports = (client, { d: data }) => {
let InteractionType;
switch (data.type) {
case InteractionTypes.APPLICATION_COMMAND:
InteractionType = Structures.get('CommandInteraction');
break;
case InteractionTypes.MESSAGE_COMPONENT:
switch (data.data.component_type) {
case MessageComponentTypes.BUTTON:
InteractionType = Structures.get('ButtonInteraction');
break;
default:
client.emit(
Events.DEBUG,
`[INTERACTION] Received component interaction with unknown type: ${data.data.component_type}`,
);
return;
}
break;
default:
client.emit(Events.DEBUG, `[INTERACTION] Received interaction with unknown type: ${data.type}`);
return;
}
/**
* Emitted when an interaction is created.
* @event Client#interaction
* @param {Interaction} interaction The interaction which was created
*/
client.emit(Events.INTERACTION_CREATE, new InteractionType(client, data));
module.exports = (client, packet) => {
client.actions.InteractionCreate.handle(packet.d);
};