【问题标题】:TypeError: __init__() missing 1 required keyword-only argument: 'intents'类型错误:__init__() 缺少 1 个必需的仅关键字参数:\'intents\'
【发布时间】:2022-10-06 09:53:28
【问题描述】:

我正在研究一个不和谐的数字生成器,每当我运行它时,我都需要帮助解决这个代码错误它说这个

Traceback (most recent call last):
  File \"C:/Users/Owner/PycharmProjects/pythonProject2/main.py\", line 6, in <module>
    bot = commands.Bot(command_prefix = prefix)
TypeError: __init__() missing 1 required keyword-only argument: \'intents\'
  • 我确定这已包含在 Bot API 文档中
  • 什么是 Bot API 文档?
  • 您正在使用commands.Bot。检查文档。
  • Bot API。查看Intents primer 可能也会有所帮助。

标签: python


【解决方案1】:

重新开始使用不和谐机器人时,我遇到了同样的错误。开发人员最近发布了一些较大的更新,因此我建议卸载不和谐,然后重新安装。

~$ pip uninstall discord

~$ pip install discord

然后确保您的设置意图,因为这些是我认为现在需要的(有关更多信息,请参阅 https://discordpy.readthedocs.io/en/latest/migrating.html 哈哈)

像这样的东西应该对我有用


import discord

intents = discord.Intents.default()
client = discord.Client(intents=intents)


@client.event
async def on_ready():
    print("Logged in as a bot {0.user}".format(client))

client.run('<TOKEN>')


【讨论】:

    猜你喜欢
    • 2022-08-19
    • 2022-11-17
    • 2022-10-30
    • 2022-10-09
    • 2021-06-20
    • 2021-07-06
    • 2023-03-19
    • 2020-01-29
    • 2017-10-30
    相关资源
    最近更新 更多