简体   繁体   English

我的解禁命令 discord.js v13 一直出现此错误

[英]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) { 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() {} .发生错误是因为要使用 await,执行 function 必须是异步的,因此您所要做的就是在执行之前添加async ,如下所示: 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.这就是为什么,最好花一些时间学习语言而不是复制粘贴,因为这样的许多错误都可以很容易地得到解答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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