Andrey0189

Untitled

Jun 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (['ban', 'бан', 'ифт'].includes(command)) {
  2.         if (message.member.roles.some(r=> [moder, owner].includes(r.id))) {
  3.         let user = message.mentions.members.first();
  4.         if (user === message.author) {
  5.             message.reply('Ошибка. Причина: **БАНИТЬ САМОГО СЕБЯ ЭТО ТУПО!**');
  6.             return
  7.         }
  8.         if(user.hasPermission("ADMINISTRATOR")) return message.reply('Ошибка. Причина: **Вы не можете забанить этого пользователя, т. к. у него есть право `Администратор`**');
  9.         if (!user) {
  10.             message.reply('Ошибка. Причина: **Вы забыли упомянуть пользователя или вы хотите забанить того, кто не является пользователем**');
  11.             return
  12.         }
  13.  
  14.         function getSeconds(str) {
  15.             let seconds = 0;
  16.             let years = str.match(/(\d+)\s*y/);
  17.             let months = str.match(/(\d+)\s*M/);
  18.             let weeks = str.match(/(\d+)\s*w/);
  19.             let days = str.match(/(\d+)\s*d/);
  20.             let hours = str.match(/(\d+)\s*h/);
  21.             let minutes = str.match(/(\d+)\s*m/);
  22.             let secs = str.match(/(\d+)\s*s/);
  23.             if (years) { seconds += parseInt(years[1])*31556926; }
  24.             if (months) { seconds += parseInt(months[1])*2592000; }
  25.             if (weeks) { seconds += parseInt(weeks[1])*604800; }
  26.             if (days) { seconds += parseInt(days[1])*86400; }
  27.             if (hours) { seconds += parseInt(hours[1])*3600; }
  28.             if (minutes) { seconds += parseInt(minutes[1])*60; }
  29.             if (secs) { seconds += parseInt(secs[1]); }
  30.             return seconds;
  31.         }
  32.  
  33.         let reason = args.join(" ").replace(user, '');
  34.         if (!reason || reason === ' ') reason = ' Не указана'
  35.         reason = reason.replace(args[1], '');
  36.         reason = reason.replace(' ', '');
  37.             const embed = new Discord.RichEmbed()
  38.                 .setTitle('Информация о бане')
  39.                 .setColor("af00ff")
  40.                 .setDescription('Вы были **забанены** пользователем ' + message.author + '.\n\nВремя: **' + args[0] + '**.\n\nПричина:**' + reason + '.**\n\nНе надо было вести себя плохо!')
  41.                 .setFooter(bot_name + " | " + version + " | Все права защищены")
  42.                 .setTimestamp();
  43.             user.send({embed})
  44.             message.guild.member(user).ban(reason);
  45.             if (args[1] && getSeconds(args[1]) !== 0 )
  46.  
  47.     setBigTimeout(() => {
  48.         const embedAutoUnban = new Discord.RichEmbed()
  49.         .setTitle("Информация о бане")
  50.         .setColor("af00ff")
  51.         .setDescription('Вы были автоматически **разбанены**.\n\nПричина: **Автоматический разбан.**')
  52.         .setFooter(bot_name + " | " + version + " | Все права защищены")
  53.         .setTimestamp();
  54.         user.send({embed: embedAutoUnban});
  55.         message.channel.send(user + ' был разбанен');
  56.         message.guild.members.get(user.id).unban(reason)
  57.         }, getSeconds(args[1])*1000);
  58.         } else {
  59.             message.reply('Ошибка. Причина: **Вы не можете использовать команду ban, вы должны иметь роль Модератор');
  60.             return
  61.         }
  62.     }
Advertisement
Add Comment
Please, Sign In to add comment