Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. const Discord = module.require("discord.js");
  2. const ms = require("ms");
  3. const commando = require('discord.js-commando');
  4. const discord = require('discord.js');
  5. const bot = new commando.Client();
  6.  
  7.  
  8. class WarnCommand extends commando.Command
  9. {
  10. constructor(client)
  11. {
  12. super(client,{
  13. name: 'mute',
  14. group: 'admin',
  15. memberName: 'mute',
  16. description: 'Mutes the specified user usage !mute @user time in minutes \(Admin+)'
  17. });
  18. }
  19.  
  20. async run(message, args)
  21. {
  22. //!mute @user 1s/m/h/d
  23. if(!message.member.hasPermission("KICK_MEMBERS")) return message.reply("You cant do this command!");
  24. let wUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0])
  25. if(!wUser) return message.reply("Couldn't find them");
  26. if(wUser.hasPermission("KICK_MEMBERS")) return message.reply("You cannot warn this person!");
  27. let words = args.split(' ');
  28. let reason = words.slice(1).join(' ');
  29.  
  30. let warnEmbed = new Discord.RichEmbed()
  31. .setDescription("Mute")
  32. .setAuthor(message.author.username)
  33. .setColor("#fc6400")
  34. .addField("Muted User", `<@${wUser.id}>`)
  35. .addField("Muted In", message.channel)
  36. .addField("Time", reason);
  37.  
  38. let warnchannel = message.guild.channels.find(`name`, "log");
  39. if(!warnchannel) return message.reply("Couldn't find channel");
  40.  
  41. warnchannel.send(warnEmbed);
  42.  
  43. let muterole = message.guild.roles.find(`name`, "muted");
  44. if(!muterole) return message.reply("You should create that role.");
  45.  
  46. if(reason === isNaN) return message.channel.send("Please specify a number and time");
  47.  
  48. wUser.addRole(muterole.id);
  49. message.channel.send(`<@${wUser.id}> has been temporarily muted`);
  50.  
  51. setTimeout(function(){
  52. message.reply(`<@${wUser.id}> has been unmuted.`);
  53. wUser.removeRole(muterole.id);
  54. }, ms(reason))
  55. }
  56. }
  57.  
  58. module.exports = WarnCommand;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement