'I keep getting this error on my unban command discord.js v13
module.exports = { name: 'unban', description: "Used to unban members from a server", execute(message, args, Discord, client) {
if (!(message.member.roles.cache.some(r => r.id === "783700556472254525"))) return
let reason;
const user = await bot.users.fetch(args[0])
if (!args[1])
{
reason = "Not specified"
}
else
{
reason = args[1]
}
const embed = new Discord.MessageEmbed()
.setTitle(`${user.username} was unbanned!`)
.setDescription(`${user.username} was unbanned by ${message.author.username} for: ${reason}`)
.setColor("GREEN")
.setFooter("Unban Command")
.setTimestamp()
message.channel.send(embed)
message.guild.members.unban(user)
Solution 1:[1]
The error happens because to use await, the execute function has to be asynchronous, so all you have to do is add async before the execute like this: async execute() {}. This is why, it is better to actually spend some time and learn the language instead of copy pasting since many error like this can be easily answered.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Caladan |
