NOTE = This is Discord.js@11.6.4 Im try to make mute commands but its not working
NOTE = This is Discord.js@11.6.4 Im try to make mute commands but its not working
NOTE = This is Discord.js@11.6.4 Im try to make mute commands but its not working
if (command === 'mute') { if (message.member.hasPermission('MUTE_MEMBERS')) {
let person = message.guild.member(message.mentions.users.first() || message.guild.member.get(args[1]))
if (!person) return message.reply('could not find that user.');
let mainrole = message.guild.roles.find(role => role.name === 'Member');
let muterole = message.guild.roles.find(role => role.name === 'Muted');
let time = args[1];
if (mainrole) {
message.guild.defaultRole.setPermissions(0);
}
if (!muterole) {
message.channel.send('This server does not include a mute role... I will created one');
console.log('This server has no mute role...creating one.');
message.guild.createRole({
name: 'Muted',
color: 'GREY',
permissions: ['VIEW_CHANNEL', 'READ_MESSAGES', 'READ_MESSAGE_HISTORY']
}).then(role => console.log(`Created ${role.name} which has the color of ${role.color} for ${message.guild.name}`)).catch(console.error);
message.channel.send('Mute role has been created for the server!\n Retype the command to mute the user, since the role was not created before.')
} else
if (!time) {
return message.reply('please enter a time to mute the user for.');
}
person.removeRole(mainrole);
person.addRole(muterole);
message.channel.send(`@${person.user.username} has been muted for ${ms(ms(time))}`);
setTimeout(function () {
person.addRole(mainrole);
person.removeRole(muterole);
message.channel.send(`@${person.user.username} has been unmuted!`)
}, ms(time));
} else {
const testEmbed = new Discord.RichEmbed()
.setColor(0x70AFD8)
.setTitle('TEz.v_ Mute')
.addField('Require' , '**`Mute Members` Permission**')
.setThumbnail('https://i.imgur.com/GnPrVRr.png')
.setFooter('Made By TEz.v_')
.setTimestamp()
try {
message.channel.send(testEmbed);
} catch {
message.reply(`sorry <@${message.author.username}> i cannot message you, make sure your dms are turned to public.`)
}
}
}