我用js(节点js)编写代码,启动我的机器人时出现此错误。 有人可以帮助我吗?
let ip = arg.split(":")[0];
let port = arg.split(":")[1];
let imgRes = await fetch("https://www.minecraftskinstealer.com/achievement/a.php?i=2&h=Success&t="+ip);
let imgAttachment = new Discord.MessageAttachment(await imgRes.buffer(), "success.png");
var serveurinfo = new Discord.RichEmbed()
.setAuthor(message.author.username , message.author.avatarURL)
.setColor("RANDOM")
.setTitle("Information du serveur MCPE\n")
.setDescription("Information du serveur:\n" + ip + " | " + port)
.addField("Il y a (" + state.raw.numplayers + "/" + state.raw.maxplayers + ")" + " Joueurs en ligne.\n\n", onlinePlayers)
.addField("Version", state.raw.version)
.addField("Ping", state.ping + "ms")
.setImage("https://cdn.discordapp.com/attachments/262263759685287939/596993744700440576/skytaria.png")
message.channel.send([ serveurinfo, imgAttachment ]);```
答案 0 :(得分:-1)
您需要使用异步函数包装await语句;
const results = async function(){
return await fetch("https://www.minecraftskinstealer.com/achievement/a.php?i=2&h=Success&t="+ip);
let imgAttachment = new Discord.MessageAttachment(await imgRes.buffer(), "success.png");
var serveurinfo = new Discord.RichEmbed()
.setAuthor(message.author.username , message.author.avatarURL)
.setColor("RANDOM")
.setTitle("Information du serveur MCPE\n")
.setDescription("Information du serveur:\n" + ip + " | " + port)
.addField("Il y a (" + state.raw.numplayers + "/" + state.raw.maxplayers + ")" + " Joueurs en ligne.\n\n", onlinePlayers)
.addField("Version", state.raw.version)
.addField("Ping", state.ping + "ms")
.setImage("https://cdn.discordapp.com/attachments/262263759685287939/596993744700440576/skytaria.png")
message.channel.send([ serveurinfo, imgAttachment ])
}