parent
17c11d482b
commit
bc6a77257f
|
@ -88,8 +88,11 @@ class GeoffreyBot(commands.Bot):
|
||||||
return
|
return
|
||||||
elif isinstance(error, commands.errors.CommandNotFound):
|
elif isinstance(error, commands.errors.CommandNotFound):
|
||||||
return
|
return
|
||||||
elif isinstance(error, commands.errors.ExpectedClosingQuoteError):
|
elif isinstance(error, commands.errors.ExpectedClosingQuoteError) or isinstance(error,
|
||||||
|
commands.errors.UnexpectedQuoteError):
|
||||||
error_str = "It appears you are missing a quotation mark in there, better luck next time goober."
|
error_str = "It appears you are missing a quotation mark in there, better luck next time goober."
|
||||||
|
elif isinstance(error, commands.errors.InvalidEndOfQuotedStringError):
|
||||||
|
error_str = "You need a space after that quotation mark bud."
|
||||||
elif isinstance(error, commands.errors.BadArgument) or isinstance(error, commands.MissingRequiredArgument) or (
|
elif isinstance(error, commands.errors.BadArgument) or isinstance(error, commands.MissingRequiredArgument) or (
|
||||||
hasattr(error, "original") and isinstance(error.original, ValueError)):
|
hasattr(error, "original") and isinstance(error.original, ValueError)):
|
||||||
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:"
|
||||||
|
@ -100,7 +103,10 @@ class GeoffreyBot(commands.Bot):
|
||||||
error_str = "Unable to connect to the database. Hopefully someone is working on this..."
|
error_str = "Unable to connect to the database. Hopefully someone is working on this..."
|
||||||
await self.send_error_message("Can't connect to the GeoffreyAPI, is it offline?")
|
await self.send_error_message("Can't connect to the GeoffreyAPI, is it offline?")
|
||||||
elif hasattr(error, "original"):
|
elif hasattr(error, "original"):
|
||||||
|
if len(error.original.args):
|
||||||
e = error.original.args[0]
|
e = error.original.args[0]
|
||||||
|
else:
|
||||||
|
e = None
|
||||||
|
|
||||||
if e == "TypeError":
|
if e == "TypeError":
|
||||||
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:"
|
||||||
|
@ -120,9 +126,14 @@ class GeoffreyBot(commands.Bot):
|
||||||
ctx.invoked_with,
|
ctx.invoked_with,
|
||||||
command_args))
|
command_args))
|
||||||
|
|
||||||
|
if hasattr(error, "original"):
|
||||||
|
tb = traceback.format_tb(error.original.__traceback__)
|
||||||
|
else:
|
||||||
|
tb = traceback.format_tb(error.__traceback__)
|
||||||
|
|
||||||
error_message = ["```python"]
|
error_message = ["```python"]
|
||||||
for tb in traceback.format_tb(error.original.__traceback__):
|
for line in tb:
|
||||||
error_message.append(tb)
|
error_message.append(line)
|
||||||
|
|
||||||
error_message.append("```")
|
error_message.append("```")
|
||||||
|
|
||||||
|
@ -131,6 +142,8 @@ class GeoffreyBot(commands.Bot):
|
||||||
logger.error("Geoffrey encountered exception: %s", error)
|
logger.error("Geoffrey encountered exception: %s", error)
|
||||||
traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
|
traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
|
||||||
|
|
||||||
|
await self.send_error_message(error_message)
|
||||||
|
|
||||||
await ctx.message.channel.send('{} **Error Running Command:** {}'.format(
|
await ctx.message.channel.send('{} **Error Running Command:** {}'.format(
|
||||||
ctx.message.author.mention, error_str))
|
ctx.message.author.mention, error_str))
|
||||||
|
|
||||||
|
@ -151,16 +164,11 @@ class GeoffreyBot(commands.Bot):
|
||||||
if user is None:
|
if user is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if msg is list:
|
if isinstance(msg, list):
|
||||||
await self.send_list(user, msg)
|
await self.send_list(user, msg)
|
||||||
else:
|
else:
|
||||||
await user.send(msg)
|
await user.send(msg)
|
||||||
|
|
||||||
def run_command(self, command, **kwargs):
|
|
||||||
url = self.base_url + '/api/command/{}'
|
|
||||||
|
|
||||||
return requests.get(url=url.format(command), params=kwargs).json()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def send_formatted_message(ctx, msg_format, *args, ping_user=False):
|
async def send_formatted_message(ctx, msg_format, *args, ping_user=False):
|
||||||
if ping_user:
|
if ping_user:
|
||||||
|
|
|
@ -299,7 +299,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
errors = {
|
errors = {
|
||||||
"LocationLookUpError": "you do not have a farm by that name you ding dong goober.",
|
"LocationLookUpError": "you do not have a farm by that name you ding dong goober.",
|
||||||
"EntryNameNotUniqueError": "you have more than one location. Please specify a name, dingus.",
|
"EntryNameNotUniqueError": "you have more than one location. Please specify a name, dingus.",
|
||||||
"ItemNotFound": "your farm does not produce **{}**. Try again buddy boy.".format(resource_name)
|
"ResourceNotFound": "your farm does not produce **{}**. Try again buddy boy.".format(resource_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
farm = await run_command(ctx, self.api_url, self.api_token, "POST", "delete_resource", errors=errors,
|
farm = await run_command(ctx, self.api_url, self.api_token, "POST", "delete_resource", errors=errors,
|
||||||
|
@ -371,7 +371,7 @@ class GeoffreyCommands(commands.Cog):
|
||||||
location["tunnel"]))
|
location["tunnel"]))
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def find_around(self, ctx, x_pos, z_pos, *args):
|
async def find_around(self, ctx, x_pos: int, z_pos: int, *args):
|
||||||
"""
|
"""
|
||||||
{}find_around <X Coordinate> <Z Coordinate> <Radius>
|
{}find_around <X Coordinate> <Z Coordinate> <Radius>
|
||||||
The Radius parameter is optional and defaults to 200 blocks
|
The Radius parameter is optional and defaults to 200 blocks
|
||||||
|
|
Loading…
Reference in New Issue