Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { RichEmbed } = require("discord.js")
  2. const { redlight } = require("../../colours.json");
  3.  
  4. module.exports = {
  5.     config: {
  6.         name: "mute",
  7.         description: "Mutes a member in the discord!",
  8.         usage: "!mute <user> <reason>",
  9.         category: "moderation",
  10.         accessableby: "Members",
  11.         aliases: ["m", "nospeak"]
  12.     },
  13.     run: async (bot, message, args) => {
  14. // check if the command caller has permission to use the command
  15. if(!message.member.hasPermission("MANAGE_ROLES") || !message.guild.owner) return message.channel.send("Você não tem permissão para usar esse comando.");
  16.  
  17. if(!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("Eu não tenho permissão para adicionar essa TAG !")
  18.  
  19. //define the reason and mutee
  20. let mutee = message.mentions.members.first() || message.guild.members.get(args[0]);
  21. if(!mutee) return message.channel.send("Por favor selecione alguem para !");
  22.  
  23. let reason = args.slice(1).join(" ");
  24. if(!reason) reason = "Você não deu uma razão!"
  25.  
  26.  
  27. //define mute role and if the mute role doesnt exist then create one
  28. let muterole = message.guild.roles.find(r => r.name === "Muted")
  29. if(!muterole) {
  30.     try{
  31.         muterole = await message.guild.createRole({
  32.             name: "Muted",
  33.             color: "#514f48",
  34.             permissions: []
  35.         })
  36.         message.guild.channels.forEach(async (channel, id) => {
  37.             await channel.overwritePermissions(muterole, {
  38.                 SEND_MESSAGES: false,
  39.                 ADD_REACTIONS: false,
  40.                 SEND_TTS_MESSAGES: false,
  41.                 ATTACH_FILES: false,
  42.                 SPEAK: false
  43.             })
  44.         })
  45.     } catch(e) {
  46.         console.log(e.stack);
  47.     }
  48. }
  49. //add role to the mentioned user and also send the user a dm explaing where and why they were muted
  50. mutee.addRole(muterole.id).then(() => {
  51.     message.delete()
  52.     mutee.send(`Olá, você foi mutado do discord: ${message.guild.name}\nMotivo: ${reason}`).catch(err => console.log(err))
  53.     message.channel.send(`${mutee.user.username} mutado com sucesso`)
  54. })
  55.  
  56.  
  57.  
  58. //send an embed to the modlogs channel
  59. let embed = new RichEmbed()
  60.     .setColor('#ff0909')
  61.     .setAuthor(`${message.guild.name} MOD LOG`, "https://imgur.com/sQweWYJ.png")
  62.     .addField("Tipo:", "mute")
  63.     .addField("Usuario:", mutee.user.username)
  64.     .addField("ID:", mutee.user.id)
  65.     .addField("Moderador:", message.author.username)
  66.     .addField("Motivo:", reason)
  67.     .addField("Data:", message.createdAt.toLocaleString())
  68.  
  69. let sChannel = message.guild.channels.find(c => c.name === "modlogs")
  70. sChannel.send(embed)
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement