【问题标题】:Make the bot wait for role removal in discord.py让机器人等待 discord.py 中的角色移除
【发布时间】:2020-12-13 12:26:46
【问题描述】:

我试图让机器人等待特定角色被删除以执行操作,我所达到的最远距离是在机器人角色更改时使其执行操作(无论是否添加或删除) ,但这不是我想要的。 我假设它与检查有关,我不确定如何设置,这是我尝试过的:

def check(member, role):
    return role not in member.roles
disable = await bot.wait_for("member_update", check=check)
if disable:
    await ctx.send("Disabled.")

任何帮助将不胜感激,在此先感谢。

【问题讨论】:

    标签: python discord discord.py discord.py-rewrite


    【解决方案1】:

    您的检查不正确,这是一个应该可以使用的示例:

    def check(member, role):
        return role.name == "name of your specific role here"
    

    这会将disable 设置为true,仅当角色名称与提供的特定角色相同时。如果您愿意,也可以使用role.id

    【讨论】:

      猜你喜欢
      • 2020-11-07
      • 1970-01-01
      • 2021-09-17
      • 2019-01-22
      • 2021-05-08
      • 2020-10-16
      • 2019-04-20
      • 2020-12-26
      • 2020-05-24
      相关资源
      最近更新 更多