简体   繁体   中英

I keep getting this error on my unban command discord.js v13

error

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM