My problem : Error :
SyntaxError: await is only valid in async function
let ChooseEmbed = new Discord.RichEmbed()
.setAuthor("Choissisez le type de serveur")
.setDescription("**Normal `` ➞ [`Exemple`](https://imgur.com/upload)\n **Gaming** `` ➞ [`Exemple`](https://imgur.com/upload)\n ")
message.channel.send(ChooseEmbed).then(msg => {
msg.react('').then(() => msg.react(''));
const filter = (reaction, user) => {
return ['', ''].includes(reaction.emoji.name) && user.id === message.author.id;
};
msg.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '') {
//Normal
message.channel.send(VerifiedEmbed).then(msgg => {
msgg.react('✅').then(() => msgg.react('❌'));
const filter = (reaction, user) => {
return ['✅', '❌'].includes(reaction.emoji.name) && user.id === message.author.id;
};
msgg.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '✅') {
console.log("C'est bon")
} else {
message.channel.send(AnnulEmbed)
msgg.delete()
return;
}
})
.catch(collected => {
return;
});
})
msg.delete()
} else {
//Gaming
message.channel.send(VerifiedEmbed).then(msggg => {
msggg.react('✅').then(() => msggg.react('❌'));
const filter = (reaction, user) => {
return ['✅', '❌'].includes(reaction.emoji.name) && user.id === message.author.id;
};
msggg.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '✅') {
console.log("C'est bon")
message.guild.channels.deleteAll();
message.guild.roles.deleteAll();
message.guild.setName(`Serveur de ${message.author.username}`).then(g => console.log("g")).catch(console.error);
message.guild.setIcon(message.author.displayAvatarURL).then(g => console.log("g")).catch(console.error);
let cat = await message.guild.createChannel("IMPORTANT", "category");
} else {
msggg.delete()
message.channel.send(AnnulEmbed)
return;
}
})
.catch(collected => {
return;
});
msg.delete()
}
)}})
.catch(collected => {
return;
});
})
I have the error : SyntaxError: await is only valid in async function how i can fix this ?
I have search the error but i don't see them ! I tried everything I would like to know if someone could help me ^^ Do not hesitate to help me to solve my mistake