Guest User

Bot Command

a guest
Dec 23rd, 2020
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Permissions = require('eris').Constants.Permissions;
  2.  
  3. //TODO: Clean them / mute case sensitivity
  4. //TODO: Clean them / mute nicknames
  5.  
  6. bot.registerCommand('mute', (msg, args) => {
  7.     if(args.length === 0) return 'Please supply a user to mute';
  8.  
  9.     let toFind = bot.users.find(u => u.username === args[0]);
  10.     if(!toFind) return 'Please supply a valid user';
  11.  
  12.     bot.editChannelPermissions(msg.channel.id, msg.author.id, 0, Permissions.sendMessages);
  13. }, {
  14.     description: 'Mutes a user',
  15.     fullDescription: 'Mutes a user so they will not be able to send messages in their current channel',
  16.     usage: '<number to search through>',
  17.     requirements: {
  18.         permissions: {
  19.             "manageMessages": true
  20.         }
  21.     }
  22. });
  23.  
  24. let clean = bot.registerCommand('clean', (msg, args) => {
  25.     let toDelete = parseInt(args.length > 0 ? args[0] : 10);
  26.     if(!toDelete) return 'Please supply a valid number';
  27.  
  28.     bot.purgeChannel(msg.channel.id, toDelete + 1).then(del => {
  29.         bot.createMessage(msg.channel.id, `${del - 1} messages deleted`).then(msg => {
  30.             setTimeout(() => bot.deleteMessage(msg.channel.id, msg.id), 4000);
  31.         });
  32.     });
  33. }, {
  34.     description: 'Deletes messages',
  35.     fullDescription: 'The bot will delete messages from all users in the last specified number of messages',
  36.     usage: '<number to search through>',
  37.     requirements: {
  38.         permissions: {
  39.             "manageMessages": true
  40.         }
  41.     }
  42. });
  43.  
  44. clean.registerSubcommand('you', (msg, args) => {
  45.     let toDelete = parseInt(args.length > 0 ? args[0] : 10);
  46.     if(!toDelete) return 'Please supply a valid number';
  47.  
  48.     bot.purgeChannel(msg.channel.id, toDelete + 1, (logMsg) => {
  49.         if(logMsg.author.id === bot.user.id) return true;
  50.     }).then(del => {
  51.         bot.createMessage(msg.channel.id, `${del - 1} messages deleted`).then(msg => {
  52.             setTimeout(() => bot.deleteMessage(msg.channel.id, msg.id), 4000);
  53.         });
  54.     });
  55. }, {
  56.     description: 'Delete the bot\'s messages',
  57.     fullDescription: 'The bot will delete messages from itself in the last specified number of messages',
  58.     usage: '<number to search through>'
  59. });
  60.  
  61. clean.registerSubcommand('me', (msg, args) => {
  62.     let toDelete = parseInt(args.length > 0 ? args[0] : 10);
  63.     if(!toDelete) return 'Please supply a valid number';
  64.  
  65.     bot.purgeChannel(msg.channel.id, toDelete + 1, (logMsg) => {
  66.         if(logMsg.author.id === msg.author.id) return true;
  67.     }).then(del => {
  68.         bot.createMessage(msg.channel.id, `${del - 1} messages deleted`).then(msg => {
  69.             setTimeout(() => bot.deleteMessage(msg.channel.id, msg.id), 4000);
  70.         });
  71.     });
  72. }, {
  73.     description: 'Deletes your messages',
  74.     fullDescription: 'The bot will delete messages from you in the last specified number of messages',
  75.     usage: '<number to search through>'
  76. });
  77.  
  78. clean.registerSubcommand('them', (msg, args) => {
  79.     if(args.length < 1) return 'Please supply a user';
  80.  
  81.     let toFind = bot.users.find(u => u.username === args[0]);
  82.     if(!toFind) return 'Please supply a valid user';
  83.  
  84.     let toDelete = parseInt(args.length > 1 ? args[1] : 10);
  85.     if(!toDelete) return 'Please supply a valid number';
  86.  
  87.     bot.purgeChannel(msg.channel.id, toDelete + 1, (logMsg) => {
  88.         if(logMsg.author.id === toFind.id) return true;
  89.     }).then(del => {
  90.         bot.createMessage(msg.channel.id, `${del - 1} messages deleted`).then(msg => {
  91.             setTimeout(() => bot.deleteMessage(msg.channel.id, msg.id), 4000);
  92.         });
  93.     });
  94. }, {
  95.     description: 'Deletes messages by a single user',
  96.     fullDescription: 'The bot will delete messages from a user in the last specified number of messages',
  97.     usage: '<user name **not a nickname**> <number to search through>',
  98.     requirements: {
  99.         permissions: {
  100.             "manageMessages": true
  101.         }
  102.     }
  103. });
Advertisement
Add Comment
Please, Sign In to add comment