Python change_presence() takes 1 positional argument but 2 were given

2024-04-29 00:22:00 发布

您现在位置:Python中文网/ 问答频道 /正文

Task exception was never retrieved
future: <Task finished coro=<on_player_stop() done, defined at /home/pi/Desktop/EbayBot/musicbot/bot.py:413> exception=TypeError('change_presence() takes 1 positional argument but 2 were given',)>
Traceback (most recent call last):

  File "/usr/local/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(value)

  File "/home/pi/Desktop/EbayBot/musicbot/bot.py", line 414, in on_player_stop
    await self.update_now_playing()

  File "/home/pi/Desktop/EbayBot/musicbot/bot.py", line 467, in update_now_playing
    await self.change_presence(game)

TypeError: change_presence() takes 1 positional argument but 2 were given

我的代码是:

^{pr2}$

Tags: inpyhometaskbotlineexceptionpi
1条回答
网友
1楼 · 发布于 2024-04-29 00:22:00

正如错误消息所说,change_presence不接受任何位置参数(除了self)。所有其他参数必须作为关键字参数传递。在

await self.change_presence(game=game)

the docs。(注意函数签名中的星号。)

change_presence(*, game=None, status=None, afk=False)

相关问题 更多 >