我有一个不和谐的机器人,但是on_ready总是给我一个错误:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 333, in _run_event
await coro(*args, **kwargs)
TypeError: on_ready() missing 1 required positional argument: 'self'
这是我的代码
@client.event
async def on_ready():
print("Connected")
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=" for *help"))
它曾经可以工作,但现在却不行,为什么?
答案 0 :(得分:0)
如果删除self
自变量会怎样?
据我所知,仅在类对象中定义了函数时才放入self
参数。因此,宁可删除它,也可以将代码重写/扩展为类对象函数。