File tree Expand file tree Collapse file tree 3 files changed +21
-11
lines changed
packages/jellycommands/src Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -13,16 +13,17 @@ export const resolveCommands = async (
1313 if ( ! ( command instanceof BaseCommand ) )
1414 throw new Error ( `Found invalid item "${ command } " in options.commands` ) ;
1515
16- commands . add ( command ) ;
16+ // Don't load disabled commands
17+ if ( ! command . options . disabled ) {
18+ commands . add ( command ) ;
19+ }
1720 } ) ;
1821
1922 const globalCommands : GlobalCommands = new Set ( ) ;
2023 const guildCommands : GuildCommands = new Map ( ) ;
2124
2225 for ( const command of commands ) {
2326 if ( command . options . disabled ) {
24- // commands is a Set and doesn't have a convenient filter function
25- // so delete the disabled commands in this loop
2627 commands . delete ( command ) ;
2728 continue ;
2829 }
Original file line number Diff line number Diff line change @@ -32,12 +32,15 @@ export async function respond(data: CommandReponseData): Promise<void> {
3232 const options = command . options ;
3333
3434 // If autocomplete interaction, run options.autocomplete
35- if ( interaction . isAutocomplete ( ) )
36- /** @todo Duck you typescript */
37- return void ( command as unknown as Command ) . autocomplete ?.( {
38- interaction,
39- client,
40- } ) ;
35+ if ( interaction . isAutocomplete ( ) ) {
36+ if ( command instanceof Command )
37+ await command . autocomplete ?.( {
38+ interaction,
39+ client,
40+ } ) ;
41+
42+ return ;
43+ }
4144
4245 // If defer, defer
4346 if ( options . defer )
Original file line number Diff line number Diff line change @@ -12,11 +12,17 @@ export const registerEvents = async (
1212 if ( ! ( event instanceof Event ) )
1313 throw new Error ( `Found invalid item "${ event } " in options.events` ) ;
1414
15- events . add ( event ) ;
15+ // Don't load disabled events
16+ if ( ! event . options . disabled ) {
17+ events . add ( event ) ;
18+ }
1619 } ) ;
1720
1821 for ( const event of events ) {
19- if ( event . options . disabled ) continue ;
22+ if ( event . options . disabled ) {
23+ events . delete ( event ) ;
24+ continue ;
25+ }
2026
2127 const cb = async ( ...ctx : any [ ] ) => {
2228 try {
You can’t perform that action at this time.
0 commit comments