Advertisement
Ryyan

Untitled

Jul 8th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. if (!message.member.hasPermission("MANAGE_ROLES") || !message.guild.owner) return message.channel.send("You dont have permission to use this command.");
  2.  
  3. if (!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I don't have permission to add roles!")
  4.  
  5. //define the reason and mutee
  6. let mutee = message.mentions.members.first() || message.guild.members.get(args[0]);
  7. if (!mutee) return message.channel.send("Please supply a user to be muted!");
  8.  
  9. let reason = args.slice(1).join(" ");
  10. if (!reason) reason = "No reason given"
  11.  
  12. //define mute role and if the mute role doesnt exist then create one
  13. let muterole = message.guild.roles.find(r => r.name === "Muted")
  14. if (!muterole) {
  15. try {
  16. muterole = await message.guild.createRole({
  17. name: "Muted",
  18. color: "#514f48",
  19. permissions: []
  20. })
  21. message.guild.channels.forEach(async (channel, id) => {
  22. await channel.overwritePermissions(muterole, {
  23. SEND_MESSAGES: false,
  24. ADD_REACTIONS: false,
  25. SEND_TTS_MESSAGES: false,
  26. ATTACH_FILES: false,
  27. SPEAK: false
  28. })
  29. })
  30. } catch (e) {
  31. console.log(e.stack);
  32. }
  33. }
  34.  
  35. //add role to the mentioned user and also send the user a dm explaing where and why they were muted
  36. mutee.addRole(muterole.id).then(() => {
  37. message.delete()
  38. mutee.send(`Hello, you have been muted in ${message.guild.name} for: ${reason}`).catch(err => console.log(err))
  39. message.channel.send(`${mutee.user.username} was successfully muted.`)
  40. })
  41.  
  42. //send an embed to the modlogs channel
  43. let muteembed = new RichEmbed()
  44. .setColor(redlight)
  45. .setAuthor(`${message.guild.name} Modlogs`, message.guild.iconURL)
  46. .addField("Moderation:", "mute")
  47. .addField("Person who was moderated:", mutee.user.username)
  48. .addField("Moderator:", message.author.username)
  49. .addField("Reason:", reason)
  50. .addField("Date:", message.createdAt.toLocaleString())
  51.  
  52. let sChannel = message.guild.channels.find(c => c.name === "logs")
  53. sChannel.send(muteembed)
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement