Got “Unexpected end of input” in Javascript when making a Discord Bot

ⅰ亾dé卋堺 提交于 2021-02-05 09:12:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!