-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
37 lines (30 loc) · 1.05 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from os import system
from bot import Bot
from disnake.errors import HTTPException
def launch():
"""
Launches the bot and handles exceptions.
This function creates an instance of the Bot class, loads the necessary cogs,
and runs the bot using the token from the configuration. It also handles
HTTPException and other exceptions, logging any errors that occur.
If the bot is temporarily banned by Discord, it attempts to fix the issue
by restarting the bot.
Note: This function assumes that the Bot class and its dependencies are properly imported.
"""
bot = Bot()
config = bot.config
bot.remove_command("help")
bot.load_cogs("cogs")
try:
bot.run(config.token)
except HTTPException:
print("Bot has been temporarily banned by Discord")
system("kill 1")
print("Trying fix...")
try:
bot.run(config.token)
except HTTPException:
bot.logger.error("Temporarily banned!")
except Exception as error:
bot.logger.exception(error)
launch()