Advertisement
dragon55

Untitled

Jun 6th, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. client.on('message', message => {
  3.     if (message.content == ("-ban")) {
  4.                
  5.  
  6.         const mmss = require('ms');
  7.         let reason = message.content.split(' ').slice(3).join(' ');
  8.         let time = message.content.split(' ')[2];
  9.         let guild = message.guild;
  10.  
  11.         let usermention = message.mentions.users.first();
  12.  
  13.         if (!message.guild.member(message.author).hasPermission('BAN_MEMBERS')) {
  14.             return message.reply(':lock: **You** need `BAN_MEMBERS` Permissions to execute `ban`')
  15.         }
  16.  
  17.         if (!message.guild.member(client.user).hasPermission('BAN_MEMBERS')) {
  18.             return message.reply(':lock: **I** need `BAN_MEMBERS` Permissions to execute `ban`')
  19.         }
  20.  
  21.    
  22.  
  23.         if (message.mentions.users.size < 1) {
  24.             return message.reply('You need to mention someone to Ban them!')
  25.         }
  26.  
  27.         if (message.author.id === usermention.id) {
  28.             return message.reply('You cant punish yourself :wink:')
  29.         }
  30.  
  31.         if (!time) {
  32.             return message.reply(`How much time ? **Usage:**\`-ban [@mention] [1d] [Reason]\``)
  33.         }
  34.  
  35.         if (!time.match(/[1-7][s,m,h,d,w]/g)) {
  36.             return message.reply('I need a valid time ! look at the Usage! right here: **Usage:**`-ban [@mention] [1m] [Reason]`')
  37.         }
  38.  
  39.         if (!reason) {
  40.             return message.reply(`You must give me a reason for the ban **Usage:**\`-ban [@mention] [1d] [Reason]\``)
  41.         }
  42.  
  43.         if (!message.guild.member(usermention).bannable) {
  44.             return message.reply('This member is above me in the `role chain` Can\'t ban them')
  45.         }
  46.  
  47.         message.reply("This user has been banned form the server.");
  48.  
  49.         usermention.send(`You've just got banned from ${guild.name}  \n State reason: **${reason}** \n **Disclamer**: If the ban is not timed and Permanent you may not appeal the **BAN**!`)
  50.        message.guild.ban(usermention, 7);
  51.        setTimeout(() => {
  52.            message.guild.unban(usermention.id);
  53.        }, mmss(time));
  54.       message.channel.send({embed: {
  55.            color: 3447003,
  56.            author: {
  57.              name: client.user.username,
  58.              icon_url: client.user.avatarURL
  59.            },
  60.            fields: [{
  61.                name: "Ban:",
  62.                value: `**Banned:** ${usermention.username}#${usermention.discriminator}\n**Moderator:** ${message.author.username} \n**Duration:** ${mmss(mmss(time), {long: true})} \n**Reason:** ${reason}`
  63.              }
  64.            ],
  65.            timestamp: new Date(),
  66.            footer: {
  67.              icon_url: client.user.avatarURL,
  68.              text: "Dragon"
  69.            }
  70.          }
  71.        });
  72.    }
  73. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement