在我的不和谐机器人中有一个 on_message 事件,它检查数据库中用户的存在,最后它说:bot.process_commands(message)
,它给出了一个错误:
RuntimeWarning: coroutine 'BotBase.process_commands' was never awaited bot.process_commands(message) RuntimeWarning: Enable tracemalloc to get the object allocation traceback
这是完整的代码:
@bot.event
async def on_message(message):
if cursor.execute("SELECT id FROM users WHERE id = ?", (message.author.id,)).fetchone() is None:
cursor.execute(f"INSERT INTO users VALUES ({message.author.id}, 100, 'Нету', 0, 0)")
conn.commit()
cursor.execute(f"INSERT INTO inventory VALUES ({message.guild.id}, {message.author.id}, '')")
bot.process_commands(message)
怎么修?
因为 您正在使用
process_commands()
异步功能,您需要使用await