Sir_Spaceboi

Untitled

Oct 11th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. if(command === 'mute') {
  2. if(message.member.hasPermissions('MUTE_MEMBERS')) {
  3.  
  4. let person = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[1]))
  5.  
  6. if (!person) return message.reply('You must state the user you would like to mute!');
  7.  
  8. let mainrole = message.guild.roles.find(role => role.name === 'Verified');
  9. let muterole = message.guild.roles.find(role => role.name === 'Muted');
  10. let time = args[1];
  11.  
  12. if (!mainrole) {
  13. message.guild.defaultRole.setPermissions(0)
  14. }
  15.  
  16. if (!muterole) {
  17. message.channel.send('This server does not have a mute role, I am now creating one.')
  18. console.log('Creating mute role.');
  19. message.guild.createRole({
  20. name: 'Muted',
  21. color: 'GREY',
  22. permissions: ['VIEW_CHANNEL', 'READ_MESSAGES', 'READ_MESSAGE_HISTORY']
  23. }).then(role => console.log('Muted role created.')).catch(console.error);
  24. message.channel.send('The muted role has been created!\n Retype the command to mute the user!')
  25. }else
  26. if (!time) {
  27. return message.reply('You must state a time you would like to mute the user for!')
  28. }
  29.  
  30. person.removeRole(mainrole.id);
  31. person.addRole(muterole.id);
  32.  
  33. message.channel.send(`@${person.user.username} has been muted for ${ms(ms(time))}!`);
  34. setTimeout(function () {
  35. person.addRole(mainrole.id);
  36. person.removeRole(muterole.id);
  37. message.channel.send(`@${person.user.username} has been unmuted!`)
  38. }, ms(time));
  39.  
  40. }else {
  41. message.reply('You cannot use that command!')
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment