@@ -15,18 +15,32 @@ let { findImage, sendImage } = require("./utils");
1515
1616const { parseMsg, isCmd } = require ( "./parse" ) ;
1717
18- async function handleCmdMsg ( msg , musicWorker ) {
18+ let runMusicCmd ;
19+ if ( process . env . MUSIC_ENABLED == "true" ) {
20+ runMusicCmd = require ( "@frogebot/music" ) ( {
21+ BOT_NAME : process . env . BOT_NAME ,
22+ EMBED_COLOUR : process . env . EMBED_COLOUR ,
23+ MSG_VIBING : process . env . MSG_VIBING ,
24+ MSG_UNVIBING : process . env . MSG_UNVIBING ,
25+ SKIP_PERCENT : process . env . SKIP_PERCENT ,
26+ USE_MUSIC_ROLE : process . env . USE_MUSIC_ROLE ,
27+ MUSIC_ROLE_NAME : process . env . MUSIC_ROLE_NAME ,
28+ TOKEN : process . env . TOKEN
29+ } )
30+ }
31+
32+ async function handleCmdMsg ( msg ) {
1933 if ( msg . author . bot || ! ( await isCmd ( msg ) ) ) return ; // If not command or called by bot
2034
2135 let parsed = await parseMsg ( msg ) ; // Parses message, returns [0: Prefix, 1: Command, 2: Args string]
2236
2337 let cmd = commands [ parsed [ 1 ] ] ;
2438 let args = parsed [ 2 ] ;
2539
26- handleCmd ( msg , cmd , args , musicWorker ) ;
40+ handleCmd ( msg , cmd , args ) ;
2741}
2842
29- async function handleCmd ( msg , cmd , args , musicWorker ) {
43+ async function handleCmd ( msg , cmd , args ) {
3044 let startTime = new Date ( ) . getTime ( ) ;
3145
3246 if ( cmd . type == "script" ) {
@@ -126,19 +140,12 @@ async function handleCmd(msg, cmd, args, musicWorker) {
126140 procMsg . delete ( ) ;
127141 }
128142 } else if ( cmd . type == "music" && process . env . MUSIC_ENABLED == "true" ) {
129- // If command is set as music type
130- musicWorker . postMessage ( {
131- msgId : msg . id ,
132- interaction : msg . interaction ,
133- channelId : msg . channel . id ,
134- args,
135- cmd,
136- } ) ;
143+ runMusicCmd ( msg , args , cmd ) ;
137144 }
138145}
139146
140147const { getShortcode } = require ( "discord-emoji-converter" ) ;
141- async function handleReaction ( reaction , user , musicWorker , remove ) {
148+ async function handleReaction ( reaction , user , remove ) {
142149 if ( reaction . partial ) {
143150 try {
144151 await reaction . fetch ( ) ;
@@ -187,8 +194,8 @@ async function handleReaction(reaction, user, musicWorker, remove) {
187194 }
188195 } ) ;
189196}
190- async function handleMemberJoin ( member , musicWorker ) { }
191- async function handleMemberLeave ( member , musicWorker ) { }
197+ async function handleMemberJoin ( member ) { }
198+ async function handleMemberLeave ( member ) { }
192199
193200module . exports = {
194201 handleCmdMsg,
0 commit comments