【发布时间】:2018-02-26 07:21:43
【问题描述】:
我正在尝试让测试不和谐机器人的状态每十秒在两条消息之间更改一次。我需要在状态消息更改时执行脚本的其余部分,但是每当我尝试使其工作时都会弹出错误。我的脚本中有线程,但我不完全确定在这种情况下如何使用它。
@test_bot.event
async def on_ready():
print('Logged in as')
print(test_bot.user.name)
print(test_bot.user.id)
print('------')
await change_playing()
@test_bot.event
async def change_playing():
threading.Timer(10, change_playing).start()
await test_bot.change_presence(game=discord.Game(name='Currently on ' + str(len(test_bot.servers)) +
' servers'))
threading.Timer(10, change_playing).start()
await test_bot.change_presence(game=discord.Game(name='Say test.help'))
错误信息如下:
C:\Python\Python36-32\lib\threading.py:1182: RuntimeWarning: coroutine 'change_playing' was never awaited
self.function(*self.args, **self.kwargs)
【问题讨论】:
-
请编辑问题以包含实际的错误消息。
-
已编辑,感谢您指出这一点。
标签: python python-3.x python-3.6 discord.py