Hello I have problem with my code! When I use my mute command it always spams "You need permission to use command"! Here is my code:
client.on('message', message => {
if(message.content.startsWith("$mute")) {
if (!message.member.permissions.has("KICK_MEMBERS")) return
message.channel.send("You need permissions to use command")
let role = message.guild.roles.cache.find(role => role.name === "Muted")
let member = message.mentions.members.first()
let reason = message.content.split(" ").slice(2).join(" ")
if(!reason) return message.channel.send("You didn't write a reason")
if(!role) return message.channel.send("This server don't have Muted role")
if(!member) return message.channel.send("You didn't mention the user to mute!")
member.roles.add(role)
.then(() => {
message.channel.send(`Successfully muted ${member} with reason: ${reason}`)
})
.catch(() => {
message.channel.send("Error")
})
}
})