Updated some formating for multiple owners and exception traces are now sent to error_users
parent
299aa80364
commit
a9fb0b1ce9
|
@ -9,8 +9,8 @@ def formatted_location(location):
|
|||
else:
|
||||
tunnel = ""
|
||||
|
||||
return '**{}** @ **{}** {}Owner: **{}**'.format(location["name"], formatted_position(location), tunnel,
|
||||
location["owner"]["name"])
|
||||
return '**{}** @ **{}** {}Owner(s): **{}**'.format(location["name"], formatted_position(location), tunnel,
|
||||
formatted_owners(location))
|
||||
|
||||
|
||||
def formatted_tunnel(tunnel):
|
||||
|
@ -27,3 +27,17 @@ def formatted_shop(shop):
|
|||
inventory = inventory + "\n" + (formatted_item_listing(item))
|
||||
|
||||
return formatted_location(shop) + inventory
|
||||
|
||||
|
||||
def formatted_owners(location):
|
||||
owner_list = ''
|
||||
if "owner" in location:
|
||||
|
||||
if len(location["owner"]) == 0:
|
||||
owner_list = location["owner"][0]["name"]
|
||||
else:
|
||||
owner_list = location["owner"][0]["name"]
|
||||
for owner in location["owner"][1:]:
|
||||
owner_list += ", " + owner["name"]
|
||||
|
||||
return owner_list
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from discord import Game
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands.formatter import HelpFormatter
|
||||
from requests import exceptions as request_exception
|
||||
from discord.utils import oauth_url
|
||||
import requests
|
||||
import logging
|
||||
|
@ -68,8 +68,8 @@ class GeoffreyBot(commands.Bot):
|
|||
else:
|
||||
subcommand = ":" + ctx.invoked_subcommand.__str__()
|
||||
|
||||
logger.info("User %s, used command %s%s with context: %s", ctx.message.author, ctx.command.name, subcommand,
|
||||
ctx.args)
|
||||
logger.info("User %s, used command '%s%s' with arguments: %s", ctx.message.author, ctx.command.name, subcommand,
|
||||
ctx.args[2:])
|
||||
|
||||
async def on_command_error(self, ctx, error):
|
||||
error_str = ""
|
||||
|
@ -79,8 +79,11 @@ class GeoffreyBot(commands.Bot):
|
|||
error_str = "That's not how you use the command you ding dong."
|
||||
elif isinstance(error, commands.errors.MissingRequiredArgument):
|
||||
error_str = "Well bud, you got this far. Good job! But you still h*cked up the syntax. " \
|
||||
"Check {}help.".format(self.prefix)
|
||||
elif len(error.args) > 0 and hasattr(error, "original"):
|
||||
"Check {}help.".format(self.prefix)
|
||||
elif hasattr(error, "original") and isinstance(error.original, request_exception.ConnectionError):
|
||||
error_str = "Unable to connect to the database. Hopefully someone is working on this..."
|
||||
await self.send_error_message("Can't connect to GeoffreyAPI, is it offline?")
|
||||
elif len(error.original.args) > 0 and hasattr(error, "original"):
|
||||
e = error.original.args[0]
|
||||
|
||||
if e == "PlayerNotFound":
|
||||
|
@ -89,14 +92,19 @@ class GeoffreyBot(commands.Bot):
|
|||
error_str = "You have no locations in the database, ding dongs like you can read {}help to figure out" \
|
||||
"how to add them".format(self.prefix)
|
||||
elif e == "TypeError":
|
||||
error_str = "Well bud, you got this far. Good job! But you still h*cked up the syntax. Check {}help."\
|
||||
error_str = "Well bud, you got this far. Good job! But you still h*cked up the syntax. Check {}help." \
|
||||
.format(self.prefix)
|
||||
|
||||
if error_str is '':
|
||||
await self.send_error_message(
|
||||
'Geoffrey encountered unhandled exception: {} Command: **{}** Context: {}'.format(error,
|
||||
ctx.command.name,
|
||||
ctx.args))
|
||||
'Geoffrey encountered unhandled exception: {} Command: **{}** Context: {}'
|
||||
.format(error,
|
||||
ctx.invoked_with,
|
||||
ctx.args[1].args[2:]))
|
||||
|
||||
for tb in traceback.format_tb(error.original.__traceback__):
|
||||
await self.send_error_message("```python\n{}```".format(tb))
|
||||
|
||||
error_str = bad_error_message.format(ctx.invoked_with)
|
||||
|
||||
logger.error("Geoffrey encountered exception: %s", error)
|
||||
|
@ -169,6 +177,3 @@ class GeoffreyBot(commands.Bot):
|
|||
help_dict[command_name] = help_list
|
||||
|
||||
return help_dict
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue