feat: Adding TextInput map & starting event plugins for message components

This commit is contained in:
jacoobes
2022-05-13 23:40:52 -05:00
parent f5d02aedca
commit 6ac9720260
2 changed files with 15 additions and 1 deletions

View File

@@ -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({});
}),
)

View File

@@ -14,6 +14,7 @@ export const ApplicationCommandStore = {
export const MessageCompCommandStore = {
[ComponentType.Button]: new Map<string, PluggedModule>(),
[ComponentType.SelectMenu]: new Map<string, PluggedModule>(),
[ComponentType.TextInput] : new Map<string, PluggedModule>()
};
export const TextCommandStore = {
text: new Map<string, PluggedModule>(),