mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
feat: general component improvements (#5787)
This commit is contained in:
@@ -1,21 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
const { Events, InteractionTypes } = require('../../../util/Constants');
|
||||
const { Events, InteractionTypes, MessageComponentTypes } = require('../../../util/Constants');
|
||||
const Structures = require('../../../util/Structures');
|
||||
|
||||
module.exports = (client, { d: data }) => {
|
||||
let interaction;
|
||||
let InteractionType;
|
||||
switch (data.type) {
|
||||
case InteractionTypes.APPLICATION_COMMAND: {
|
||||
const CommandInteraction = Structures.get('CommandInteraction');
|
||||
interaction = new CommandInteraction(client, data);
|
||||
case InteractionTypes.APPLICATION_COMMAND:
|
||||
InteractionType = Structures.get('CommandInteraction');
|
||||
break;
|
||||
}
|
||||
case InteractionTypes.MESSAGE_COMPONENT: {
|
||||
const MessageComponentInteraction = Structures.get('MessageComponentInteraction');
|
||||
interaction = new MessageComponentInteraction(client, data);
|
||||
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;
|
||||
@@ -26,5 +32,5 @@ module.exports = (client, { d: data }) => {
|
||||
* @event Client#interaction
|
||||
* @param {Interaction} interaction The interaction which was created
|
||||
*/
|
||||
client.emit(Events.INTERACTION_CREATE, interaction);
|
||||
client.emit(Events.INTERACTION_CREATE, new InteractionType(client, data));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user