daily pastebin goal
50%
SHARE
TWEET

tempmute

a guest Dec 16th, 2018 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require("discord.js");
  2. const ms = require("ms");
  3.  
  4. module.exports.run = async (bot, message, args) => {
  5.  
  6.   //!tempmute @user 1s/m/h/d
  7.  
  8.   let tomute = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  9.   if(!tomute) return message.reply("Couldn't find user.");
  10.   if(tomute.hasPermission("KICK_MEMBERS")) return message.reply("User is immune to mutes");
  11.   let muterole = message.guild.roles.find(`name`, "muted");
  12.   //start of create role
  13.   if(!muterole){
  14.     try{
  15.       muterole = await message.guild.createRole({
  16.         name: "muted",
  17.         color: "#000000",
  18.         permissions:[]
  19.       })
  20.       message.guild.channels.forEach(async (channel, id) => {
  21.         await channel.overwritePermissions(muterole, {
  22.           SEND_MESSAGES: false,
  23.           ADD_REACTIONS: false
  24.         });
  25.       });
  26.     }catch(e){
  27.       console.log(e.stack);
  28.     }
  29.   }
  30.   //end of create role
  31.   let mutetime = args[1];
  32.   if(!mutetime) return message.reply("You didn't specify a time!");
  33.  
  34.   await(tomute.addRole(muterole.id));
  35.   message.reply(`<@${tomute.id}> has been muted for ${ms(ms(mutetime))}`);
  36.  
  37.   setTimeout(function(){
  38.     tomute.removeRole(muterole.id);
  39.     message.channel.send(`<@${tomute.id}> has been unmuted!`);
  40.   }, ms(mutetime));
  41.  
  42.  
  43. //end of module
  44. }
  45.  
  46. module.exports.help = {
  47.   name: "tempmute"
  48. }
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