0

В моем боте в дискорд есть ивент 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)

Как исправить?

2
  • В тексте ошибки написано, что асинхронная вызывается не асинхронно. Добавьте await перед process_commands
    – denisnumb
    17 июн 2022 в 11:46
  • Спасибо, а то я бы долго не понимал
    – heyman
    17 июн 2022 в 11:52

1 ответ 1

0

Т.к. вы используете process_commands() в ассинхронной функции вам нужно использовать await

await bot.process_commands(message)

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.