[英]Why do i get an error when running my discord.py code?
I always get this error code when I run my discord.py bot.当我运行我的 discord.py 机器人时,我总是得到这个错误代码。 this is the error code:
这是错误代码:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
TypeError: on_ready() missing 1 required positional argument: 'self'
This is the link to my full code:这是我完整代码的链接:
https://pastebin.com/wVftj2kF https://pastebin.com/wVftj2kF
I ran my bot before changing the "on-ready" event to include 'self' and it worked.在将“on-ready”事件更改为包含“self”之前,我运行了我的机器人并且它起作用了。 Removing 'self' breaks the "self.user" part of the command.
删除“self”会破坏命令的“self.user”部分。 I need help quick.
我需要快速帮助。 Thanks a lot if you can help.
如果您能提供帮助,非常感谢。
You don't actually need to refer to self outside of a class in order to retrieve attributes of the bot, you can just use client.您实际上不需要在 class 之外引用 self 来检索机器人的属性,您只需使用 client.
@client.event
async def on_ready():
change_status.start()
print('Logged on as {0}!'.format(client.user))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.