@@ -13,17 +13,16 @@ const events = new Discord.Collection();
1313globalThis . Underline = {
1414 config,
1515 client,
16- interactions : interactions ,
17- events : events ,
16+ interactions,
17+ events,
1818 Interaction : require ( './types/Interaction' ) ,
1919 Event : require ( './types/Event' ) ,
2020 SlashCommand : require ( "./types/SlashCommand" ) ,
21- SlashSubCommand : require ( "./types/SlashSubCommand" ) ,
2221 MessageAction : require ( "./types/MessageAction" ) ,
2322 UserAction : require ( "./types/UserAction" ) ,
2423}
2524
26- console . info ( "[BİLGİ] Basit Altyapı - by Kıraç Armağan Önal" ) ;
25+ console . info ( "[BİLGİ] Basit Altyapı v1.8 - by Kıraç Armağan Önal" ) ;
2726( async ( ) => {
2827 let interactionsPath = path . resolve ( "./interactions" ) ;
2928 await makeSureFolderExists ( interactionsPath ) ;
@@ -46,53 +45,46 @@ console.info("[BİLGİ] Basit Altyapı - by Kıraç Armağan Önal");
4645 let rltPath = path . relative ( __dirname , interactionFile ) ;
4746 console . info ( `[BİLGİ] "${ interactionFile } " konumundaki interaksiyon yükleniyor..` )
4847 /** @type {import("./types/Interaction") } */
49- let interactionData = require ( interactionFile ) ;
48+ let uInter = require ( interactionFile ) ;
5049
51- if ( interactionData ?. _type != "interaction" ) {
50+ if ( uInter ?. _type != "interaction" ) {
5251 console . warn ( `[UYARI] "${ rltPath } " interaksiyon dosyası boş. Atlanıyor..` ) ;
5352 return ;
5453 }
5554
56- if ( ! interactionData . type ) {
57- console . warn ( `[UYARI] "${ rltPath } " interaksiyon dosyasın için bir type belirtilmemiş. Atlanıyor.` ) ;
58- return ;
59- }
60-
61- if ( ! interactionData . id ) {
55+ if ( ! uInter . id ) {
6256 console . warn ( `[UYARI] "${ rltPath } " interaksiyon dosyasının bir idsi bulunmuyor. Atlanıyor..` ) ;
6357 return ;
6458 }
6559
66- if ( typeof interactionData . name != "string" ) {
67- console . warn ( `[UYARI] "${ rltPath } " interaksiyon dosyasının bir ismi bulunmuyor. Atlanıyor..` ) ;
60+ if ( uInter . name . length > 3 ) {
61+ console . warn ( `[UYARI] "${ rltPath } " interaksiyon dosyasının isim listesi çok uzun. (>3) Atlanıyor..` ) ;
6862 return ;
6963 }
70- if ( interactionData . actionType == "CHAT_INPUT" ) interactionData . name = interactionData . name . replace ( / / g, "" ) . toLowerCase ( ) ;
7164
72- if ( typeof interactionData . type == "SUB_COMMAND" && ! interactionData . subName ) {
73- console . warn ( `[UYARI] "${ rltPath } " interaksiyon dosyasının tipi "SUB_COMMAND" ancak bir subName bulundurmuyor . Atlanıyor..` ) ;
65+ if ( ! uInter . name ?. length ) {
66+ console . warn ( `[UYARI] "${ rltPath } " interaksiyon dosyasının bir ismi bulunmuyor . Atlanıyor..` ) ;
7467 return ;
7568 }
7669
77-
78- if ( Underline . interactions . has ( interactionData . id ) ) {
79- console . warn ( `[UYARI] "${ interactionData . id } " idli bir interaksiyon daha önceden zaten yüklenmiş. Atlanıyor.` )
70+ if ( Underline . interactions . has ( uInter . id ) ) {
71+ console . warn ( `[UYARI] "${ uInter . id } " idli bir interaksiyon daha önceden zaten yüklenmiş. Atlanıyor.` )
8072 return ;
8173 }
8274
83- if ( typeof interactionData . onInteraction != "function" ) {
75+ if ( typeof uInter . onInteraction != "function" ) {
8476 console . error ( `[HATA] "${ rltPath } " interaksiyon dosyası geçerli bir onInteraction fonksiyonuna sahip değil! Atlanıyor.` ) ;
8577 return ;
8678 } ;
8779
88- if ( ! interactionData . guildOnly && ( interactionData . perms . bot . length != 0 || interactionData . perms . user . length != 0 ) ) {
80+ if ( ! uInter . guildOnly && ( uInter . perms . bot . length != 0 || uInter . perms . user . length != 0 ) ) {
8981 console . warn ( `[UYARI] "${ rltPath } " interaksiyon dosyası sunuculara özel olmamasına rağmen özel perm kullanıyor.` ) ;
9082 }
9183
9284
93- Underline . interactions . set ( interactionData . id , interactionData ) ;
94- interactionData . onLoad ( client ) ;
95- console . info ( `[BİLGİ] "/ ${ interactionData . name } ${ interactionData . subName ? ` ${ interactionData . subName } ` : "" } " (${ interactionData . id } ) adlı interaksiyon yüklendi. (${ Date . now ( ) - start } ms sürdü.)` ) ;
85+ Underline . interactions . set ( uInter . id , uInter ) ;
86+ uInter . onLoad ( client ) ;
87+ console . info ( `[BİLGİ] "${ uInter . actionType == "CHAT_INPUT" ? `/ ${ uInter . name . join ( " " ) } ` : ` ${ uInter . name [ 0 ] } ` } " (${ uInter . id } ) adlı interaksiyon yüklendi. (${ Date . now ( ) - start } ms sürdü.)` ) ;
9688 } ) ;
9789
9890 if ( Underline . interactions . size ) {
@@ -148,11 +140,16 @@ console.info("[BİLGİ] Basit Altyapı - by Kıraç Armağan Önal");
148140 client . on ( "interactionCreate" , async ( interaction ) => {
149141 if ( ! ( interaction . isCommand ( ) || interaction . isContextMenu ( ) ) ) return ;
150142
151- let command = Underline . interactions . find ( cmd => {
152- if ( cmd . type == "SUB_COMMAND" ) {
153- return cmd . name == interaction . commandName && cmd . subName == interaction . options . getSubcommand ( ) ;
154- } else if ( cmd . type == "COMMAND" ) {
155- return cmd . name == interaction . commandName ;
143+ let subCommandName = "" ;
144+ try { subCommandName = interaction . options . getSubcommand ( ) ; } catch { } ;
145+ let subCommandGroupName = "" ;
146+ try { subCommandGroupName = interaction . options . getSubcommandGroup ( ) ; } catch { } ;
147+
148+ let command = Underline . interactions . find ( uInter => {
149+ switch ( uInter . name . length ) {
150+ case 1 : return uInter . name [ 0 ] == interaction . commandName ;
151+ case 2 : return uInter . name [ 0 ] == interaction . commandName && uInter . name [ 1 ] == subCommandName ;
152+ case 3 : return uInter . name [ 0 ] == interaction . commandName && uInter . name [ 1 ] == subCommandGroupName && uInter . name [ 2 ] == subCommandName ;
156153 }
157154 } ) ;
158155
0 commit comments