diff --git a/redbot/__main__.py b/redbot/__main__.py index ad28cb383..e12fcc891 100644 --- a/redbot/__main__.py +++ b/redbot/__main__.py @@ -139,18 +139,16 @@ def main(): sys.exit(0) if tmp_data["enable_sentry"]: red.enable_sentry() - cleanup_tasks = True try: loop.run_until_complete(red.start(token, bot=not cli_flags.not_bot)) except discord.LoginFailure: - cleanup_tasks = False # No login happened, no need for this log.critical( "This token doesn't seem to be valid. If it belongs to " "a user account, remember that the --not-bot flag " "must be used. For self-bot functionalities instead, " "--self-bot" ) - db_token = red.db.token() + db_token = loop.run_until_complete(red.db.token()) if db_token and not cli_flags.no_prompt: print("\nDo you want to reset the token? (y/n)") if confirm("> "): @@ -165,10 +163,9 @@ def main(): sentry_log.critical("Fatal Exception", exc_info=e) loop.run_until_complete(red.logout()) finally: - if cleanup_tasks: - pending = asyncio.Task.all_tasks(loop=red.loop) - gathered = asyncio.gather(*pending, loop=red.loop, return_exceptions=True) - gathered.cancel() + pending = asyncio.Task.all_tasks(loop=red.loop) + gathered = asyncio.gather(*pending, loop=red.loop, return_exceptions=True) + gathered.cancel() sys.exit(red._shutdown_mode.value)