1+ //=====================================| Import the Module |=====================================\
2+
3+ const { MessageEmbed, MessageActionRow, MessageButton, MessageSelectMenu, MessageAttachment, InteractionCreate } = require ( 'discord.js' ) ;
4+ const { errorCmdLogs2 } = require ( `${ process . cwd ( ) } /Functions/errorCmdLogs.js` ) ;
5+ const { onCoolDown2 } = require ( `${ process . cwd ( ) } /Functions/onCoolDown.js` ) ;
6+ const { author, version } = require ( `${ process . cwd ( ) } /package.json` ) ;
7+ const Settings = require ( `${ process . cwd ( ) } /Settings/settings.json` ) ;
8+ const Config = require ( `${ process . cwd ( ) } /Settings/config.json` ) ;
9+ const Emoji = require ( `${ process . cwd ( ) } /Settings/emojis.json` ) ;
10+ const Embed = require ( `${ process . cwd ( ) } /Settings/embed.json` ) ;
11+
12+ /**
13+ *
14+ * @param {Client } client
15+ * @param {InteractionCreate } interaction
16+ */
17+
18+ //=====================================| Code |=====================================\
19+
20+ module . exports = async ( client , interaction ) => {
21+ try {
22+ //=====================================| Command Handling |=====================================\\
23+ if ( interaction . isCommand ( ) ) {
24+ const command = client . slashCommands . get ( interaction . commandName ) ;
25+ if ( ! command ) return interaction . reply ( {
26+ ephemeral : true ,
27+ embeds : [
28+ new MessageEmbed ( )
29+ . setColor ( Embed . wrongcolor )
30+ . setDescription ( `${ Emoji . Message . ERROR } The command \`${ interaction . commandName } \` doesn't exist!` )
31+ . setFooter ( `${ Embed . footertext } · v${ version } ` , client . user . displayAvatarURL ( ) )
32+ ]
33+ } ) . catch ( ( ) => null ) ;
34+
35+ const args = [ ] ;
36+
37+ for ( let option of interaction . options . data ) {
38+ if ( option . type === 'SUB_COMMAND' ) {
39+ if ( option . name ) args . push ( option . name ) ;
40+ option . options ?. forEach ( ( x ) => {
41+ if ( x . value ) args . push ( x . value ) ;
42+ } ) ;
43+ } else if ( option . value ) args . push ( option . value ) ;
44+ }
45+ interaction . member = interaction . guild . members . cache . get ( interaction . user . id ) || await interaction . guild . members . fetch ( interaction . user . id ) . catch ( ( ) => null ) ;
46+
47+ // ========================================| Other list Handler |======================================= \\
48+
49+ // ====================< NSFW only Check >=================== \\
50+ if ( command . nsfwOnly && ! interaction . channel . nsfw ) {
51+ return interaction . reply ( {
52+ ephemeral : true ,
53+ embeds : [
54+ new MessageEmbed ( )
55+ . setColor ( Embed . wrongcolor )
56+ . setDescription ( `${ Emoji . Message . ERROR } This command can only be used in NSFW channels!` )
57+ . setFooter ( `${ Embed . footertext } · v${ version } ` , client . user . displayAvatarURL ( ) )
58+ ]
59+ } )
60+ }
61+
62+ // ====================< Bots Permissions Check >=================== \\
63+ if ( command . botPerms && ! interaction . member . permissions . has ( command . botPerms ) ) {
64+ return interaction . reply ( {
65+ ephemeral : true ,
66+ embeds : [
67+ new MessageEmbed ( )
68+ . setColor ( Embed . wrongcolor )
69+ . setDescription ( `${ Emoji . Message . ERROR } I don't have the required permissions to use this command\n \`${ command . botPerms . join ( `, ` ) } \`` )
70+ . setFooter ( `${ Embed . footertext } · v${ version } ` , client . user . displayAvatarURL ( ) )
71+ ]
72+ } )
73+ }
74+
75+ // ====================< Members Permissions Check >=================== \\
76+ if ( command . userPerms && ! interaction . member . permissions . has ( command . userPerms ) ) {
77+ return interaction . reply ( {
78+ ephemeral : true ,
79+ embeds : [
80+ new MessageEmbed ( )
81+ . setColor ( Embed . wrongcolor )
82+ . setDescription ( `${ Emoji . Message . ERROR } You don't have the required permissions to use this command\n \`${ command . userPerms . join ( `, ` ) } \`` )
83+ . setFooter ( `${ Embed . footertext } · v${ version } ` , client . user . displayAvatarURL ( ) )
84+ ]
85+ } )
86+ }
87+
88+ // ====================< Cooldown Check >=================== \\
89+ if ( command . cooldown && onCoolDown2 ( interaction , command ) ) {
90+ return interaction . reply ( {
91+ ephemeral : true ,
92+ embeds : [
93+ new MessageEmbed ( )
94+ . setColor ( Embed . wrongcolor )
95+ . setTitle ( `${ Emoji . Message . ERROR } You have been cooldown for \`${ command . cooldown } \` seconds!` )
96+ . setDescription ( `Please wait \`${ onCoolDown2 ( interaction , command ) . toFixed ( 1 ) } \` Before using the \`${ command . name } \` command again!` )
97+ . setFooter ( `${ Embed . footertext } · v${ version } ` , client . user . displayAvatarURL ( ) )
98+ ]
99+ } )
100+ }
101+
102+ // ====================< Start Command >=================== \\
103+ try {
104+ command . run ( client , interaction , args , '/' ) ;
105+ } catch ( error ) {
106+ console . log ( error ) ;
107+ return interaction . reply ( {
108+ ephemeral : true ,
109+ embeds : [
110+ new MessageEmbed ( )
111+ . setColor ( Embed . wrongcolor )
112+ . setDescription ( `${ Emoji . Message . ERROR } There was an error trying to execute that command!` )
113+ . setDescription ( `There was an error trying to execute that command.` )
114+ . addField ( 'Error' , `\`\`\`${ error } \`\`\`` )
115+ . setFooter ( `${ Embed . footertext } · v${ version } ` , client . user . displayAvatarURL ( ) )
116+ ]
117+ } )
118+ }
119+ }
120+
121+ } catch ( error ) {
122+ errorCmdLogs2 ( client , interaction , error ) ;
123+ }
124+ }
125+
126+
127+
128+
129+ /**
130+ /////////////////////////////////////////////////////////////////////
131+ //// ////
132+ \\\\ Handlers Coded by GalaXd#9165 \\\\
133+ //// ////
134+ \\\\ Work for MGalaCyber Development | https://galacyber.xyz \\\\
135+ //// ////
136+ \\\\ All Right Reserved! \\\\
137+ //// ////
138+ /////////////////////////////////////////////////////////////////////
139+ */
0 commit comments