-3
I am programming a BOT for Discord and I cannot resolve the error below:
> SyntaxError: Unexpected end of input
> at wrapSafe (internal/modules/cjs/loader.js:1072:16)
> at Module._compile (internal/modules/cjs/loader.js:1122:27)
> at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
> at Module.load (internal/modules/cjs/loader.js:1002:32)
> at Function.Module._load (internal/modules/cjs/loader.js:901:14)
> at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
> at internal/main/run_main_module.js:18:47
My code :
const Discord = require('discord.js')
const bot = new Discord.Client();
const ytdl = require('ytdl-core')
const streamOptions = {seek: 0, volume: 1};
const token = 'Njg4NTc1NzE1NzE3MDIxNzUx.Xm2UKA.stJB8VEHvjpfOVsR6qw1NGOceLs';
bot.login(token);
bot.on('ready', () => {
console.log('estou pronto para ser usado');
});
bot.on('message', msg => {}
if(msg.author.bot) {
return;
}
if(msg.content.indexOf("youtube")!==-1 && msg.content.toLowerCase(),startsWith ("?play"))
let CompleteMessage = msg.content.split('');
let youtubeLink = CompleteMessage [1];
if (VoiceChannel == null) {
console.log('Canal nâo foi encontrado!');
}
if (VoiceChannel !== null) {
console.log('O canal foi encontrado!');
VoiceChannel.join()
.then(connection => {
const stream = ytdl(youtubeLink, {filter:'audioonly'});
const DJ = connection.playStream(stream, streamOptions)
DJ.on('end', end => {
VoiceChannel.leave();
});
})
.catch(console.error);
}
This happens when you just type
node
or when you try to run your code with Node ? If this is the case, you should put your code for us to analyze.– JeanExtreme002
Missing a piece at the end of the source, a key and a parenthesis, to close bot.on('message', ... if it is missing in real code, will give syntax error even.
– epx
Vlw more... when I went to type Node gave the following message : Lexical declaration cannot appear in a single-statement context
– Eduardo Etienne