Skip to content

Commit

Permalink
[V3] Fixes issue preventing token reset from setup (#1771)
Browse files Browse the repository at this point in the history
* fixes issue preventing token reset.

Also removes a faulty assumption about not needing cleanup tasks

* Update __main__.py

remove unneeded condition
  • Loading branch information
Michael H authored and tekulvw committed Jun 2, 2018
1 parent 741f3cb commit a0a2976
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions redbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("> "):
Expand All @@ -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)

Expand Down

0 comments on commit a0a2976

Please sign in to comment.