From dcd1db1d4ad599c119af58709361150c2e324f3f Mon Sep 17 00:00:00 2001 From: Etz Elia Date: Thu, 5 Mar 2020 17:38:39 +0100 Subject: [PATCH] Loop MCM bot (#47) Loop Signed-off-by: Etzelia Co-authored-by: Etzelia Reviewed-by: ZeroHD --- bot/discord.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bot/discord.py b/bot/discord.py index 0a4ebd8..993cc37 100644 --- a/bot/discord.py +++ b/bot/discord.py @@ -108,13 +108,17 @@ class Discord(commands.Bot): def run_bot(self): global discord_loop - try: - discord_loop.run_until_complete(self.start(self.token)) - except KeyboardInterrupt: - logger.info("Bot received keyboard interrupt") - except Exception as e: - print(e) - logger.info('Bot encountered the following unhandled exception %s', e) + loop = True + while loop: + try: + discord_loop.run_until_complete(self.start(self.token)) + except KeyboardInterrupt: + logger.info("Bot received keyboard interrupt") + loop = False + except Exception as e: + print(e) + logger.info('Bot encountered the following unhandled exception %s', e) + loop = False def start():