ConfonedDev

Discord.js Ban script

Feb 26th, 2020
6,641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on('message', message => {
  2.    
  3.     if (!message.guild) return;
  4.  
  5.  
  6.     if (message.content.startsWith('?ban')) {
  7.       const user = message.mentions.users.first()
  8.    
  9.       if (user) {
  10.        
  11.         const member = message.guild.member(user);
  12.      
  13.         if (member) {
  14.          
  15.           member.ban({
  16.             reason: 'They were bad!',
  17.           }).then(() => {
  18.             message.reply(`Successfully banned ${user.tag}, LOSER HAH! Get the ban hammer boi!`); // this is the message that will be.
  19.           }).catch(err => {
  20.          
  21.             message.reply('I was unable to ban the member. Check if their roles are higher then mine or if they have administrative permissions!'); // if a user does not have permission to use a command on a user or as a member, this message will be send.
  22. //** for my bot I would say message.reply(`${author.tag}, sorry, I was unable to ban this user! Check to see if there roles are above mine, or if this user is an admin!`)**\\
  23.        
  24.             console.error(err);
  25.           });
  26.         } else {
  27.          
  28.           message.reply('That user isn\'t in this guild!');
  29.         }
  30.       } else {
  31.      
  32.         message.reply('You didn\'t mention the user to ban!');
  33.       }
  34.     }
  35.   });
Advertisement
Add Comment
Please, Sign In to add comment