你可以做这样的事情。@client.command()async def roles(ctx, *, role_wanted: discord.Role): for role in ctx.guild.roles: if role == role_wanted: for member in role.members: await ctx.send(member.name)我这样做的格式是 !roles @Role1 @Role2 等,您可以在列表中拥有任意多个角色。
所以这可能是一些代码:#Assuming this is in an on_messagex = message.guild.memberswithTheRole = []for member in x: if "ROLE" in member.roles: withTheRole.append(member.name)