@@ -34,60 +34,7 @@ module.exports = async (bot) => {
3434
3535 await rest . put ( Routes . applicationGuildCommands ( bot . user . id , guild . id ) , {
3636 body : SlashCmdsData . filter ( ( x ) => typeof x == "object" ) ,
37- } ) . then ( async registeredCommands => {
38- let fullPermissions = [ ] ;
39- for ( let index = 0 ; index < registredCommands . length ; index ++ ) {
40- let element = registredCommands [ index ] , cmdPerms = [ ] ;
41- try {
42- let commandYMLData = SlashCmds . find ( x => {
43- let commandName = x . commandData . SlashCommand . Data . Name || x . commandData . Name || x . name ;
44- return commandName . toLowerCase ( ) == element . name . toLowerCase ( ) ;
45- } ) ;
46- if ( ! commandYMLData ) {
47- Utils . logWarning ( `Command ${ chalk . bold ( element . name ) } is not found in commands, please check your command configuration.` ) ;
48- continue ;
49- }
50- if ( ! commandYMLData ?. commandData ?. Permission ?. includes ( "@everyone" ) ) {
51- if ( typeof commandYMLData . commandData . Permission == "string" )
52- commandYMLData . commandData . Permission = [ commandYMLData . commandData . Permission ]
53-
54- for ( let i = 0 ; i < commandYMLData . commandData . Permission . length ; i ++ ) {
55- const permission = commandYMLData . commandData . Permission [ i ]
56-
57- const permissionRole = Utils . findRole ( permission , guild , false ) ,
58- permissionUser = Utils . parseUser ( permission , guild , false ) ;
59-
60- if ( permissionRole ) {
61- cmdPerms . push ( {
62- id : permissionRole . id ,
63- type : "ROLE" ,
64- permission : true
65- } )
66- } else if ( permissionUser ) {
67- cmdPerms . push ( {
68- id : permissionUser . id ,
69- type : "USER" ,
70- permission : true
71- } )
72- } else {
73- Utils . logWarning ( `Command ${ chalk . bold ( element . name ) } - ${ chalk . bold ( permission ) } is not a valid User/Role.` )
74- }
75- }
76- fullPermissions . push ( { id : element . id , permissions : cmdPerms } )
77- } else fullPermissions . push ( {
78- id : element . id ,
79- permissions : [ {
80- id : guild . id ,
81- type : "ROLE" ,
82- permission : true
83- } ]
84- } )
85- } catch ( e ) {
86- Utils . logError ( "Error while registering commands: " + element . name + "\n\t" + e . stack )
87- }
88- }
89- await guild . commands . permissions . set ( { fullPermissions } )
90- await Utils . logInfo ( `${ chalk . bold ( SlashCmdsData . length ) } Slash Command${ SlashCmdsData . length == 1 ? "" : "s" } Loaded.` ) ;
37+
9138 } ) . catch ( e => {
9239 if ( e . code == 50001 ) {
9340 Utils . logWarning ( `[SlashCommands] \"${ chalk . bold ( `application.commands` ) } \" scope wasn't selected while inviting the bot. Please use the below link to re-invite your bot.` )
0 commit comments