I wanted to make a Discord bot for my Server and I need help by finding out if the Person is an Mod or not.
Here’s the Code:
@client.hybrid_command(description="All Commands")
async def cmds(ctx):
if has_role('HCRP | Staff Team'):
print("Is Staff")
else:
print("Is Member")
I want it to tell me what Role the Person has but it says always is Staff.
>Solution :
@client.hybrid_command(description="all commands")
async def cmds(ctx:commands.Context):
guild = ctx.guild
role = guild.get_role(ROLE_ID)
if role in ctx.author.roles:
print("Is Staff")
else:
print("Is Member")
In this code we define the guild which is the server the command was executed on. Then use the guild.get_role() function to define the role by it’s id. Then we check if that role is the ctx.author's roles.