Runtime Warning:Coroutine' SaimeCode'从未等待过。启用TraceMalloc获得对象分配跟踪(Telebot)
我遇到此错误的代码部分。
@bot.message_handler(commands=['redeemcode'])
def get_code(message):
code = bot.send_message(chatid, "Send the Code to Redeem")
bot.register_next_step_handler(code, claimcode)
async def claimcode(message):
code = str(message.text)
print(code)
await client.redeem_code(code)
我遇到的错误。
Microsoft Windows [Version 10.0.19044.1645]
(c) Microsoft Corporation. All rights reserved.
D:\Genshin Bot>C:/Python310/python.exe "d:/Genshin Bot/genshinbot.py"
C:\Python310\lib\site-packages\telebot\util.py:89: RuntimeWarning: coroutine 'claimcode' was never awaited
task(*args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
有人可以帮助并告诉代码怎么了
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在尝试在普通功能中调用coroutine。使用
asyncio.run
。要了解有关Coroutines和任务的更多信息,您可以参考此链接:。上面的代码段可以更改为:
You are trying to call a coroutine inside a normal function. Use
asyncio.run
. To learn more about coroutines and tasks, you can refer to this link: https://docs.python.org/3/library/asyncio-task.html.The code snippet from above can be changed to: