SyntaxError: Unexpected token if

Hi everyone, I would like to have some help I don’t understand this error

if (command === ‘play’) {
const voiceChannel = msg.member.voiceChannel;
if (!voiceChannel) return msg.channel.send(‘I’m sorry but you need to be in a voice channel to play music!’);
const permissions = voiceChannel.permissionsFor(msg.client.user);
if (!permissions.has(‘CONNECT’)) {

C:\Users\young\OneDrive\Bureau\Kim Alpha\app.js:34
if (command === ‘play’) {
^^

SyntaxError: Unexpected token if
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

With syntax errors, always check the line(s) above. You might have a mistake on line 33, causing the syntax on line 34 to give an error

even better, post the whole content of the JS file, makes debugging a lot easier for the people who are trying to help you

1 Like


here are the code

line 32 in this case then, because line 33 is blank

i think you attempted to close line 32 with a semi-colon, but you use a comma.

1 Like

oh actually yes thank you very much

just for my own personal clarification (if you don’t mind), i asked you about the line above the error line:

Did you do this?