mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
parent
ef8b57a1d2
commit
a7987a83fd
@ -288,7 +288,18 @@ def handle_edit(cli_flags: Namespace):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
async def run_bot(red: Red, cli_flags: Namespace) -> NoReturn:
|
async def run_bot(red: Red, cli_flags: Namespace) -> None:
|
||||||
|
"""
|
||||||
|
This runs the bot.
|
||||||
|
|
||||||
|
Any shutdown which is a result of not being able to log in needs to raise
|
||||||
|
a SystemExit exception.
|
||||||
|
|
||||||
|
If the bot starts normally, the bot should be left to handle the exit case.
|
||||||
|
It will raise SystemExit in a task, which will reach the event loop and
|
||||||
|
interrupt running forever, then trigger our cleanup process, and does not
|
||||||
|
need additional handling in this function.
|
||||||
|
"""
|
||||||
|
|
||||||
driver_cls = drivers.get_driver_class()
|
driver_cls = drivers.get_driver_class()
|
||||||
|
|
||||||
@ -335,7 +346,6 @@ async def run_bot(red: Red, cli_flags: Namespace) -> NoReturn:
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
try:
|
try:
|
||||||
await red.start(token, bot=True, cli_flags=cli_flags)
|
await red.start(token, bot=True, cli_flags=cli_flags)
|
||||||
# This raises SystemExit in normal use at close
|
|
||||||
except discord.LoginFailure:
|
except discord.LoginFailure:
|
||||||
log.critical("This token doesn't seem to be valid.")
|
log.critical("This token doesn't seem to be valid.")
|
||||||
db_token = await red._config.token()
|
db_token = await red._config.token()
|
||||||
@ -344,7 +354,9 @@ async def run_bot(red: Red, cli_flags: Namespace) -> NoReturn:
|
|||||||
await red._config.token.set("")
|
await red._config.token.set("")
|
||||||
print("Token has been reset.")
|
print("Token has been reset.")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def handle_early_exit_flags(cli_flags: Namespace):
|
def handle_early_exit_flags(cli_flags: Namespace):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user