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

角色授予事件中的Discord Python

角色授予事件中的Discord Python

首先,您必须检查用户是否具有新角色。然后,您可以检查他们所担任的角色是您所寻找的角色之一:

@bot.event
async def on_member_update(before, after):
    if len(before.roles) < len(after.roles):
        new_role = next(role for role in after.roles if role not in before.roles)
        if new_role.name in ('android', 'human'):
            fmt = "{0.mention} your role request has been accepted! :confetti_ball: You've been granted the role '{1}'"
            await bot.send_message(bot.get_channel('495285593711050754'), fmt.format(after, new_role.name))
        elif new_role.name in ('moderator'):
            fmt = "{0.mention} you are Now part of the CyberLife staff, we're so excited to have you here! :confetti_ball:"
            await bot.send_message(bot.get_channel('495285593711050754'), fmt.format(after))
python 2022/1/1 18:27:30 有362人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

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

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

请先登录

推荐问题


联系我
置顶