【问题标题】:Python on_member_join not working with discord botPython on_member_join 无法与不和谐机器人一起使用
【发布时间】:2021-08-04 16:16:38
【问题描述】:

我的 on_member_join 命令不适用于 discord 机器人,我也不是 100% 确定原因,我尝试了多种方法,但都没有奏效(代码见下图)enter image description here

【问题讨论】:

  • 您是否为您的机器人启用了成员意图?

标签: python discord.py


【解决方案1】:

client.fetch_channel 需要输入频道 ID,而不是频道名称。

您还需要Members Intent:

您必须启用它here。选择您想要的应用程序 -> 选择 Bot -> SERVER MEMBERS INTENT,然后确保它旁边显示为蓝色。然后单击保存更改。由于您正在开发您的机器人,您可能还希望启用 Presence Intent 以节省您以后的时间。

然后您必须像这样编辑您的机器人变量:

intents = discord.Intents()
intents.all()

client = commands.Bot(command_prefix=".", intents=intents)

【讨论】:

    猜你喜欢
    • 2021-09-16
    • 2021-03-25
    • 2019-04-09
    • 2020-10-28
    • 2021-10-30
    • 2021-05-27
    • 2021-07-15
    • 2021-05-24
    • 1970-01-01
    相关资源
    最近更新 更多