-1

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)
  • Does this answer your question? [await is only valid in async function](https://stackoverflow.com/questions/49432579/await-is-only-valid-in-async-function) – Zsolt Meszaros Feb 23 '22 at 17:43

1 Answers1

0

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.

Caladan
  • 2,261
  • 2
  • 6
  • 19