Answers for "discord.js mute script"

1

discord.js mute command

const Discord = require('discord.js')

exports.run = async (client, message, args) => {
  if (!message.member.hasPermission('MUTE_MEMBERS')) return message.reply('You cannot use this command');
  if (!message.guild.me.hasPermission('MANAGE_ROLES')) return message.reply('I cannot use this command as i dont have the \`MANAGE_ROLES\` Permission on my role');
  
  //Variables
  var muteRole = message.guild.roles.find(r => r.name === 'YOUR_MUTE_ROLE_NAME');
  var memberRole = message.guild.roles.find(r => r.name === 'YOUR_MAIN_MEMBER_ROLE');
  
  //let
  let member = message.mentions.members.first();
  let reason = args.slice(1).join(' ');
  if (!reason) reason = 'No Reason Given';
  
  message.member.roles.add(muteRole);
  message.member.roles.remove(memberRole);
  
  var muteEmbed = new Discord.MessageEmbed()
   .setColor('RED')
   .setTitle('${member} has been muted for ${reason}');
  
  message.channel.send(muteEmbed).catch(err => console.log(err));
}
Posted by: Guest on June-12-2021
0

discord.js mute script

client.on('message', message => {
    if(message.content.startsWith(prefix + 'mute')){
         if(message.member.hasPermission('MANAGE_ROLES')) {
             const role = message.guild.roles.cache.find(role => role.name === 'Muted');
                 const member = message.mentions.members.first();
                     member.roles.add(role); 
                     message.channel.send(member + ' Has Been Muted');

            } else {
                 message.channel.send("Please Mention Who To Mute")
             }     
        }
})
Posted by: Guest on December-27-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language