11import ExtendedClient from "../../classes/ExtendedClient" ;
2- import { ColorResolvable , CommandInteraction } from "discord.js" ;
2+ import { ChatInputCommandInteraction , ColorResolvable } from "discord.js" ;
33
44import Command from "../../classes/Command" ;
55
66import { emojis as emoji , main } from "../../../config.json" ;
77
88const cooldowns = new Map ( ) ;
99
10- export = async ( client : ExtendedClient , Discord : typeof import ( "discord.js" ) , interaction : CommandInteraction ) => {
10+ export = async (
11+ client : ExtendedClient ,
12+ Discord : typeof import ( "discord.js" ) ,
13+ interaction : ChatInputCommandInteraction
14+ ) => {
1115 try {
1216 const command : Command = client . commands . get ( interaction . commandName ) ;
1317
14- if ( ! command ) return ;
18+ if ( ! command ) return ;
1519
16- if ( ! command . enabled ) {
20+ if ( ! command . enabled ) {
1721 const disabled = new Discord . EmbedBuilder ( )
1822 . setColor ( client . config . embeds . error as ColorResolvable )
19- . setDescription ( `${ emoji . cross } This command has been disabled!` )
23+ . setDescription ( `${ emoji . cross } This command has been disabled!` ) ;
2024
2125 await interaction . reply ( { embeds : [ disabled ] , ephemeral : true } ) ;
2226 return ;
2327 }
2428
2529 const validPermissions = client . validPermissions ;
2630
27- if ( command . botPermissions . length ) {
31+ if ( command . botPermissions . length ) {
2832 const invalidPerms = [ ] ;
2933
30- for ( const perm of command . botPermissions as any ) {
31- if ( ! validPermissions . includes ( perm ) ) return ;
34+ for ( const perm of command . botPermissions as any ) {
35+ if ( ! validPermissions . includes ( perm ) ) return ;
3236
33- if ( ! interaction . guild ?. members . me ?. permissions . has ( perm ) ) invalidPerms . push ( perm ) ;
37+ if ( ! interaction . guild ?. members . me ?. permissions . has ( perm ) ) invalidPerms . push ( perm ) ;
3438 }
3539
36- if ( invalidPerms . length ) {
40+ if ( invalidPerms . length ) {
3741 const permError = new Discord . EmbedBuilder ( )
3842 . setColor ( client . config . embeds . error as ColorResolvable )
39- . setDescription ( `I am missing these permissions: \`${ invalidPerms . join ( "\ `, \ `" ) } \`` )
43+ . setDescription ( `I am missing these permissions: \`${ invalidPerms . join ( "`, `" ) } \`` ) ;
4044
4145 await interaction . reply ( { embeds : [ permError ] , ephemeral : true } ) ;
4246 return ;
4347 }
4448 }
4549
46- command . deferReply ? command . ephemeral ? await interaction . deferReply ( { ephemeral : true } ) : await interaction . deferReply ( ) : null ;
50+ command . deferReply
51+ ? command . ephemeral
52+ ? await interaction . deferReply ( { ephemeral : true } )
53+ : await interaction . deferReply ( )
54+ : null ;
4755
48- if ( main . owners . includes ( interaction . user . id ) ) {
56+ if ( main . owners . includes ( interaction . user . id ) ) {
4957 // Log interaction to console
50- console . log ( `[interactionCreate] [command] ${ interaction . user . tag } (${ interaction . user . id } ): /${ interaction . commandName } ${ interaction . options . data . map ( ( option : any ) => option . value ? `${ option . name } :${ option . value } ` : option . name ) . join ( " " ) } ` ) ;
58+ console . log (
59+ `[interactionCreate] [command] ${ interaction . user . tag } (${ interaction . user . id } ): /${
60+ interaction . commandName
61+ } ${ interaction . options . data
62+ . map ( ( option : any ) => ( option . value ? `${ option . name } :${ option . value } ` : option . name ) )
63+ . join ( " " ) } `
64+ ) ;
5165
5266 try {
5367 await command . execute ( interaction , client , Discord ) ;
5468 return ;
55- } catch ( err ) {
69+ } catch ( err ) {
5670 client . logError ( err ) ;
5771
5872 const error = new Discord . EmbedBuilder ( )
5973 . setColor ( client . config . embeds . error as ColorResolvable )
60- . setDescription ( `${ emoji . cross } There was an error while executing that command!` )
74+ . setDescription ( `${ emoji . cross } There was an error while executing that command!` ) ;
6175
62- command . deferReply ? await interaction . editReply ( { embeds : [ error ] } ) : await interaction . reply ( { embeds : [ error ] , ephemeral : true } ) ;
76+ command . deferReply
77+ ? await interaction . editReply ( { embeds : [ error ] } )
78+ : await interaction . reply ( { embeds : [ error ] , ephemeral : true } ) ;
6379 return ;
6480 }
6581 }
6682
67- if ( ! cooldowns . has ( command . name ) ) cooldowns . set ( command . name , new Discord . Collection ( ) ) ;
83+ if ( ! cooldowns . has ( command . name ) ) cooldowns . set ( command . name , new Discord . Collection ( ) ) ;
6884
6985 const currentTime = Date . now ( ) ;
7086 const timeStamps = cooldowns . get ( command . name ) ;
7187 const cooldownAmount = command . cooldown * 1000 ;
7288
73- if ( timeStamps . has ( interaction . user . id ) ) {
89+ if ( timeStamps . has ( interaction . user . id ) ) {
7490 const expirationTime = timeStamps . get ( interaction . user . id ) + cooldownAmount ;
7591
76- if ( currentTime < expirationTime ) {
77- const timeLeft : string = ( ( ( expirationTime - currentTime ) / 1000 ) . toFixed ( 0 ) ) . toString ( ) ;
92+ if ( currentTime < expirationTime ) {
93+ const timeLeft : string = ( ( expirationTime - currentTime ) / 1000 ) . toFixed ( 0 ) . toString ( ) ;
7894
7995 const cooldown = new Discord . EmbedBuilder ( )
8096 . setColor ( client . config . embeds . error as ColorResolvable )
81- . setDescription ( `⏰ Please wait ${ timeLeft } second${ timeLeft === "1" ? "" : "s" } before running that command again!` )
82-
83- command . deferReply ? await interaction . editReply ( { embeds : [ cooldown ] } ) : await interaction . reply ( { embeds : [ cooldown ] , ephemeral : true } ) ;
97+ . setDescription (
98+ `⏰ Please wait ${ timeLeft } second${
99+ timeLeft === "1" ? "" : "s"
100+ } before running that command again!`
101+ ) ;
102+
103+ command . deferReply
104+ ? await interaction . editReply ( { embeds : [ cooldown ] } )
105+ : await interaction . reply ( { embeds : [ cooldown ] , ephemeral : true } ) ;
84106 return ;
85107 }
86108 }
@@ -89,23 +111,31 @@ export = async (client: ExtendedClient, Discord: typeof import("discord.js"), in
89111
90112 setTimeout ( ( ) => {
91113 timeStamps . delete ( interaction . user . id ) ;
92- } , cooldownAmount )
114+ } , cooldownAmount ) ;
93115
94116 try {
95117 // Log interaction to console
96- console . log ( `[interactionCreate] [command] ${ interaction . user . tag } (${ interaction . user . id } ): /${ interaction . commandName } ${ interaction . options . data . map ( ( option : any ) => option . value ? `${ option . name } :${ option . value } ` : option . name ) . join ( " " ) } ` ) ;
118+ console . log (
119+ `[interactionCreate] [command] ${ interaction . user . tag } (${ interaction . user . id } ): /${
120+ interaction . commandName
121+ } ${ interaction . options . data
122+ . map ( ( option : any ) => ( option . value ? `${ option . name } :${ option . value } ` : option . name ) )
123+ . join ( " " ) } `
124+ ) ;
97125
98126 await command . execute ( interaction , client , Discord ) ;
99- } catch ( err ) {
127+ } catch ( err ) {
100128 client . logError ( err ) ;
101129
102130 const error = new Discord . EmbedBuilder ( )
103131 . setColor ( client . config . embeds . error as ColorResolvable )
104- . setDescription ( `${ emoji . cross } There was an error while executing that command!` )
132+ . setDescription ( `${ emoji . cross } There was an error while executing that command!` ) ;
105133
106- command . deferReply ? await interaction . editReply ( { embeds : [ error ] } ) : await interaction . reply ( { embeds : [ error ] , ephemeral : true } ) ;
134+ command . deferReply
135+ ? await interaction . editReply ( { embeds : [ error ] } )
136+ : await interaction . reply ( { embeds : [ error ] , ephemeral : true } ) ;
107137 }
108- } catch ( err ) {
138+ } catch ( err ) {
109139 client . logError ( err ) ;
110140 }
111- }
141+ } ;
0 commit comments