@@ -17,17 +17,17 @@ let { findImage, sendImage } = require("./utils");
17
17
const { parseMsg, isCmd } = require ( "./parse" ) ;
18
18
19
19
let runMusicCmd ;
20
- if ( process . env . MUSIC_ENABLED == "true" ) {
21
- runMusicCmd = require ( "@frogebot/music" ) ( {
22
- BOT_NAME : process . env . BOT_NAME ,
23
- EMBED_COLOUR : process . env . EMBED_COLOUR ,
24
- MSG_VIBING : process . env . MSG_VIBING ,
25
- MSG_UNVIBING : process . env . MSG_UNVIBING ,
26
- SKIP_PERCENT : process . env . SKIP_PERCENT ,
27
- USE_MUSIC_ROLE : process . env . USE_MUSIC_ROLE ,
28
- MUSIC_ROLE_NAME : process . env . MUSIC_ROLE_NAME ,
29
- TOKEN : process . env . TOKEN
30
- } )
20
+ if ( process . env . MUSIC_ENABLED == "true" ) {
21
+ runMusicCmd = require ( "@frogebot/music" ) ( {
22
+ BOT_NAME : process . env . BOT_NAME ,
23
+ EMBED_COLOUR : process . env . EMBED_COLOUR ,
24
+ MSG_VIBING : process . env . MSG_VIBING ,
25
+ MSG_UNVIBING : process . env . MSG_UNVIBING ,
26
+ SKIP_PERCENT : process . env . SKIP_PERCENT ,
27
+ USE_MUSIC_ROLE : process . env . USE_MUSIC_ROLE ,
28
+ MUSIC_ROLE_NAME : process . env . MUSIC_ROLE_NAME ,
29
+ TOKEN : process . env . TOKEN ,
30
+ } ) ;
31
31
}
32
32
33
33
async function handleCmdMsg ( msg ) {
@@ -41,12 +41,20 @@ async function handleCmdMsg(msg) {
41
41
handleCmd ( msg , cmd , args ) ;
42
42
}
43
43
async function handleCmdInteraction ( interaction ) {
44
- if ( interaction . isCommand ( ) ) {
44
+ if ( interaction . isCommand ( ) ) {
45
45
let cmd = commands [ interaction . commandName ] ;
46
- let args = cmd . options ? cmd . options . map ( o => { if ( interaction . options . get ( o . name ) ) { return interaction . options . get ( o . name ) . value } else { return undefined } } ) : [ ]
46
+ let args = cmd . options
47
+ ? cmd . options . map ( ( o ) => {
48
+ if ( interaction . options . get ( o . name ) ) {
49
+ return interaction . options . get ( o . name ) . value ;
50
+ } else {
51
+ return undefined ;
52
+ }
53
+ } )
54
+ : [ ] ;
47
55
handleCmd ( interaction , cmd , args ) ;
48
56
}
49
- if ( interaction . isContextMenu ( ) ) {
57
+ if ( interaction . isContextMenu ( ) ) {
50
58
let cmd = commands [ interaction . commandName ] ;
51
59
let args = [ interaction . targetId ] ;
52
60
handleCmd ( interaction , cmd , args ) ;
@@ -57,7 +65,8 @@ async function handleCmd(interaction, cmd, args) {
57
65
let startTime = new Date ( ) . getTime ( ) ;
58
66
cmdUses += 1 ;
59
67
60
- if ( cmd . type == "script" ) { // If command is set as script type
68
+ if ( cmd . type == "script" ) {
69
+ // If command is set as script type
61
70
// Debug clear cache
62
71
// delete require.cache[require.resolve("../" + cmd.path)];
63
72
@@ -69,7 +78,10 @@ async function handleCmd(interaction, cmd, args) {
69
78
// If command is set as image type
70
79
let imageUrl = await findImage ( interaction ) ; // Find image in channel
71
80
try {
72
- let procMsg = await interaction . reply ( { content : process . env . MSG_PROCESSING , fetchReply : true } ) ;
81
+ let procMsg = await interaction . reply ( {
82
+ content : process . env . MSG_PROCESSING ,
83
+ fetchReply : true ,
84
+ } ) ;
73
85
// msg.channel.startTyping();
74
86
75
87
let r ;
@@ -125,8 +137,10 @@ async function handleCmd(interaction, cmd, args) {
125
137
// Execute command
126
138
let img ;
127
139
if ( cmd . library == "jimp" ) img = await exec ( imageUrl , list , interaction ) ;
128
- if ( cmd . library == "magick" ) img = await execGM ( imageUrl , list , interaction ) ;
129
- if ( cmd . library == "native" ) img = await execGPU ( imageUrl , list , interaction ) ;
140
+ if ( cmd . library == "magick" )
141
+ img = await execGM ( imageUrl , list , interaction ) ;
142
+ if ( cmd . library == "native" )
143
+ img = await execGPU ( imageUrl , list , interaction ) ;
130
144
131
145
let extension = await getFormat ( imageUrl ) ;
132
146
@@ -139,30 +153,31 @@ async function handleCmd(interaction, cmd, args) {
139
153
// procMsg.delete();
140
154
interaction . editReply ( {
141
155
content : `${ process . env . MSG_UNVIBING } An error occurred` ,
142
- embeds : [ {
143
- title : "Error" ,
144
- description : `<@${ interaction . member . id } > - ${
145
- imageUrl != undefined
146
- ? process . env . MSG_ERROR
147
- : process . env . MSG_NO_IMAGE
148
- } \n${ "```" + e + "```" } `,
149
- color : Number ( process . env . EMBED_COLOUR ) ,
150
- timestamp : new Date ( ) ,
151
- author : {
152
- name : process . env . BOT_NAME ,
153
- icon_url : interaction . client . user . displayAvatarURL ( ) ,
156
+ embeds : [
157
+ {
158
+ title : "Error" ,
159
+ description : `<@${ interaction . member . id } > - ${
160
+ imageUrl != undefined
161
+ ? process . env . MSG_ERROR
162
+ : process . env . MSG_NO_IMAGE
163
+ } \n${ "```" + e + "```" } `,
164
+ color : Number ( process . env . EMBED_COLOUR ) ,
165
+ timestamp : new Date ( ) ,
166
+ author : {
167
+ name : process . env . BOT_NAME ,
168
+ icon_url : interaction . client . user . displayAvatarURL ( ) ,
169
+ } ,
154
170
} ,
155
- } ] ,
171
+ ] ,
156
172
} ) ;
157
173
}
158
174
} else if ( cmd . type == "music" && process . env . MUSIC_ENABLED == "true" ) {
159
175
// If command is set as music type
160
- runMusicCmd ( msg , args , cmd )
176
+ runMusicCmd ( msg , args , cmd ) ;
161
177
}
162
178
}
163
179
164
-
165
180
module . exports = {
166
181
handleCmdMsg,
167
- handleCmdInteraction
182
+ handleCmdInteraction,
168
183
} ;
0 commit comments