Reputation: 29
I am creating a bot for whitelisting people but I can't check if users that called the command has a role for whitelisting people I tried:
@bot.command()
async def idk(ctx):
role = discord.utils.get(ctx.guild.roles, id='892437125293813790')
if role in ctx.author.roles:
print('y')
else:
print(ctx.author.roles)
print('n')
bot its returns n everytime so I tried many different ways but this was the best I found so... I need help
Upvotes: 1
Views: 71
Reputation: 4088
The problem is at line 3 in your code, the IDs in Discord.py are always int
type.
Try this:
role = discord.utils.get(ctx.guild.roles, id=892437125293813790)
Then, there's a better way to do this:
role = ctx.guild.get_role(892437125293813790)
Upvotes: 1