SHARE
TWEET

Untitled

a guest Sep 17th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require ("discord.js");
  2. const botconfig = require("../../botconfig.json");
  3. const ms = require("ms");
  4.  
  5. module.exports.run = async (bot, message, args) => {
  6.       let tomute = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  7.  
  8.   let faileduser = new Discord.RichEmbed()
  9.   .setTitle("Failed!")
  10.   .setColor("RANDOM")
  11.   .setDescription("Couldnt find that user in this server!")
  12.   if(!tomute) return message.reply(faileduser);
  13.  
  14.  
  15.   let failedmute = new Discord.RichEmbed()
  16.   .setTitle("Failed!")
  17.   .setColor("RANDOM")
  18.   .setDescription(`You cannot mute someone with the same powers as you!`)
  19.   if(tomute.hasPermission("MANAGE_MESSAGES" || "MANAGE_ROLES")) return message.reply(failedmute);
  20.  
  21.   let muterole = message.guild.roles.find(`name`, "Muted");
  22.  
  23.   //start of create role
  24.   if(!muterole){
  25.     try{
  26.       muterole = await message.guild.createRole({
  27.         name: "Muted",
  28.         color: "#000000",
  29.         permissions:[]
  30.       })
  31.       message.guild.channels.forEach(async (channel, id) => {
  32.         await channel.overwritePermissions(muterole, {
  33.           SEND_MESSAGES: false,
  34.           ADD_REACTIONS: false
  35.         });
  36.       });
  37.     }catch(e){
  38.       console.log(e.stack);
  39.     }
  40.   }
  41.   //end of create role
  42.  
  43.   let failedmutetime = new Discord.RichEmbed()
  44.   .setTitle("Failed!")
  45.   .setColor("RANDOM")
  46.   .setDescription("You didn't specify a time period for the person to be muted!")
  47.   let mutetime = args[1];
  48.   if(!mutetime) return message.reply(failedmutetime);
  49.  
  50.   let success = new Discord.RichEmbed()
  51.   .setTitle("Successful Mute!")
  52.   .setColor("RANDOM")
  53.   .setDescription(`<@${message.author.id}>, you have muted <@${tomute.id}> for ${ms(ms(mutetime))}`)
  54.  
  55.   await(tomute.addRole(muterole.id));
  56.   message.reply(success);
  57.  
  58.  
  59. let removemute = new Discord.RichEmbed()
  60. .setTitle("Unmuted!")
  61. .setColor("RANDOM")
  62. .setDescription(`<@${tomute.id}> has been unmuted!`)
  63.   setTimeout(function(){
  64.     tomute.removeRole(muterole.id);
  65.     message.channel.send(removemute);
  66.   }, ms(mutetime));
  67.  
  68. }
  69.  
  70. module.exports.help = {
  71.     name: "mute",
  72.     aliases: ["tempmute"]
  73. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top