From d211d73230e7977e30736c21a119e6f696397d43 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 19 Jul 2020 13:42:52 -0400 Subject: Removed fs and re-added playAudio function --- bot.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'bot.js') diff --git a/bot.js b/bot.js index 52fe8b3..6db2ded 100644 --- a/bot.js +++ b/bot.js @@ -1,13 +1,10 @@ const Discord = require('discord.js'); const client = new Discord.Client(); const config = require('./token.json'); -const fs = require('fs'); -let prefix = "!"; +var prefix = "!"; var voiceChannel = "734184921433899108"; -client.on('ready', () => { - console.log(`Logged in as ${client.user.tag}!`); - console.log('Prefix:', prefix); +function playAudio() { const channel = client.channels.cache.get(voiceChannel); if (!channel) return console.error("The channel does not exist!"); channel.join().then(connection => { @@ -17,6 +14,12 @@ client.on('ready', () => { // Oh no, it errored! Let's log it to console :) console.error(e); }); +} + +client.on('ready', () => { + console.log(`Logged in as ${client.user.tag}!`); + console.log(`Prefix: ${prefix}`); + playAudio(); }); client.on('message', async msg => { @@ -40,8 +43,7 @@ client.on('message', async msg => { if (command == 'join') { // Only try to join the sender's voice channel if they are in one themselves - console.log("Connected to voice chat...") - const connection = await msg.member.voice.channel.join(); + playAudio(); } if (command == 'skip') { //TODO -- cgit v1.2.3