async function msge(){
client.on("message", msg => {
if (msg.content === `${call}status`) {
msg.reply('The aqi in Bucharest is ' + await printf())
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
}
})
return console.log("Worked")
}
This is the function that gets the error and i can't get why. This is the error code: SyntaxError: missing ) after argument list
You cannot use await in here like that:
msg.reply('The aqi in Bucharest is ' + await printf())
^
Await expects the scope it runs in to be annotated with async.
Just put the async keyword next to msg:
client.on("message", async msg => {
^
Alternatively, you could use a Promise. Since you already use it here. You could also just add another .then();
function msge(){
client.on("message", msg => {
if (msg.content === `${call}status`) {
msg.reply('The aqi in Bucharest is ')
.then(printf) // <-- you may adjust this to match your signature
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
}
})