aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-07-20 14:43:33 -0400
committerAndrew Lee <alee14498@protonmail.com>2020-07-20 14:43:33 -0400
commitac4839ded1a87b85aab901fd29c0f8875189a98f (patch)
tree4f5598fd1ae0053df220fe28dcc3ddf87c734bd8
parent47dbf3bc875078a66797907b20861c021bfe8817 (diff)
downloadDLAP-ac4839ded1a87b85aab901fd29c0f8875189a98f.tar.gz
DLAP-ac4839ded1a87b85aab901fd29c0f8875189a98f.tar.bz2
DLAP-ac4839ded1a87b85aab901fd29c0f8875189a98f.zip
Removed fetchAudio and it actually shuffles
-rw-r--r--bot.js26
1 files changed, 14 insertions, 12 deletions
diff --git a/bot.js b/bot.js
index 643aeec..e2b0170 100644
--- a/bot.js
+++ b/bot.js
@@ -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);