@@ -55,7 +55,7 @@ let eventListeners = [];
5555async function load ( ) {
5656 let loadStart = Date . now ( ) ;
5757 console . debug ( `[HATA AYIKLAMA] Yüklemeye başlandı!` ) ;
58-
58+
5959 let interactionFiles = await getInteractionFilePaths ( ) ;
6060 await chillout . forEach ( interactionFiles , ( interactionFile ) => {
6161 let start = Date . now ( ) ;
@@ -163,7 +163,7 @@ async function load() {
163163 */
164164 ( [ eventName , events ] ) => {
165165 console . info ( `[BİLGİ] Event "${ eventName } " için ${ events . length } dinleyici yüklendi!` ) ;
166-
166+
167167 let listener = ( ...args ) => {
168168
169169 setTimeout ( async ( ) => {
@@ -199,7 +199,7 @@ async function unloadModule(modulePath) {
199199 if ( nodeModule ) {
200200 if ( nodeModule . children . length ) await chillout . forEach ( nodeModule . children , async ( child ) => {
201201 if ( child . filename ) unloadModule ( child . filename ) ;
202- } ) ;
202+ } ) ;
203203 }
204204 delete require . cache [ modulePath ] ;
205205}
@@ -297,31 +297,52 @@ client.on("interactionCreate", async (interaction) => {
297297 return ;
298298 }
299299
300- let userCooldown = uInter . coolDowns . get ( interaction . user . id ) || 0 ;
301- if ( Date . now ( ) < userCooldown ) {
302- config . userErrors . coolDown ( interaction , uInter , userCooldown - Date . now ( ) , other ) ;
303- return ;
300+ if ( typeof uInter . coolDown == "number" ) uInter . coolDown = {
301+ type : "user" ,
302+ amount : uInter . coolDown ,
303+ }
304+
305+ let converter = {
306+ "user" : interaction . user . id ,
307+ "member" : interaction . user . id + "_" + interaction . guild ?. id ,
308+ "channel" : interaction . channel ?. id || interaction . user . id + " _c" ,
309+ "guild" : interaction . guild ?. id || interaction . user . id + "_g" ,
310+ "any" : "any"
311+ }
312+
313+ if ( uInter . coolDown && ! uInter . coolDown . amount ) uInter . coolDown . amount = 0 ;
314+ let now = Date . now ( ) ;
315+
316+ for ( let k in converter ) {
317+ let key = converter [ k ] ;
318+ let keyCooldown = uInter . coolDowns . get ( key ) ;
319+ if ( uInter . coolDown ?. amount && ( now < keyCooldown ) ) {
320+ config . userErrors . coolDown ( interaction , uInter , keyCooldown - now , other , k ) ;
321+ return ;
322+ }
304323 }
305324
306- function setCoolDown ( duration = 0 ) {
325+ function setCoolDown ( duration = 0 , type = "user" ) {
326+ let ckey = converter [ type ] || interaction . user . id ;
307327 if ( typeof duration == "number" && duration > 0 ) {
308- return uInter . coolDowns . set ( interaction . user . id , Date . now ( ) + duration ) ;
328+ return uInter . coolDowns . set ( ckey , Date . now ( ) + duration ) ;
309329 } else {
310- return uInter . coolDowns . delete ( interaction . user . id ) ;
330+ return uInter . coolDowns . delete ( ckey ) ;
311331 }
312332 }
333+
313334 other . setCoolDown = setCoolDown ;
314335
315- if ( uInter . coolDown > 0 ) {
316- setCoolDown ( uInter . coolDown ) ;
336+ if ( uInter . coolDown ?. amount > 0 ) {
337+ setCoolDown ( uInter . coolDown ?. amount , uInter . coolDown ?. type ) ;
317338 }
318339
319340 if ( uInter . guildOnly && uInter . perms . bot . length != 0 && ! uInter . perms . bot . every ( perm => interaction . guild . me . permissions . has ( perm ) ) ) {
320341 config . userErrors . botPermsRequired ( interaction , uInter , uInter . perms . bot , other ) ;
321342 return ;
322343 }
323344
324- if ( uInter . guildOnly && uInter . perms . user . length != 0 && ! uInter . perms . user . every ( perm => interaction . member . permissions . has ( perm ) ) ) {
345+ if ( uInter . guildOnly && ( ! config . developers . has ( interaction . user . id ) ) && uInter . perms . user . length != 0 && ! uInter . perms . user . every ( perm => interaction . member . permissions . has ( perm ) ) ) {
325346 config . userErrors . userPermsRequired ( interaction , uInter , uInter . perms . user , other ) ;
326347 return ;
327348 }
@@ -350,7 +371,7 @@ client.on("interactionCreate", async (interaction) => {
350371 await config . onBeforeLoad ( client ) ;
351372 await load ( ) ;
352373 await config . onAfterLoad ( client ) ;
353-
374+
354375 await client . login ( config . clientToken ) ;
355376
356377 config . onReady ( client ) ;
0 commit comments