Removed fs and re-added playAudio function

This commit is contained in:
Andrew Lee 2020-07-19 13:42:52 -04:00
parent 3602700e53
commit d211d73230
2 changed files with 10 additions and 8 deletions

16
bot.js
View file

@ -1,13 +1,10 @@
const Discord = require('discord.js'); const Discord = require('discord.js');
const client = new Discord.Client(); const client = new Discord.Client();
const config = require('./token.json'); const config = require('./token.json');
const fs = require('fs'); var prefix = "!";
let prefix = "!";
var voiceChannel = "734184921433899108"; var voiceChannel = "734184921433899108";
client.on('ready', () => { function playAudio() {
console.log(`Logged in as ${client.user.tag}!`);
console.log('Prefix:', prefix);
const channel = client.channels.cache.get(voiceChannel); const channel = client.channels.cache.get(voiceChannel);
if (!channel) return console.error("The channel does not exist!"); if (!channel) return console.error("The channel does not exist!");
channel.join().then(connection => { channel.join().then(connection => {
@ -17,6 +14,12 @@ client.on('ready', () => {
// Oh no, it errored! Let's log it to console :) // Oh no, it errored! Let's log it to console :)
console.error(e); console.error(e);
}); });
}
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
console.log(`Prefix: ${prefix}`);
playAudio();
}); });
client.on('message', async msg => { client.on('message', async msg => {
@ -40,8 +43,7 @@ client.on('message', async msg => {
if (command == 'join') { if (command == 'join') {
// Only try to join the sender's voice channel if they are in one themselves // Only try to join the sender's voice channel if they are in one themselves
console.log("Connected to voice chat...") playAudio();
const connection = await msg.member.voice.channel.join();
} }
if (command == 'skip') { if (command == 'skip') {
//TODO //TODO

View file

@ -1,7 +1,7 @@
{ {
"name": "Project-Jul-2020-Discord-Bot", "name": "Project-Jul-2020-Discord-Bot",
"version": "1.0.0", "version": "1.0.0",
"main": "index.js", "main": "bot.js",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@discordjs/opus": "^0.3.2", "@discordjs/opus": "^0.3.2",