【问题标题】:Discord bot cannot see member updatesDiscord bot 看不到成员更新
【发布时间】:2021-07-19 11:31:19
【问题描述】:

我已经编写了一个不和谐的机器人来使用 discord.py 和 discord.ext.commands,到目前为止它一直在按预期工作。但是,无论我尝试什么,我似乎都无法看到会员更新。 这是设置意图的代码

#declare our intents
intents = discord.Intents.default()
intents.members = True
intents.presences = True
#client settings, load intents
client = discord.Client(intents=intents)
client = commands.Bot(command_prefix = "!", guild_subscriptions=True)

这是应该看到成员更新的代码

@client.event
async def on_member_update(before, after):
    print("just saw a member update!")

我还在应用程序门户中启用了状态和成员特权意图,并且该机器人在服务器上具有完全的管理员权限,并且在服务器所有者之下具有最高级别。代码有问题,还是有其他因素阻止它看到更新?是否需要手动授予一些权限?它可以在同一服务器中使用几乎相同的代码查看 on_voice_state_update 和 on_message 事件。

【问题讨论】:

  • 你做了什么来调用member_update事件?
  • 我尝试过改变角色、昵称、状态。根据 API 文档,当其中任何一个发生更改时应该调用它:状态活动昵称角色待定

标签: discord discord.py


【解决方案1】:

您正在分配一个启用了成员意图的Client,他们立即用具有默认意图的Bot 覆盖它(因此禁用了成员意图)。

将您的意图传递到 Bot 创建中。

#declare our intents
intents = discord.Intents.default()
intents.members = True
intents.presences = True
#client settings, load intents
client = commands.Bot(command_prefix = "!", guild_subscriptions=True, intents=intents)

【讨论】:

    猜你喜欢
    • 2021-07-05
    • 2021-06-18
    • 2021-01-21
    • 2021-10-11
    • 2021-08-11
    • 2021-02-15
    • 1970-01-01
    • 2021-05-07
    • 2021-04-15
    相关资源
    最近更新 更多