Summary
Any error during startup is completely invisible. The bot prints the same four lines no matter what went wrong and exits with code 0:
E:\...\saveload/userdata.pkl
[INFO ] discord.client: logging in using static token
. . . Saved Userdata Successfully !
--- Client disconnected ---
No traceback, no error, no hint. It looks like a clean shutdown.
Cause
Client.Save() in singletons.py ends with exit(0):
async def Save(self):
await saveload.SaveUserDict()
print_colored("--- Client disconnected ---", "red")
exit(0)
async def close(self):
await self.async_cleanup() # -> Save() -> exit(0)
await super().close()
discord.py calls close() from run()'s finally block. So when login() or connect() raises, the cleanup path fires, exit(0) raises SystemExit, and that replaces the in-flight exception before it can be printed. super().close() never runs either.
In my case two separate errors were being hidden this way: first a TypeError (token was None), then PrivilegedIntentsRequired once the token loaded.
Other things found while tracking this down
os.mknod doesn't exist on Windows. LoadUserDict() calls it when saveload/userdata.pkl is missing, so a fresh clone crashes on Windows before the bot ever starts. Even where mknod does exist, the next line runs pickle.load() on the newly created empty file and raises EOFError.
- The README never mentions privileged gateway intents.
singletons.py uses discord.Intents.all(), which requires Presence, Server Members and Message Content to be enabled in the developer portal. Without them the bot dies with PrivilegedIntentsRequired — which, thanks to the above, you can't see.
.env files aren't supported. The README only documents a system environment variable, so dropping a .env next to main.py (a pretty natural assumption) silently yields econtoken=None.
Repro
- Clone, don't set
econtoken.
python main.py.
- Observe the output above, exit code 0, and no clue that the token is missing.
PR incoming.
Summary
Any error during startup is completely invisible. The bot prints the same four lines no matter what went wrong and exits with code 0:
No traceback, no error, no hint. It looks like a clean shutdown.
Cause
Client.Save()insingletons.pyends withexit(0):discord.pycallsclose()fromrun()'sfinallyblock. So whenlogin()orconnect()raises, the cleanup path fires,exit(0)raisesSystemExit, and that replaces the in-flight exception before it can be printed.super().close()never runs either.In my case two separate errors were being hidden this way: first a
TypeError(token wasNone), thenPrivilegedIntentsRequiredonce the token loaded.Other things found while tracking this down
os.mknoddoesn't exist on Windows.LoadUserDict()calls it whensaveload/userdata.pklis missing, so a fresh clone crashes on Windows before the bot ever starts. Even wheremknoddoes exist, the next line runspickle.load()on the newly created empty file and raisesEOFError.singletons.pyusesdiscord.Intents.all(), which requires Presence, Server Members and Message Content to be enabled in the developer portal. Without them the bot dies withPrivilegedIntentsRequired— which, thanks to the above, you can't see..envfiles aren't supported. The README only documents a system environment variable, so dropping a.envnext tomain.py(a pretty natural assumption) silently yieldsecontoken=None.Repro
econtoken.python main.py.PR incoming.