if(msg.member.roles.has(role.id)){
console.log("1");
}
else{
console.log("0");
}
it always prints 0 no matter what even if i have the role.
i can assign the role using role.id too but even then the check will always fail
(this isnt the exact code im using its just an example)
The issue template is there for a reason, please don't delete it but instead fill it out.
Please further provide a reproducible minimal code sample (focusing on the issue, that - when plugged into a fresh bot - still reproduces the issue you are experiencing on your other bot)
Further please provide the version of discord.js you are using (npm ls discord.js gives you that information)
If you are getting the role ID from a database please make sure you don't save it as number as javascripts accuracy is not enough to not truncate snowflakes (IDs) when converting them from a string to a number type in order to insert/retrieve it.
Generally make sure you provide the role ID as string and log role to make sure it even is a discord.js Role object in the first place.
With the provided information i can not reproduce this behavior on 11.5.1, 11.5-dev, or 12.0.0-dev at the time.
The GuildMember class does not have a method called hasroles(), but it does have a method called hasPermissions() which you can pass a flag from here as the first parameter and a boolean will be returned.
Alternatively, you can access the property roles of the GuildMember class which returns a Collection and can use .get() to find a role with a specified ID.