diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-07-20 14:43:33 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-07-20 14:43:33 -0400 |
| commit | ac4839ded1a87b85aab901fd29c0f8875189a98f (patch) | |
| tree | 4f5598fd1ae0053df220fe28dcc3ddf87c734bd8 /bot.js | |
| parent | 47dbf3bc875078a66797907b20861c021bfe8817 (diff) | |
| download | DLAP-ac4839ded1a87b85aab901fd29c0f8875189a98f.tar.gz DLAP-ac4839ded1a87b85aab901fd29c0f8875189a98f.tar.bz2 DLAP-ac4839ded1a87b85aab901fd29c0f8875189a98f.zip | |
Removed fetchAudio and it actually shuffles
Diffstat (limited to 'bot.js')
| -rw-r--r-- | bot.js | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -14,22 +14,24 @@ let botOwner = "242775871059001344"; var voiceChannel = "734184921433899108"; var prefix = "!"; -function fetchAudio() { - fs.readdir('./music', (err, files) => { - if (err) console.error(err); - files.forEach(function (file) { - console.log(`Fetching ${file}`); - }); - }); -} - function playAudio() { + let audio; const channel = client.channels.cache.get(voiceChannel); if (!channel) return console.error("The channel does not exist!"); + + fs.readdir('./music', (err, files) => { + if (err) console.error(err); + audio = files[Math.floor(Math.random() * files.length)]; + return audio; + }); + channel.join().then(connection => { console.log("Connected to the voice channel."); - fetchAudio(); - connection.play('./music/4616-werq-by-kevin-macleod.mp3'); + const dispatcher = connection.play("./music/" + audio); + + console.log("Project Jul-2020 Bot:\nNow playing " + audio); + let serviceChannel = client.channels.cache.get('606602551634296968'); + serviceChannel.send("**Project Jul-2020 Bot:**\nNow playing " + audio); }).catch(e => { console.error(e); }); @@ -69,7 +71,7 @@ client.on('message', async msg => { playAudio(); } if (command == 'skip') { - //TODO + //This feature might not make it in } if (command == 'leave') { const channel = client.channels.cache.get(voiceChannel); |
