From 6ac9720260040afb12d232b002c28db99b18e093 Mon Sep 17 00:00:00 2001 From: jacoobes Date: Fri, 13 May 2022 23:40:52 -0500 Subject: [PATCH] feat: Adding TextInput map & starting event plugins for message components --- src/handler/events/interactionCreate.ts | 15 ++++++++++++++- src/handler/utilities/readFile.ts | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 0ee4b4a..aff662d 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -15,9 +15,9 @@ import Context from '../structures/context'; import type { Result } from 'ts-results'; import type { PluggedModule } from '../structures/modules/module'; import { CommandType, controller } from '../sern'; -import type { EventPlugin } from '../plugins/plugin'; import { resolveParameters } from '../utilities/resolveParameters'; import type { Args } from '../../types/handler'; +import type { MessageComponentInteraction } from 'discord.js'; function applicationCommandHandler< T extends CommandType.Both | CommandType.MenuUser | CommandType.MenuMsg | CommandType.Slash, @@ -59,6 +59,13 @@ function applicationCommandHandler< .run(); } +function messageComponentInteractionHandler( + modul: PluggedModule | undefined, + interaction: MessageComponentInteraction, +) { + return of(modul); +} + export const onInteractionCreate = (wrapper: Wrapper) => { const { client } = wrapper; @@ -73,6 +80,12 @@ export const onInteractionCreate = (wrapper: Wrapper) => { Files.BothCommand.get(interaction.commandName); return applicationCommandHandler(modul, interaction); } + if (interaction.isMessageComponent()) { + const modul = Files + .MessageCompCommandStore[interaction.componentType] + .get(interaction.customId); + return messageComponentInteractionHandler(modul, interaction); + } return of({}); }), ) diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts index 75d9b5b..676ca73 100644 --- a/src/handler/utilities/readFile.ts +++ b/src/handler/utilities/readFile.ts @@ -14,6 +14,7 @@ export const ApplicationCommandStore = { export const MessageCompCommandStore = { [ComponentType.Button]: new Map(), [ComponentType.SelectMenu]: new Map(), + [ComponentType.TextInput] : new Map() }; export const TextCommandStore = { text: new Map(),