File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export type AppCommands = {
88} ;
99export type AppCommand = {
1010 data : SlashCommandBuilder ;
11- execute : ( data : AppCommandOptions ) => void ;
11+ execute : ( data : AppCommandOptions ) => Promise < void > ;
1212} ;
1313export type AppCommandOptions = {
1414 interaction : CommandInteraction ;
Original file line number Diff line number Diff line change 1+ import { CacheType , Interaction } from 'discord.js' ;
2+ import { AppCommands } from '../../commands/commands' ;
3+ import { EventModule } from '../events' ;
4+
5+ export default function ( { app, appCommands } : EventModule ) {
6+ app . on ( 'interactionCreate' , async ( interaction : Interaction < CacheType > ) => {
7+ try {
8+ if ( ! interaction . inGuild ( ) || ! appCommands ) return ;
9+
10+ if ( interaction . isCommand ( ) ) {
11+ const { commandName } = interaction ;
12+ const command = appCommands [ commandName as keyof AppCommands ] ;
13+ command && ( await command . execute ( { interaction, app } ) ) ;
14+ }
15+ //Maybe add buttons, selections and modal handlers here eventually
16+ } catch ( errors ) {
17+ //TODO: Add error handling
18+ console . log ( errors ) ;
19+ }
20+ } ) ;
21+ }
You can’t perform that action at this time.
0 commit comments