Reputation: 144
I want to lock some ranks, to have only one from a board, e.g tab = [rank1, rank2, rank3, rank4, ...]
.
For example, if I have rank1
, I can't get rank2
.
My code is:
async def rank(ctx, *, role:discord.Role):
member = ctx.message.author
for i in member.roles:
for j in tab:
if j in i:
if role.name == j:
await ctx.send(f"You can't get this role")
return
The bot give ranks from this board. Any ideas?
Upvotes: 0
Views: 220
Reputation: 5157
Disregarding the improper indentation, Member.roles
returns a list of Role
s, so i
will be a Role
object.
if j in i
will raise a TypeError
since Role
objects are not iterable.
If tab
is a list of Role
objects, then you can simply check if i
is in that list.
Otherwise, if it's a list of role names, you can use the name
attribute of i
to check if it's in the list.
Upvotes: 1