UnMute Command. Don't umute the user

Hi, when i want to unmute someone It’s just say this user is not mute i don’t know how i can resolve this.
Below is the unmute command

const Discord = require("discord.js");
const ms = require("ms");

module.exports.run = async (bot, message, args) => {
  if (args[0] == "help") {
    message.reply(`Usage: c!unmute [user]`);

  let xdemb = new Discord.MessageEmbed()
    .setTitle(`UnMute Command <:info:713344071816446039>`)
    .addField("Description:", "`UnMute a member`" + "\n")
    .addField("Usage", "`c!unmute <@user>`" + "\n")
    .addField("Example", "`c!unmute @ur mom`");
const embed = new Discord.MessageEmbed()
  .setDescription("<:x1:715859799585325086> **| You don't have permission (**__`MANAGE_MESSAGES`__**)**")
const embed2 = new Discord.MessageEmbed()
  .setDescription("<:x1:715859799585325086> **| I can't UnMute this user**")
if (!message.member.hasPermission("MANAGE_MESSAGES"))
    return message.channel.send(embed)
  let toMute = message.mentions.users.first() || message.guild.members.cache.get(args[0]);
if (!toMute) return message.channel.send(xdemb);
const embed3 = new Discord.MessageEmbed()
  .setDescription("<:x1:715859799585325086> **| This user is not muted**")
let role = message.guild.roles.cache.find(val => val.name === "Muted");
    return message.channel.send(embed3)
        if(!role || !toMute.roles.has(role.id)) return message.channel.send(embed3);

        await toMute.removeRole(role);
  const embed4 = new Discord.MessageEmbed()
  .setDescription(`<:good:715860337865392130> **| <@${toMute.id}> has been unmuted!**`)

module.exports.help = {
  name: "unmute"

Help me please

You’re using .cache on a RoleManager which is only a thing v12+

Also, if you want a faster and better answer, you should go to the Official Discord.js Discord Server.

There’s one major problem that you’re overlooking.
You’re using
let role = message.guild.roles.cache.find(val => val.name === "Muted");
which is only on discord.js v12, but then you’re also using
as well as
if (!message.member.hasPermission("MANAGE_MESSAGES"))
which is only available on v11 and earlier.

Make sure you update all the code to v12.

1 Like

Thanks bro <333333333333333333

@Ghostoblivion Can you help me on my question ENEOT Error?