Error with mute command

Hello everyone, I have this error in my mute command … can someone help me?
if (message.content.includes(“discord.gg”) || message.content.includes(“https://discord.gg”)) {
message.author.roles.add(“725104931400319098”)
}

With that, the following error happens
UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘add’ of undefined

Hello, message.author is a user object, what it means is that, it classifies it under a discord user instead of a discord member object, therefore you cannot add role to a discord user. What you should so is

message.member instead of message.author.

Let me know if it works.

2 Likes

OwO Thank you! Solved it here!