Having trouble with an Error. I have no idea how to solve it

} else if (message.content === ‘/dice roll’) {
^^^^
SyntaxError: Unexpected token else
at Module._compile (internal/modules/cjs/loader.js:703:23)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)
at internal/main/run_main_module.js:17:11

Seems like a fine question from the title and the arrows so I won’t provide tips for formatting just yet.

It is probably the outside of the code. That’s what I’m going to ask; clarify and/or show us more code, wrapped in a code block (put three back ticks)

Don’t know if this helps, but here is a portion of the code with the error.

// DICE ROLL COMMAND
} else if (message.content === '/dice roll') {
  ^^^^
{ const replies = [`1`, `2`, `3`, `4`, `5`, `6`]
message.replytext = Math.floor((Math.random() * replies.length) + 0); 
message.channel.send(replies[message.replytext]);
});

You could try

else if (message.content === '/dice roll')
{ const replies = [`1`, `2`, `3`, `4`, `5`, `6`];
message.replytext = Math.floor((Math.random() * replies.length) + 0); 
message.channel.send(replies[message.replytext]);
}

It probably has to do with what comes before the } else. It would have to come after a matching if (...) {. Other combinations like while (...) { ... } else { ... } aren’t valid.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.