Spaces:
Paused
Paused
test restart_bot on error
Browse files
app.py
CHANGED
|
@@ -45,6 +45,11 @@ bot = commands.Bot(command_prefix='!', intents=intents)
|
|
| 45 |
|
| 46 |
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
@bot.event
|
|
@@ -115,7 +120,9 @@ async def give_verified_roles():
|
|
| 115 |
await asyncio.sleep(10)
|
| 116 |
|
| 117 |
except Exception as e:
|
| 118 |
-
print(f"Error encountered: {e}")
|
|
|
|
|
|
|
| 119 |
|
| 120 |
await asyncio.sleep(60)
|
| 121 |
|
|
|
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
+
## testing this, restart bot on errors
|
| 49 |
+
def restart_bot():
|
| 50 |
+
print("Restarting bot...")
|
| 51 |
+
os.execv(sys.executable, ['python'] + sys.argv)
|
| 52 |
+
|
| 53 |
|
| 54 |
|
| 55 |
@bot.event
|
|
|
|
| 120 |
await asyncio.sleep(10)
|
| 121 |
|
| 122 |
except Exception as e:
|
| 123 |
+
print(f"Error encountered, restarting bot: {e}")
|
| 124 |
+
asyncio.sleep(5)
|
| 125 |
+
restart_bot()
|
| 126 |
|
| 127 |
await asyncio.sleep(60)
|
| 128 |
|