/**
 * @file softBan command
 * @author Sankarsan Kampa (a.k.a k3rn31p4nic)
 * @license MIT
 */

exports.exec = async (Bastion, message, args) => {
  try {
    let user = message.mentions.users.first();
    if (!user) {
      /**
      * The command was ran with invalid parameters.
      * @fires commandUsage
      */
      return Bastion.emit('commandUsage', message, this.help);
    }

    let member = await message.guild.fetchMember(user.id);
    if (message.author.id !== message.guild.ownerID && message.member.highestRole.comparePositionTo(member.highestRole) <= 0) return Bastion.log.info(Bastion.strings.error(message.guild.language, 'lowerRole', true));

    if (!member.bannable) {
      /**
      * Error condition is encountered.
      * @fires error
      */
      return Bastion.emit('error', Bastion.strings.error(message.guild.language, 'forbidden'), Bastion.strings.error(message.guild.language, 'noPermission', true, 'soft-ban', user), message.channel);
    }

    let reason = args.slice(1).join(' ');
    if (reason.length < 1) {
      reason = 'No reason given';
    }

    await member.ban({
      days: 7,
      reason: reason
    });

    await message.guild.unban(user.id).catch(e => {
      Bastion.log.error(e);
      message.channel.send({
        embed: {
          color: Bastion.colors.RED,
          title: 'Soft-Ban Error',
          description: 'Banned but unable to unban. Please unban the following user.',
          fields: [
            {
              name: 'User',
              value: user.tag,
              inline: true
            },
            {
              name: 'ID',
              value: user.id,
              inline: true
            }
          ]
        }
      }).catch(e => {
        Bastion.log.error(e);
      });
    });

    message.channel.send({
      embed: {
        color: Bastion.colors.RED,
        title: 'Soft-Banned',
        fields: [
          {
            name: 'User',
            value: user.tag,
            inline: true
          },
          {
            name: 'ID',
            value: user.id,
            inline: true
          },
          {
            name: 'Reason',
            value: reason,
            inline: false
          }
        ]
      }
    }).catch(e => {
      Bastion.log.error(e);
    });

    /**
    * Logs moderation events if it is enabled
    * @fires moderationLog
    */
    Bastion.emit('moderationLog', message.guild, message.author, this.help.name, user, reason);

    let DMChannel = await user.createDM();
    DMChannel.send({
      embed: {
        color: Bastion.colors.RED,
        title: `Soft-Banned from ${message.guild.name} Server`,
        description: `**Reason:** ${reason}`
      }
    }).catch(e => {
      Bastion.log.error(e);
    });
  }
  catch (e) {
    Bastion.log.error(e);
  }
};

exports.config = {
  aliases: [ 'sb' ],
  enabled: true
};

exports.help = {
  name: 'softBan',
  botPermission: 'BAN_MEMBERS',
  userTextPermission: 'BAN_MEMBERS',
  userVoicePermission: '',
  usage: 'softBan @user-mention [Reason]',
  example: [ 'softBan @user#0001 Reason for soft ban.' ]
};

@@ -1868,293 +1868,94 @@
     
-title: 'Soft-Banned',%0A        fields: %5B%0A          %7B%0A            name: 'User',%0A            value: user.tag,%0A            inline: true%0A          %7D,%0A          %7B%0A            name: 'ID',%0A            value: user.id,%0A            inline: true%0A          %7D,%0A          %7B%0A            name: 'R
+description: %60$%7Bmessage.author.tag%7D soft-banned $%7Buser.tag%7D with reason **$%7Br
 eason
-'
+%7D**%60
 ,%0A  
@@ -1964,74 +1964,59 @@
     
-    value: reason,%0A            inline: false%0A          %7D%0A        %5D
+footer: %7B%0A          text: %60ID $%7Buser.id%7D%60%0A        %7D
 %0A   
@@ -2388,33 +2388,67 @@
     
-title: %60S
+description: %60$%7Bmessage.author.tag%7D s
 oft-
-B
+b
 anned 
+you 
 from 
+**
 $%7Bme
@@ -2468,52 +2468,32 @@
 ame%7D
- S
+** s
 erver
-%60,%0A        description: %60**R
+ with r
 eason
-:
+ 
 **
- 
 $%7Bre
@@ -2497,16 +2497,18 @@
 %7Breason%7D
+**
 %60%0A      

Simplified output message - softBan command