@@ -22,7 +22,7 @@ globalThis.Underline = {
2222 UserAction : require ( "./types/UserAction" ) ,
2323}
2424
25- console . info ( "[BİLGİ] Basit Altyapı v1.8.2 - by Kıraç Armağan Önal" ) ;
25+ console . info ( "[BİLGİ] Basit Altyapı v1.8.3 - by Kıraç Armağan Önal" ) ;
2626( async ( ) => {
2727 let interactionsPath = path . resolve ( "./interactions" ) ;
2828 await makeSureFolderExists ( interactionsPath ) ;
@@ -145,78 +145,85 @@ console.info("[BİLGİ] Basit Altyapı v1.8.2 - by Kıraç Armağan Önal");
145145 let subCommandGroupName = "" ;
146146 try { subCommandGroupName = interaction . options . getSubcommandGroup ( ) ; } catch { } ;
147147
148- let command = Underline . interactions . find ( uInter => {
148+ let uInter = Underline . interactions . find ( uInter => {
149149 switch ( uInter . name . length ) {
150150 case 1 : return uInter . name [ 0 ] == interaction . commandName ;
151151 case 2 : return uInter . name [ 0 ] == interaction . commandName && uInter . name [ 1 ] == subCommandName ;
152152 case 3 : return uInter . name [ 0 ] == interaction . commandName && uInter . name [ 1 ] == subCommandGroupName && uInter . name [ 2 ] == subCommandName ;
153153 }
154154 } ) ;
155155
156- if ( ! command ) return ;
156+ if ( ! uInter ) return ;
157157
158- if ( config . autoDefer ) interaction . defer ( ) ;
158+ let other = { } ;
159159
160- let shouldRun1 = await config . onInteractionBeforeChecks ( command , interaction ) ;
160+ let shouldRun1 = await config . onInteractionBeforeChecks ( uInter , interaction , other ) ;
161161
162162 if ( ! shouldRun1 ) return ;
163163
164- if ( command . developerOnly && ! config . developers . has ( interaction . user . id ) ) {
165- config . userErrors . developerOnly ( interaction , command ) ;
164+ if ( uInter . developerOnly && ! config . developers . has ( interaction . user . id ) ) {
165+ config . userErrors . developerOnly ( interaction , uInter , other ) ;
166166 return ;
167167 }
168168
169- if ( command . disabled ) {
170- config . userErrors . disabled ( interaction , command ) ;
169+ if ( uInter . disabled ) {
170+ config . userErrors . disabled ( interaction , uInter , other ) ;
171171 return ;
172172 }
173173
174174 if ( config . blockedUsers . has ( interaction . user . id ) ) {
175- config . userErrors . blocked ( interaction , command ) ;
175+ config . userErrors . blocked ( interaction , uInter , other ) ;
176176 return ;
177177 }
178178
179- if ( command . guildOnly && interaction . channel . type == "dm" ) {
180- config . userErrors . guildOnly ( interaction , command ) ;
179+ if ( uInter . guildOnly && ! interaction . guildId ) {
180+ config . userErrors . guildOnly ( interaction , uInter , other ) ;
181181 return ;
182182 }
183183
184-
185- let other = { } ;
186-
187- let userCooldown = command . coolDowns . get ( interaction . user . id ) || 0 ;
184+ let userCooldown = uInter . coolDowns . get ( interaction . user . id ) || 0 ;
188185 if ( Date . now ( ) < userCooldown ) {
189- config . userErrors . coolDown ( interaction , command , userCooldown - Date . now ( ) ) ;
186+ config . userErrors . coolDown ( interaction , uInter , userCooldown - Date . now ( ) , other ) ;
190187 return ;
191188 }
192189
193190 function setCoolDown ( duration = 0 ) {
194191 if ( typeof duration == "number" && duration > 0 ) {
195- return command . coolDowns . set ( interaction . user . id , Date . now ( ) + duration ) ;
192+ return uInter . coolDowns . set ( interaction . user . id , Date . now ( ) + duration ) ;
196193 } else {
197- return command . coolDowns . delete ( interaction . user . id ) ;
194+ return uInter . coolDowns . delete ( interaction . user . id ) ;
198195 }
199196 }
200197 other . setCoolDown = setCoolDown ;
201198
202- if ( command . coolDown > 0 ) {
203- setCoolDown ( command . coolDown ) ;
199+ if ( uInter . coolDown > 0 ) {
200+ setCoolDown ( uInter . coolDown ) ;
204201 }
205202
206- if ( command . guildOnly && command . perms . bot . length != 0 && ! command . perms . bot . every ( perm => interaction . guild . me . permissions . has ( perm ) ) ) {
207- config . userErrors . botPermsRequired ( interaction , command , command . perms . bot ) ;
203+ if ( uInter . guildOnly && uInter . perms . bot . length != 0 && ! uInter . perms . bot . every ( perm => interaction . guild . me . permissions . has ( perm ) ) ) {
204+ config . userErrors . botPermsRequired ( interaction , uInter , uInter . perms . bot , other ) ;
208205 return ;
209206 }
210207
211- if ( command . guildOnly && command . perms . user . length != 0 && ! command . perms . user . every ( perm => interaction . member . permissions . has ( perm ) ) ) {
212- config . userErrors . userPermsRequired ( interaction , command , command . perms . user ) ;
208+ if ( uInter . guildOnly && uInter . perms . user . length != 0 && ! uInter . perms . user . every ( perm => interaction . member . permissions . has ( perm ) ) ) {
209+ config . userErrors . userPermsRequired ( interaction , uInter , uInter . perms . user , other ) ;
213210 return ;
214211 }
215212
216213 ( async ( ) => {
217- let shouldRun2 = await config . onInteraction ( command , interaction , other ) ;
214+ let shouldRun2 = await config . onInteraction ( uInter , interaction , other ) ;
218215 if ( ! shouldRun2 ) return ;
219- await command . onInteraction ( interaction , other ) ;
216+ try {
217+ await uInter . onInteraction ( interaction , other ) ;
218+ } catch ( err ) {
219+ console . error ( `[HATA] "${ uInter . actionType == "CHAT_INPUT" ? `/${ uInter . name . join ( " " ) } ` : `${ uInter . name [ 0 ] } ` } " adlı interaksiyon çalıştırılırken bir hata ile karşılaşıldı!` )
220+ if ( err . message ) console . error ( `[HATA] ${ err . message } ` ) ;
221+ if ( err . stack ) {
222+ `${ err . stack } ` . split ( "\n" ) . forEach ( ( line ) => {
223+ console . error ( `[HATA] ${ line } ` ) ;
224+ } ) ;
225+ }
226+ }
220227 } ) ( ) ;
221228
222229 return ;
0 commit comments