My code does not work and I have no idea where the missing comma is. Please help!
(Sorry for it being sloppy. Im just learning coding)
My Code is Below:
const Discord = require('discord.js');
const bot = new Discord.Client();
//Deleted const so no one can see it
const token = ''
;
const PREFIX = '!';
const ytdl = require("ytdl-core");
var version = '0.7';
var servers = {};
bot.on('ready',() =>{
console.log('This bot is online!');
bot.user.setActivity ('Minecraft')
})
bot.on('message', msg=>{
let args = msg.content.substring(PREFIX.length).split(" ");
switch(args[0]){
case 'ping':
msg.channel.sendMessage('pong!');
break;
case 'ip':
msg.channel.sendMessage('The server Ip is Nuclearwars.serv.gs');
break;
case 'info':
if(args[1] === 'version'){
msg.channel.sendMessage('Version ' + version);
}else{
msg.channel.sendMessage('Invalid Args')
}
break;
case 'commands':
msg.channel.sendMessage('The following commands are: info version, ip, and ping. There will be more commands coming soon!');
break;
case 'help':
msg.channel.sendMessage('The following commands are: info version, ip, and ping. There will be more commands coming soon!');
break;
case 'play':
function play(connection, message){
var server = servers[message.guild.id];
server.dispatcher = connection.playStream(ytdl(server.queue[0], {filter: "audioonly"}));
server.queue.shift();
server.dispatcher.on("end", funtion(),
if(server.queue[0]){
play(connection, message);
}else{
connection.disconnect();
}
};
if(!args[1]){
MessageChannel.channel.send("you need to provide a link!")
return;
}
if(!Message.member.voiceChannel){
message.channel.send("You must be in a channel to play the bot!")
}
if(!servers[message.guild.id]) servers[message.guild.id] = {
queue: []
}
var server = servers[message.guild.id];
server.queue.push(args[1]);
if(!message.quild.voiceConnetion) message.member.voiceChannel.join().then(funchtion(connection),{
play(connection,message);
})
break;
}
});
bot.login(token);
Here are the pictures of it to.