Discord.Net icon indicating copy to clipboard operation
Discord.Net copied to clipboard

will someone PLEASE tell me how to check if a user has a certain role

Open barry-mcockiner opened this issue 2 years ago • 2 comments

i have read every single article on every single google page and no solution works. for the love of god please help me i have destroyed my second monitor because i have been trying to do this shit for 7 hours

barry-mcockiner avatar Aug 20 '22 22:08 barry-mcockiner

get the user in the guild then do user.RoleIds.Contains(Id), don't think you read the docs

SylveonDeko avatar Aug 21 '22 01:08 SylveonDeko

I have this (this is just made quickly as I was to lazy to make it properly but it does work)

var user = (Context.User as SocketGuildUser)!;
var role = Context.Guild.GetRole(ROLE_ID);

if (user.Roles.Contains(role))
{
    // do your thing here
}

Almighty-Shogun avatar Sep 04 '22 02:09 Almighty-Shogun