Advertisement
BlackB1RDD

TrueXPixels - Mute/Unmute

Oct 12th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   // Unmute/Mute Commands
  2.   // Mute Command
  3.   if (msg.startsWith(prefix + 'MUTE')) {
  4.   // Check if the user has the `Admin` role.
  5.   if (!message.member.roles.find("name", "Moderator")) { // This checks to see if they DONT have it, the "!" inverts the true/false
  6.       message.channel.send('You Need The \`Moderator or Admin\` Role To Use This Command !'); // Tells the user in chat that they need the role.
  7.       return; // This returns the code, so the rest doesn't run.
  8.   }
  9.   let reason = args.slice(1).join(' ');
  10.   let user = message.mentions.users.first();
  11.   let modlog = bot.channels.find('name', 'mod-log');
  12.   let muteRole = bot.guilds.get(message.guild.id).roles.find('name', 'Muted');
  13.   if (!modlog) return message.reply('I Cannot Find a mod-log Channel !').catch(console.error);
  14.   if (!muteRole) return message.reply('I Cannot Find a Mute Role !').catch(console.error);
  15.   if (reason.length < 1) return message.reply('You Must Supply a Reason For The Mute.').catch(console.error);
  16.   if (message.mentions.users.size < 1) return message.reply('You Must Mention Someone To Mute Them.').catch(console.error);
  17.   const embed = new Discord.RichEmbed()
  18.     .setColor(0xCB4335)
  19.     .setTimestamp()
  20.     .addField('Action:', 'Mute')
  21.     .addField('User:', `${user.username}#${user.discriminator} (UserID: ${user.id})`)
  22.     .addField('Modrator:', `${message.author.username}#${message.author.discriminator}`)
  23.     .addField('Reason', reason);
  24.  
  25.   if (!message.guild.member(bot.user).hasPermission('MANAGE_ROLES_OR_PERMISSIONS')) return message.reply('I Do Not Have The Correct Permissions.').catch(console.error);
  26.  
  27.   if (message.guild.member(user).roles.has(muteRole.id)) {
  28.     message.guild.member(user).removeRole(muteRole).then(() => {
  29.       bot.channels.get(modlog.id).sendEmbed(embed).catch(console.error);
  30.     });
  31.   } else {
  32.     message.guild.member(user).addRole(muteRole).then(() => {
  33.       bot.channels.get(modlog.id).sendEmbed(embed).catch(console.error);
  34.     });
  35.   }
  36. }
  37.  
  38.   // UnMute Command
  39.   if (msg.startsWith(prefix + 'UNMUTE')) {
  40.   // Check if the user has the `Admin` role.
  41.   if (!message.member.roles.find("name", "Moderator")) { // This checks to see if they DONT have it, the "!" inverts the true/false
  42.       message.channel.send('You Need The \`Moderator or Admin\` Role To Use This Command !'); // Tells the user in chat that they need the role.
  43.       return; // This returns the code, so the rest doesn't run.
  44.   }
  45.   let user = message.mentions.users.first();
  46.   let modlog = bot.channels.find('name', 'mod-log');
  47.   let muteRole = bot.guilds.get(message.guild.id).roles.find('name', 'Muted');
  48.   if (!modlog) return message.reply('I Cannot Find a mod-log Channel !').catch(console.error);
  49.   if (!muteRole) return message.reply('I Cannot Find a Mute Role !').catch(console.error);
  50.   if (message.mentions.users.size < 1) return message.reply('You Must Mention Someone To Mute Them.').catch(console.error);
  51.   const embed = new Discord.RichEmbed()
  52.     .setColor(0x35CB35)
  53.     .setTimestamp()
  54.     .addField('Action:', 'Unmute')
  55.     .addField('User:', `${user.username}#${user.discriminator} (UserID: ${user.id})`)
  56.     .addField('Modrator:', `${message.author.username}#${message.author.discriminator}`)
  57.     .addField('Reason', 'Mute Expired.');
  58.  
  59.   if (!message.guild.member(bot.user).hasPermission('MANAGE_ROLES_OR_PERMISSIONS')) return message.reply('I Do Not Have The Correct Permissions.').catch(console.error);
  60.  
  61.   if (message.guild.member(user).roles.has(muteRole.id)) {
  62.     message.guild.member(user).removeRole(muteRole).then(() => {
  63.       bot.channels.get(modlog.id).sendEmbed(embed).catch(console.error);
  64.     });
  65.   } else {
  66.     message.guild.member(user).addRole(muteRole).then(() => {
  67.       bot.channels.get(modlog.id).sendEmbed(embed).catch(console.error);
  68.     });
  69.   }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement