1const Discord = require('discord.js')
2
3exports.run = async (client, message, args) => {
4 if (!message.member.hasPermission('MUTE_MEMBERS')) return message.reply('You cannot use this command');
5 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');
6
7 //Variables
8 var muteRole = message.guild.roles.find(r => r.name === 'YOUR_MUTE_ROLE_NAME');
9 var memberRole = message.guild.roles.find(r => r.name === 'YOUR_MAIN_MEMBER_ROLE');
10
11 //let
12 let member = message.mentions.members.first();
13 let reason = args.slice(1).join(' ');
14 if (!reason) reason = 'No Reason Given';
15
16 message.member.roles.add(muteRole);
17 message.member.roles.remove(memberRole);
18
19 var muteEmbed = new Discord.MessageEmbed()
20 .setColor('RED')
21 .setTitle('${member} has been muted for ${reason}');
22
23 message.channel.send(muteEmbed).catch(err => console.log(err));
24}
1const Discord = require('discord.js');
2const client = new Discord.Client();
3const prefix = "!";
4const token = ""; // Fill in your token
5
6client.on("message", msg => {
7 msg.content.startsWith(prefix + "mute") {
8
9
10 // Variables
11 var muteRole = msg.guild.roles.find(role => role.name.toLowerCase().includes("muted"));
12 var muteChannel = msg.guild.channels.find(channel => channel.name.includes("modlogs"));
13 var muteUser = msg.mentions.members.first();
14 var muteReason = msg.content.slice(prefix.length + 27);
15
16
17 // Conditions
18 if (!msg.member.hasPermission("MANAGE_MESSAGES")) return msg.channel.send("You don't have the permissions");
19 if (!muteUser) return msg.channel.send("You have to mention a valid member");
20 if (!muteChannel) return msg.channel.send("There's no channel called modlogs");
21 if (!muteRole) return msg.channel.send("There's no role called muted");
22 if (!msg.guild.member(client.user.id).hasPermission("MANAGE_ROLES")) return msg.channel.send("I Don't have permissions");
23 if (!muteReason) muteReason = "No reason given";
24
25 // Embed
26 var muteEmbed = new Discord.RichEmbed()
27 .setTitle("Mute")
28 .addField("Muted user", muteUser)
29 .addField("Reason", muteReason)
30 .setFooter(`Muted by ${msg.author.tag}`)
31 .setTimestamp();
32
33 //Mute
34 muteUser.addRole(muteRole);
35 msg.channel.send(`${muteUser} has been muted`);
36 muteChannel.send(muteEmbed);
37
38 }
39})
1client.on('message', message => {
2 if(message.content.startsWith(prefix + 'mute')){
3 if(message.member.hasPermission('MANAGE_ROLES')) {
4 const role = message.guild.roles.cache.find(role => role.name === 'Muted');
5 const member = message.mentions.members.first();
6 member.roles.add(role);
7 message.channel.send(member + ' Has Been Muted');
8
9 } else {
10 message.channel.send("Please Mention Who To Mute")
11 }
12 }
13})