-2

I code in js (node js) and i have this error when i start my bot. Anyone can help me ?

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 ]);```
Max
  • 1

1 Answers1

-1

You need to wrap the await statement with an async function ;

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 ])
}
Vandervidi
  • 642
  • 2
  • 14
  • 32