mirror of https://github.com/miaowware/qrm2.git
main.py: added error handling for the bot task
- no mo traceback 4 me
This commit is contained in:
parent
a1da6a32e0
commit
eaace87517
21
main.py
21
main.py
|
@ -6,7 +6,6 @@ Qrm, a bot for Discord
|
||||||
[copyright here]
|
[copyright here]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import discord.ext.commands as commands
|
import discord.ext.commands as commands
|
||||||
|
|
||||||
|
@ -15,8 +14,26 @@ import info
|
||||||
import options as opt
|
import options as opt
|
||||||
import keys
|
import keys
|
||||||
|
|
||||||
|
# --- Variables ---
|
||||||
|
debug_mode = opt.debug
|
||||||
|
|
||||||
bot = commands.Bot(command_prefix=opt.prefix, description=info.description)
|
bot = commands.Bot(command_prefix=opt.prefix, description=info.description)
|
||||||
|
|
||||||
|
|
||||||
bot.run(keys.discord_token)
|
try:
|
||||||
|
bot.run(keys.discord_token)
|
||||||
|
|
||||||
|
except discord.LoginFailure as ex: # Miscellaneous authentications errors: borked token and co
|
||||||
|
if debug_mode:
|
||||||
|
raise
|
||||||
|
raise SystemExit("Error: Failed to authenticate: {}".format(ex))
|
||||||
|
|
||||||
|
except discord.ConnectionClosed as ex: # When the connection the the gateway (websocket) is closed
|
||||||
|
if debug_mode:
|
||||||
|
raise
|
||||||
|
raise SystemExit("Error: Discord gateway connection closed: [Code {}] {}".format(ex.code, ex.reason))
|
||||||
|
|
||||||
|
except ConnectionResetError as ex: # More generic connection reset error
|
||||||
|
if debug_mode:
|
||||||
|
raise
|
||||||
|
raise SystemExit("ConnectionResetError: {}".format(ex))
|
||||||
|
|
|
@ -10,4 +10,5 @@
|
||||||
"""Settings and options for the bot."""
|
"""Settings and options for the bot."""
|
||||||
|
|
||||||
prefix = "?"
|
prefix = "?"
|
||||||
|
debug = False
|
||||||
owners_uids = ()
|
owners_uids = ()
|
||||||
|
|
Loading…
Reference in New Issue