|
1 | 1 | import type { Module } from '../types/core-modules'
|
2 | 2 | import { callPlugins, executeModule } from './event-utils';
|
3 | 3 | import { SernError } from '../core/structures/enums'
|
4 |
| -import { createSDT, isAutocomplete, isCommand, isMessageComponent, isModal, resultPayload, treeSearch } from '../core/functions' |
| 4 | +import { createSDT, isAutocomplete, isCommand, isContextCommand, isMessageComponent, isModal, resultPayload, treeSearch } from '../core/functions' |
5 | 5 | import type { UnpackedDependencies } from '../types/utility';
|
6 | 6 | import * as Id from '../core/id'
|
7 | 7 | import { Context } from '../core/structures/context';
|
@@ -29,13 +29,23 @@ export function interactionHandler(deps: UnpackedDependencies, defaultPrefix?: s
|
29 | 29 | }
|
30 | 30 | const { module, params } = modules.at(0)!;
|
31 | 31 | let payload;
|
| 32 | + // handles autocomplete |
32 | 33 | if(isAutocomplete(event)) {
|
33 | 34 | //@ts-ignore stfu
|
34 | 35 | const { command } = treeSearch(event, module.options);
|
35 | 36 | payload= { module: command as Module, //autocomplete is not a true "module" warning cast!
|
36 | 37 | args: [event, createSDT(command, deps, params)] };
|
| 38 | + // either CommandTypes Slash | ContextMessage | ContextUesr |
37 | 39 | } else if(isCommand(event)) {
|
38 |
| - payload= { module, args: [Context.wrap(event, defaultPrefix), createSDT(module, deps, params)] }; |
| 40 | + const sdt = createSDT(module, deps, params) |
| 41 | + // handle CommandType.CtxUser || CommandType.CtxMsg |
| 42 | + if(isContextCommand(event)) { |
| 43 | + payload= { module, args: [event, sdt] }; |
| 44 | + } else { |
| 45 | + // handle CommandType.Slash || CommandType.Both |
| 46 | + payload= { module, args: [Context.wrap(event, defaultPrefix), sdt] }; |
| 47 | + } |
| 48 | + // handles modals or components |
39 | 49 | } else if (isModal(event) || isMessageComponent(event)) {
|
40 | 50 | payload= { module, args: [event, createSDT(module, deps, params)] }
|
41 | 51 | } else {
|
|
0 commit comments