Два варианта которые вижу я:
1. Рекурсивная функция
async def give_me_not_in_roles(members, roles): # members: List[discord.Member], roles: List[discord.Role]
member = random.choice(members)
if any(role in member.roles for role in roles):
return await give_me_not_in_roles(members, roles)
return member
@client.command(name="random")
@commands.has_permissions(administrator = True)
async def rnd(ctx, members: commands.Greedy[discord.Member], *roles: discord.Role): # https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Greedy
m = await give_me_not_in_roles(members, roles)
await ctx.send(f"{m.mention} won a whole nothing!")
2. Составлять список всех кто не в указанных ролях:
@client.command(name="random")
@commands.has_permissions(administrator = True)
async def rnd(ctx, members: commands.Greedy[discord.Member], *roles: discord.Role): # https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Greedy
filtered = [m for m in members if not any(m in r.members for r in roles)]
m = random.choice(filtered)
await ctx.send(f"{m.mention} won a whole nothing!")