From b266db5bf3258e9b83693794231711150dade7d3 Mon Sep 17 00:00:00 2001 From: Michal Tuszowski Date: Wed, 8 Jul 2026 00:26:02 +0200 Subject: [PATCH] fix: Client.start() takes no log_handler kwarg (run()-only) log_handler belongs to Client.run() (which configures logging and then calls start()); passing it to start() raised TypeError at launch. This was inherited from the never-run dockerised variant's thin_client.py. We configure our own handlers, so simply drop the kwarg. Also set logger.propagate=False: a dependency calls logging.basicConfig(), so every 'discord' record was printed twice (our format + root's). Verified with a strict-signature stub client (start(token, *, reconnect)). Co-Authored-By: Claude Opus 4.8 --- bot.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index bbcb1e5..dd28937 100755 --- a/bot.py +++ b/bot.py @@ -62,6 +62,9 @@ console_handler = logging.StreamHandler() console_handler.setLevel(logging.INFO) console_handler.setFormatter(formatter) logger.addHandler(console_handler) +# Some dependency calls logging.basicConfig(), adding a root handler; without +# this the 'discord' logger's records get printed twice (our format + root's). +logger.propagate = False # *=========================================== Initializations intents = discord.Intents.default() @@ -238,7 +241,10 @@ async def _run_bot(token: str, shutdown_event: asyncio.Event) -> None: docker). Now every death is diagnosed on the console first. """ try: - await client.start(token, log_handler=None) + # NOTE: log_handler is a Client.run()-only kwarg (run() configures + # logging, then calls start()); start() takes just the token. We set + # up our own handlers above, so nothing is lost. + await client.start(token) except discord.LoginFailure: logger.critical( "FATAL: Discord REJECTED the token (Improper token). Fix the "