SHARE
TWEET

Untitled

a guest Jul 17th, 2019 62 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. const errors = require("../utils/errors.js");
  4.  
  5. module.exports.run = async (bot, message, args) => {
  6.  
  7.   //!tempmute @user 1s/m/h/d
  8.  
  9.   if(!message.member.hasPermission("MANAGE_MESSAGES")) return errors.noPerms(message, "MANAGE_MESSAGES");
  10.  
  11.  
  12.   let reason = args.slice(2).join(" ");
  13.   if(!reason) return errors.noReason(message.channel);
  14.  
  15.   let tomute = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
  16.   if(!tomute) return errors.cantfindUser(message.channel);
  17.   if(tomute.hasPermission("MANAGE_MESSAGES")) return errors.equalPerms(message, tomute, "MANAGE_MESSAGES");
  18.   let muterole = message.guild.roles.find(`name`, "muted");
  19.   //start of create role
  20.   if(!muterole){
  21.     try{
  22.       muterole = await message.guild.createRole({
  23.         name: "muted",
  24.         color: "#000000",
  25.         permissions:[]
  26.       })
  27.       message.guild.channels.forEach(async (channel, id) => {
  28.         await channel.overwritePermissions(muterole, {
  29.           SEND_MESSAGES: false,
  30.           ADD_REACTIONS: false
  31.         });
  32.       });
  33.     }catch(e){
  34.       console.log(e.stack);
  35.     }
  36.   }
  37.   //end of create role
  38.  
  39.  
  40.  
  41.  
  42.   let mutetime = args[1];
  43.   if(!mutetime) return errors.noTime(message.channel);
  44.  
  45.  
  46.  
  47.  
  48.   let muteembed = new Discord.RichEmbed()
  49.   .setTitle("<:wd_banhammer:598810920365326338> Mute Log")
  50.   .setColor("#7289da")
  51.   .addField(":x: | Muted User", tomute)
  52.   .addField(":x: | Muted in", message.channel)
  53.    .addField(":file_folder: | Muted By", `<@${message.author.id}> cu id-ul ${message.author.id}`)
  54.   .addField(":alarm_clock: | Time", message.createdAt)
  55.   .addField(":scroll: | Reason", reason)
  56.   .addField(":scroll: | Length", mutetime);
  57.  
  58.  
  59.  
  60.   let incidentschannel = message.guild.channels.find(`name`, "mod-logs");
  61.   incidentschannel.send(muteembed);
  62.  
  63.   await(tomute.addRole(muterole.id));
  64.  
  65.  
  66.   await(tomute.addRole(muterole.id));
  67.   message.reply(`<@${tomute.id}> a primit mute pentru ${ms(ms(mutetime))}`);
  68.  
  69.  
  70.   setTimeout(function(){
  71.     tomute.removeRole(muterole.id);
  72.     message.channel.send(`<@${tomute.id}> a primit unmute!`);
  73.   }, ms(mutetime));
  74.  
  75.  
  76. //end of module
  77. }
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. module.exports.help = {
  85.   name: "tempmute"
  86. }
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