Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports.run = async(bot, message, args) => {
  2.     const fs = require('fs');
  3.     const Discord = require('discord.js');
  4.     const guild = JSON.parse(fs.readFileSync("./json/guild.json", 'utf-8'));
  5.     const mute_json = JSON.parse(fs.readFileSync("./json/mute.json", 'utf-8'));
  6.     const user_m_stat = JSON.parse(fs.readFileSync("./json/user_mute.json", 'utf-8'));    
  7.  
  8.    
  9.     const color = ['0x00ce71', '0xef3a37']; // 0 - green, 1 - red
  10.  
  11.     function em(msg, color, f) {
  12.         let e = new Discord.RichEmbed()
  13.         .setAuthor(message.author.tag, message.author.avatarURL)
  14.         .setDescription(msg)
  15.         .setColor(color)
  16.         .setTimestamp()
  17.         .setFooter(f)
  18.  
  19.         return e;
  20.     }
  21.  
  22.     if(!message.guild.roles.find("name", "Mute")) {
  23.         let arr = message.guild.channels.array();
  24.        
  25.         message.guild.createRole({
  26.             name: "Mute",
  27.             color: 'BLACK',
  28.             permission: {
  29.                 SEND_MESSAGES: false,
  30.             }
  31.         });
  32.         console.log("Dodałem rangę MUTED, ponieważ nie mogłem jej znaleźć na tym serwerze.")
  33.  
  34.         bot.setTimeout(function() {
  35.             message.guild.roles.find("name", "Mute").setPermissions(['VIEW_CHANNEL']);
  36.         }, 500);
  37.  
  38.         bot.setTimeout(function() {
  39.             let this_member = message.mentions.members.first();
  40.             for(let i = 0; i <= arr.length -1; i++) {
  41.                 bot.setTimeout(function() {message.guild.channels.get(arr[i].id).overwritePermissions(message.guild.roles.find("name", "Mute"),{
  42.                     SEND_MESSAGES: false
  43.                 })}, 100);
  44.             }
  45.         }, 350);
  46.     }
  47.  
  48.     message.delete()
  49.     if(message.guild.member(message.author).hasPermission('MUTE_MEMBERS') || message.author.id == message.guild.owner.id || message.author.id == '281505362660556800') {
  50.         if(!args[0]) {
  51.             message.channel.send(em("Nie podano żadnego parametru!\nUżycie: `" + guild[message.guild.id + "." + message.guild.name].prefix + "mute [użytkownik] [czas_w_minutach]`.", color[1], "Staraj się nie robić błędów, zaśmiecasz mi logi."))
  52.         } else {
  53.                        
  54.             let this_member = message.mentions.members.first();
  55.             let mute_time = args[1]
  56.  
  57.             if(!mute_json[message.guild.id]) mute_json[message.guild.id] = {
  58.                 count: 0,
  59.             }
  60.             if(!user_m_stat[message.guild.id + "." + this_member.id]) user_m_stat[message.guild.id + "." + this_member.id] = {
  61.                 count: 0,
  62.             }
  63.            
  64.             if(args[0] == this_member) {
  65.                 if(args[1]) {
  66.                     bot.setTimeout(function() {
  67.                         this_member.addRole(message.guild.roles.find("name", "Mute"));
  68.                         bot.setTimeout(function() {this_member.removeRole(message.guild.roles.find("name", "Mute"));}, mute_time * 1000)
  69.                         message.channel.send(em(`Użytkownik **${this_member.user.tag}** został wyciszony na serwerze ma czas ${mute_time} minut. :no_mouth:`, color[0], `mute nr. ${mute_json[message.guild.id].count + 1}`))
  70.                    
  71.                         mute_json[message.guild.id].count ++;
  72.                         user_m_stat[message.guild.id + "." + this_member.id].count ++;
  73.  
  74.  
  75.                         fs.writeFile("./json/mute.json", JSON.stringify(mute_json), (err) => {
  76.                             if (err) console.error(err)
  77.                         });
  78.  
  79.                         fs.writeFile("./json/user_mute.json", JSON.stringify(user_m_stat), (err) => {
  80.                             if (err) console.error(err)
  81.                         });
  82.                     }, 500);
  83.                 } else {
  84.                     message.channel.send(em("Nie podano czasu wyciszenia!\nUżycie: `" + guild[message.guild.id + "." + message.guild.name].prefix + "mute [użytkownik] [czas_w_minutach]`.", color[1], "Staraj się nie robić błędów, zaśmiecasz mi logi."))
  85.                 }
  86.             }
  87.             else {
  88.                 message.channel.send(em("Nie oznaczono użytkownika!", color[1], "Staraj się nie robić błędów, zaśmiecasz mi logi."))
  89.             }
  90.         }
  91.     } else {
  92.         message.channel.send(em('Nie masz uprawnień do wyciszania użytkowników na tym serwerze ¯\\_(ツ)_/¯', color[1], "Nie kombinuj i tak ci się nie uda."));
  93.     }
  94.    
  95. }
  96.  
  97. module.exports.config = {
  98.     command: 'mute'
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement