【问题标题】:tried to make a discord bot , but gave an error:试图制作一个不和谐的机器人,但给出了一个错误:
【发布时间】:2022-01-26 23:49:12
【问题描述】:
#cod
import discord
from discord.ext import commands

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

Traceback(最近一次调用最后一次):文件“E:\PyCharm\bot\Bot_state.py”,第 4 行,在 client = discord.Client(intents = discord.Intents().all)文件“E:\ PyCharm\bot\lib\site-packages\discord\client.py",第 248 行,在 __init__self._connection = self._get_state(**options)File "E:\PyCharm\bot\lib\site-packages\discord\ client.py",第 265 行,在 _get_statereturn ConnectionState(dispatch=self.dispatch, handlers=self._handlers,File "E:\PyCharm\bot\lib\site-packages\discord\state.py",第 152 行,在__init__raise TypeError('intents parameter must be Intent not %r' % type(intents))TypeError: intents parameter must be Intent not

【问题讨论】:

    标签: python discord


    【解决方案1】:

    你忘了打电话给all()。因此,错误消息表明您正在尝试将方法 all 作为参数而不是 Intent 传递(调用 all() 应该返回什么)。

    这是正确的代码:

    #cod
    import discord
    from discord.ext import commands
    
    client = discord.Client(intents = discord.Intents().all())
    

    【讨论】:

    • 非常感谢,我是新来的,顺便说一句,我住在俄罗斯,今年 13 岁
    猜你喜欢
    • 2021-08-19
    • 2021-05-03
    • 2021-11-28
    • 1970-01-01
    • 2021-09-11
    • 2021-06-27
    • 1970-01-01
    • 2023-01-05
    • 1970-01-01
    相关资源
    最近更新 更多