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:
|
else:
|
||||||
tunnel = ""
|
tunnel = ""
|
||||||
|
|
||||||
return '**{}** @ **{}** {}Owner: **{}**'.format(location["name"], formatted_position(location), tunnel,
|
return '**{}** @ **{}** {}Owner(s): **{}**'.format(location["name"], formatted_position(location), tunnel,
|
||||||
location["owner"]["name"])
|
formatted_owners(location))
|
||||||
|
|
||||||
|
|
||||||
def formatted_tunnel(tunnel):
|
def formatted_tunnel(tunnel):
|
||||||
|
@ -27,3 +27,17 @@ def formatted_shop(shop):
|
||||||
inventory = inventory + "\n" + (formatted_item_listing(item))
|
inventory = inventory + "\n" + (formatted_item_listing(item))
|
||||||
|
|
||||||
return formatted_location(shop) + inventory
|
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 import Game
|
||||||
from discord.ext import commands
|
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
|
from discord.utils import oauth_url
|
||||||
import requests
|
import requests
|
||||||
import logging
|
import logging
|
||||||
|
@ -68,8 +68,8 @@ class GeoffreyBot(commands.Bot):
|
||||||
else:
|
else:
|
||||||
subcommand = ":" + ctx.invoked_subcommand.__str__()
|
subcommand = ":" + ctx.invoked_subcommand.__str__()
|
||||||
|
|
||||||
logger.info("User %s, used command %s%s with context: %s", ctx.message.author, ctx.command.name, subcommand,
|
logger.info("User %s, used command '%s%s' with arguments: %s", ctx.message.author, ctx.command.name, subcommand,
|
||||||
ctx.args)
|
ctx.args[2:])
|
||||||
|
|
||||||
async def on_command_error(self, ctx, error):
|
async def on_command_error(self, ctx, error):
|
||||||
error_str = ""
|
error_str = ""
|
||||||
|
@ -79,8 +79,11 @@ class GeoffreyBot(commands.Bot):
|
||||||
error_str = "That's not how you use the command you ding dong."
|
error_str = "That's not how you use the command you ding dong."
|
||||||
elif isinstance(error, commands.errors.MissingRequiredArgument):
|
elif isinstance(error, commands.errors.MissingRequiredArgument):
|
||||||
error_str = "Well bud, you got this far. Good job! But you still h*cked up the syntax. " \
|
error_str = "Well bud, you got this far. Good job! But you still h*cked up the syntax. " \
|
||||||
"Check {}help.".format(self.prefix)
|
"Check {}help.".format(self.prefix)
|
||||||
elif len(error.args) > 0 and hasattr(error, "original"):
|
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]
|
e = error.original.args[0]
|
||||||
|
|
||||||
if e == "PlayerNotFound":
|
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" \
|
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)
|
"how to add them".format(self.prefix)
|
||||||
elif e == "TypeError":
|
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)
|
.format(self.prefix)
|
||||||
|
|
||||||
if error_str is '':
|
if error_str is '':
|
||||||
await self.send_error_message(
|
await self.send_error_message(
|
||||||
'Geoffrey encountered unhandled exception: {} Command: **{}** Context: {}'.format(error,
|
'Geoffrey encountered unhandled exception: {} Command: **{}** Context: {}'
|
||||||
ctx.command.name,
|
.format(error,
|
||||||
ctx.args))
|
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)
|
error_str = bad_error_message.format(ctx.invoked_with)
|
||||||
|
|
||||||
logger.error("Geoffrey encountered exception: %s", error)
|
logger.error("Geoffrey encountered exception: %s", error)
|
||||||
|
@ -169,6 +177,3 @@ class GeoffreyBot(commands.Bot):
|
||||||
help_dict[command_name] = help_list
|
help_dict[command_name] = help_list
|
||||||
|
|
||||||
return help_dict
|
return help_dict
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue