在制作 Discord 机器人时在 Javascript 中获得了 "Unexpected end of input"
Got "Unexpected end of input" in Javascript when making a Discord Bot
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
我在 node.js 中使用 discord.js,我不确定是什么导致了这个错误。我试过检查错别字,但没有发现任何错别字。帮忙?
如评论中所述,将 });
添加到代码的最后。这应该关闭 client.on
事件侦听器。您代码中的最后一个 });
看起来像是关闭了该侦听器,直到我以正确的格式编辑了问题。现在你可以看出还需要 });
。
归功于@SterlingArcher,我回答了 b/c 我不想再将此视为未回答的问题。
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
我在 node.js 中使用 discord.js,我不确定是什么导致了这个错误。我试过检查错别字,但没有发现任何错别字。帮忙?
如评论中所述,将 });
添加到代码的最后。这应该关闭 client.on
事件侦听器。您代码中的最后一个 });
看起来像是关闭了该侦听器,直到我以正确的格式编辑了问题。现在你可以看出还需要 });
。
归功于@SterlingArcher,我回答了 b/c 我不想再将此视为未回答的问题。