text: let { MessageEmbed } = require("discord.js")
  const Color = `#ffcc00`
  
  let emoji = {
    loading: "<a:loading_EMOTE:933199075254337566>",
    line: "<:line_reply_3:920073431544918017>",
    arrow: "<:green:925389347631534090>",
    cross: "<a:cross:923961428120064021>"
  }
  
  
  module.exports = {
    name: 'ban',
    description: 'Ban a user from a specific guild.',
    userpermissions: ["BAN_MEMBERS"],
    botpermissions: ["BAN_MEMBERS"],
    /**
     *
     * @param {Client} client
     * @param {Message} message
     * @param {String[]} args
     */
    run: async (client, message, args) => {
  
      try {
  
        if (!args[0]) return message.reply(`${emoji.cross} **|** Please specify a member to ban.`)
  
        let reason = args.slice(1).join(" ")
        if (!reason) reason = "Not specified."
  
        if (message.member.permissions.has("BAN_MEMBERS")) {
  
          let member = message.mentions.members.first() || client.members.cache.get(args[0]) || client.members.cache.find(r => r.user.tag === args[0])
  
          if (!member) return message.reply(`${emoji.cross} **|** I could not find that user in this server. Please try mentioning them.`);
  
          if (member.id == message.author.id) return message.reply(`${emoji.cross} **|** Why would you try to ban yourself-`)
  
          if (member.id == client.user.id) return message.reply(`${emoji.cross} **|** Thanks I guess...`);
  
          if (member.id == message.guild.ownerId) return message.reply(`${emoji.cross} **|** So why are we trying to ban the owner of the server??`);
  
          if (member.roles.highest.position >= message.member.roles.highest.position && message.author !== message.guild.owner) {
            return message.reply(`${emoji.cross} **|** Nice try, but you can't ban members that have a role higher than your's...`)
          }
  
          if (!member.bannable) return message.reply(`${emoji.cross} **|** It seems that user is not bannable.`);
  
          else {
            const embed = new MessageEmbed()
              .setTitle("Member Banned:")
              .setDescription(`**${member.user.tag}** was banned by **${message.author.tag}**`)
              .addField(`Banned member:`, member.user.tag, true)
              .addField(`Moderator:`, message.author.tag, true)
              .addField(`Reason:`, reason)
              .setTimestamp()
              .setColor(`#303136`)
              .setThumbnail(member.user.displayAvatarURL({ dynamic: true }))
            member.ban({ reason: reason }).then(mem => {
              message.reply({ embeds: [embed] })
  
            }).catch(e => {
              message.reply(`${emoji.cross} **|** I am missing permissions to ban this user.`)
            })
          }
        } else {
          const noPermissionsEmbed = new MessageEmbed()
            .setFooter({
              text: `You dont have permission to do that!`,
              iconURL: message.author.displayAvatarURL({ dynamic: true })
              })
            .setColor(`#303136`)
          message.reply({
            embeds: [noPermissionsEmbed]
          })
        }
      } catch (e) {
        message.reply(`${emoji.cross} **|** Dang... I've run into an issue, but it seems to be on my end. Please contact **Shark#2538** ASAP.`)
        console.log(e)
      };
    }
  };