问题
client.on("message", (message) => {
message.channel.send({
embed: {
color: 3447003,
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
title: "commands",
description: "all current commands",
fields: [{
name: "admin only",
value: "ban"
},
{
name: "moderator only",
value: "kick"
},
{
name: "everyone",
value: "ping \n help \n invite \n sinvite \n gay \n owner "
}],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: "~Isabelle~"
}
}
});
^
SyntaxError; Unexpected end of input
I'm using discord.js within node.js, and I'm unsure what's causing this error. I've tried checking back for typos but I haven't caught any. Help?
回答1:
As mentioned in the comments, add });
to the very end of your code. This should close off the client.on
event listener. The final });
in your code looked like it closed off that listener until I edited the question with proper formatting. Now you can tell there is another });
needed.
Credit goes to @SterlingArcher, I answered b/c I want to stop looking at this as an unanswered question.
来源:https://stackoverflow.com/questions/48735546/got-unexpected-end-of-input-in-javascript-when-making-a-discord-bot