@@ -8,8 +8,9 @@ export async function commandHandler(
88 interaction : Interaction
99) {
1010 if ( interaction . isCommand ( ) ) {
11+ await interaction . deferReply ( ) ;
1112 const command = context . commands . get ( interaction . commandName ) ;
12- if ( ! command ) return interaction . reply ( `Command not found` ) ;
13+ if ( ! command ) return interaction . editReply ( `Command not found` ) ;
1314
1415 if ( commandPermissionCheck ( interaction , command ) ) return ;
1516 if ( commandCooldownCheck ( interaction , command , context ) ) return ;
@@ -18,9 +19,7 @@ export async function commandHandler(
1819 } catch ( e ) {
1920 console . error ( e ) ;
2021 const errorMessage = "An error has occurred" ;
21- interaction . replied
22- ? interaction . reply ( errorMessage ) . catch ( console . error )
23- : interaction . editReply ( errorMessage ) . catch ( console . error ) ;
22+ interaction . editReply ( errorMessage ) . catch ( console . error ) ;
2423 }
2524 }
2625}
@@ -65,7 +64,9 @@ function commandPermissionCheck(
6564 if ( channel . type === "DM" || ! channel ) {
6665 if ( command . guildOnly ) {
6766 interaction
68- . reply ( `This is a guild exclusive command, not to be executed in a dm` )
67+ . editReply (
68+ `This is a guild exclusive command, not to be executed in a dm`
69+ )
6970 . catch ( console . error ) ;
7071 // For guild only commands that were executed in a dm, cancel the command
7172 return true ;
@@ -81,7 +82,7 @@ function commandPermissionCheck(
8182 . missing ( botPermissions ) ;
8283 if ( missingPermissions . length > 0 ) {
8384 interaction
84- . reply (
85+ . editReply (
8586 `In order to run this command, I need the following permissions: ${ missingPermissions
8687 . map ( ( perm ) => `\`${ perm } \`` )
8788 . join ( ", " ) } `
@@ -98,7 +99,7 @@ function commandPermissionCheck(
9899 . missing ( authorPermissions ) ;
99100 if ( missingPermissions . length > 0 ) {
100101 interaction
101- . reply (
102+ . editReply (
102103 `In order to run this command, you need: ${ missingPermissions
103104 . map ( ( perm ) => `\`${ perm } \`` )
104105 . join ( ", " ) } `
@@ -125,7 +126,7 @@ function commandCooldownCheck(
125126 return false ;
126127 }
127128 interaction
128- . reply (
129+ . editReply (
129130 `Please wait ${ Formatters . time (
130131 Date . now ( ) + existingCooldown ,
131132 "R"
0 commit comments