Python36 Discord Bot:任务已被破坏,但处于待处理状态
Posted
技术标签:
【中文标题】Python36 Discord Bot:任务已被破坏,但处于待处理状态【英文标题】:Python36 Discord Bot: Task was destroyed but it is pending 【发布时间】:2018-05-30 18:03:36 【问题描述】:当我运行我的机器人时,我收到了这个错误:
TypeError: __init__() got an unexpected keyword argument 'timestamps'
Task was destroyed but it is pending!
我将发布完整的代码(不包括机器人令牌),以便有人可以帮助我找到这个问题。基本上,这个机器人在很长一段时间内都运行良好,并且经历了以前从未出现过任何问题的各种不同版本。我通常会犯一个简单的错误并且必须修复它。但是,我使用另一个 discord bot 的依赖批处理代码来自动获取插件及其最新版本。我认为当 Discord、Python 或其他一些插件更新时,它会导致这个问题破坏当前代码。
我的不和谐机器人代码的链接在这里: https://pastebin.com/Sp8jjSDb
注意:最后的 client.Close() 是新的,并且是一个测试,看看它是否能解决问题。我原本不需要它在那里。
这里是完整的调试日志,感兴趣的人可以参考:
Traceback (most recent call last):
File "C:\Users\*****\MusicBot_2\app.py", line 1027, in <module>
client.run('[TOKEN HIDDEN]')
File "C:\Program Files\Python36\lib\discord\client.py", line 519, in run
self.loop.run_until_complete(self.start(*args, **kwargs))
File "C:\Program Files\Python36\lib\asyncio\base_events.py", line 466, in run_
until_complete
return future.result()
File "C:\Program Files\Python36\lib\discord\client.py", line 491, in start
yield from self.connect()
File "C:\Program Files\Python36\lib\discord\client.py", line 448, in connect
yield from self.ws.poll_event()
File "C:\Program Files\Python36\lib\discord\gateway.py", line 431, in poll_eve
nt
yield from self.received_message(msg)
File "C:\Program Files\Python36\lib\discord\gateway.py", line 390, in received
_message
func(data)
File "C:\Program Files\Python36\lib\discord\state.py", line 509, in parse_guil
d_create
server = self._get_create_server(data)
File "C:\Program Files\Python36\lib\discord\state.py", line 483, in _get_creat
e_server
server._from_data(data)
File "C:\Program Files\Python36\lib\discord\server.py", line 218, in _from_dat
a
self._sync(guild)
File "C:\Program Files\Python36\lib\discord\server.py", line 245, in _sync
member.game = Game(**game) if game else None
TypeError: __init__() got an unexpected keyword argument 'timestamps'
Task was destroyed but it is pending!
task: <Task pending coro=<ConnectionState._delay_ready() running at C:\Program F
iles\Python36\lib\discord\state.py:173> wait_for=<Future pending cb=[<TaskWakeup
MethWrapper object at 0x0000000003B83108>()]>>
Press any key to continue . . .
【问题讨论】:
【参考方案1】:我找到了解决方案:我运行的是较新版本的 Python,由于某种原因导致机器人出错。这可以通过强制它运行“python35”而不是更高版本来解决。
【讨论】:
以上是关于Python36 Discord Bot:任务已被破坏,但处于待处理状态的主要内容,如果未能解决你的问题,请参考以下文章
多对多 EF Core 已被跟踪 - C# Discord Bot
Discord Python Bot 在使用后台任务时破坏了我的命令