Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- client.on('message', message => {
- if (message.content == ("-ban")) {
- const mmss = require('ms');
- let reason = message.content.split(' ').slice(3).join(' ');
- let time = message.content.split(' ')[2];
- let guild = message.guild;
- let usermention = message.mentions.users.first();
- if (!message.guild.member(message.author).hasPermission('BAN_MEMBERS')) {
- return message.reply(':lock: **You** need `BAN_MEMBERS` Permissions to execute `ban`')
- }
- if (!message.guild.member(client.user).hasPermission('BAN_MEMBERS')) {
- return message.reply(':lock: **I** need `BAN_MEMBERS` Permissions to execute `ban`')
- }
- if (message.mentions.users.size < 1) {
- return message.reply('You need to mention someone to Ban them!')
- }
- if (message.author.id === usermention.id) {
- return message.reply('You cant punish yourself :wink:')
- }
- if (!time) {
- return message.reply(`How much time ? **Usage:**\`-ban [@mention] [1d] [Reason]\``)
- }
- if (!time.match(/[1-7][s,m,h,d,w]/g)) {
- return message.reply('I need a valid time ! look at the Usage! right here: **Usage:**`-ban [@mention] [1m] [Reason]`')
- }
- if (!reason) {
- return message.reply(`You must give me a reason for the ban **Usage:**\`-ban [@mention] [1d] [Reason]\``)
- }
- if (!message.guild.member(usermention).bannable) {
- return message.reply('This member is above me in the `role chain` Can\'t ban them')
- }
- message.reply("This user has been banned form the server.");
- 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**!`)
- message.guild.ban(usermention, 7);
- setTimeout(() => {
- message.guild.unban(usermention.id);
- }, mmss(time));
- message.channel.send({embed: {
- color: 3447003,
- author: {
- name: client.user.username,
- icon_url: client.user.avatarURL
- },
- fields: [{
- name: "Ban:",
- value: `**Banned:** ${usermention.username}#${usermention.discriminator}\n**Moderator:** ${message.author.username} \n**Duration:** ${mmss(mmss(time), {long: true})} \n**Reason:** ${reason}`
- }
- ],
- timestamp: new Date(),
- footer: {
- icon_url: client.user.avatarURL,
- text: "Dragon"
- }
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement