您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python从特定角色获取所有成员列表

Python从特定角色获取所有成员列表

重写分支提供了一个attributeRole.members

在异步分支上,您必须遍历服务器的所有成员并检查其角色。

@bot.command(pass_context=True)  
async def getuser(ctx, role: discord.Role):
    role = discord.utils.get(ctx.message.server.roles, name="mod")
    if role is None:
        await bot.say('There is no "mod" role on this server!')
        return
    empty = True
    for member in ctx.message.server.members:
        if role in member.roles:
            await bot.say("{0.name}: {0.id}".format(member))
            empty = False
    if empty:
        await bot.say("Nobody has the role {}".format(role.mention))
python 2022/1/1 18:50:34 有532人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶