Updated error handling to better suited for when an error dosen't have an origina attr
parent
72bd148531
commit
6083e9d1c7
|
@ -66,7 +66,6 @@ class Config:
|
||||||
self.south_tunnel = self.config['Minecraft']['South_Tunnel']
|
self.south_tunnel = self.config['Minecraft']['South_Tunnel']
|
||||||
self.west_tunnel = self.config['Minecraft']['West_Tunnel']
|
self.west_tunnel = self.config['Minecraft']['West_Tunnel']
|
||||||
|
|
||||||
|
|
||||||
self.count = int(self.config['Logging']['Count'])
|
self.count = int(self.config['Logging']['Count'])
|
||||||
self.rotation_duration = int(self.config['Logging']['Rotation_Duration'])
|
self.rotation_duration = int(self.config['Logging']['Rotation_Duration'])
|
||||||
self.special_name_list = dict(self.config.items('Special Names'))
|
self.special_name_list = dict(self.config.items('Special Names'))
|
||||||
|
@ -86,4 +85,5 @@ class Config:
|
||||||
|
|
||||||
return engine_args.format(driver, username, password, host, port, database_name)
|
return engine_args.format(driver, username, password, host, port, database_name)
|
||||||
|
|
||||||
|
|
||||||
bot_config = Config()
|
bot_config = Config()
|
||||||
|
|
|
@ -67,11 +67,27 @@ async def on_command(command, ctx):
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_command_error(error, ctx):
|
async def on_command_error(error, ctx):
|
||||||
|
error_str = ''
|
||||||
if hasattr(ctx, 'cog'):
|
if hasattr(ctx, 'cog'):
|
||||||
if "Admin_Commands" in ctx.cog.__str__():
|
if "Admin_Commands" in ctx.cog.__str__():
|
||||||
return
|
return
|
||||||
if isinstance(error, commands.CommandNotFound):
|
if hasattr(error, 'original'):
|
||||||
return
|
if isinstance(error.original, NoPermissionError):
|
||||||
|
error_str = 'You don\'t have permission for that cool command.'
|
||||||
|
elif isinstance(error.original, UsernameLookupFailed):
|
||||||
|
error_str = 'Your user name was not found, either Mojang is having a fucky wucky ' \
|
||||||
|
'or your nickname is not set correctly. *stares at the Mods*'
|
||||||
|
elif isinstance(error.original, PlayerNotFound):
|
||||||
|
error_str = 'Make sure to use ?register first you ding dong.'
|
||||||
|
elif isinstance(error.original, EntryNameNotUniqueError):
|
||||||
|
error_str = 'An entry in the database already has that name you ding dong.'
|
||||||
|
elif isinstance(error.original, DatabaseValueError):
|
||||||
|
error_str = 'Use a shorter name or a smaller value, dong ding.'
|
||||||
|
elif isinstance(error.original, NotOnServerError):
|
||||||
|
error_str = 'Command needs to be run on 24CC. Run this command there whoever you are.'.format()
|
||||||
|
elif isinstance(error.original, OperationalError):
|
||||||
|
await send_error_message('Error connecting to the MySQL server, is it offline?')
|
||||||
|
error_str = 'Database connection issue, looks like some admin has to fix something.'.format()
|
||||||
elif isinstance(error, commands.CommandOnCooldown):
|
elif isinstance(error, commands.CommandOnCooldown):
|
||||||
return
|
return
|
||||||
elif isinstance(error, commands.UserInputError):
|
elif isinstance(error, commands.UserInputError):
|
||||||
|
@ -81,24 +97,10 @@ async def on_command_error(error, ctx):
|
||||||
pages = bot.formatter.format_help_for(ctx, ctx.command)
|
pages = bot.formatter.format_help_for(ctx, ctx.command)
|
||||||
for page in pages:
|
for page in pages:
|
||||||
error_str = error_str + '\n' + page
|
error_str = error_str + '\n' + page
|
||||||
|
elif isinstance(error, commands.CommandNotFound):
|
||||||
|
return
|
||||||
|
|
||||||
elif isinstance(error.original, NoPermissionError):
|
if error_str is None:
|
||||||
error_str = 'You don\'t have permission for that cool command.'
|
|
||||||
elif isinstance(error.original, UsernameLookupFailed):
|
|
||||||
error_str = 'Your user name was not found, either Mojang is having a fucky wucky ' \
|
|
||||||
'or your nickname is not set correctly. *stares at the Mods*'
|
|
||||||
elif isinstance(error.original, PlayerNotFound):
|
|
||||||
error_str = 'Make sure to use ?register first you ding dong.'
|
|
||||||
elif isinstance(error.original, EntryNameNotUniqueError):
|
|
||||||
error_str = 'An entry in the database already has that name you ding dong.'
|
|
||||||
elif isinstance(error.original, DatabaseValueError):
|
|
||||||
error_str = 'Use a shorter name or a smaller value, dong ding.'
|
|
||||||
elif isinstance(error.original, NotOnServerError):
|
|
||||||
error_str = 'Command needs to be run on 24CC. Run this command there whoever you are.'.format()
|
|
||||||
elif isinstance(error.original, OperationalError):
|
|
||||||
await send_error_message('Error connecting to the MySQL server, is it offline?')
|
|
||||||
error_str = 'Database connection issue, looks like some admin has to fix something.'.format()
|
|
||||||
else:
|
|
||||||
await send_error_message('Geoffrey encountered unhandled exception: {}. Context:'.format(error, ctx.args))
|
await send_error_message('Geoffrey encountered unhandled exception: {}. Context:'.format(error, ctx.args))
|
||||||
|
|
||||||
logger.error("Geoffrey encountered unhandled exception: %s", error)
|
logger.error("Geoffrey encountered unhandled exception: %s", error)
|
||||||
|
@ -162,9 +164,9 @@ def setup_logging():
|
||||||
bot_info_logger.addHandler(handler)
|
bot_info_logger.addHandler(handler)
|
||||||
bot_info_logger.addHandler(console)
|
bot_info_logger.addHandler(console)
|
||||||
|
|
||||||
|
|
||||||
def start_bot():
|
def start_bot():
|
||||||
try:
|
try:
|
||||||
|
|
||||||
setup_logging()
|
setup_logging()
|
||||||
Commands()
|
Commands()
|
||||||
for extension in extensions:
|
for extension in extensions:
|
||||||
|
|
Loading…
Reference in New Issue