findaround: fixed dimension selection

doc_update
Joey Hines 2018-07-21 13:49:10 -05:00
parent 4c0d8d2384
commit 866cc56a33
1 changed files with 23 additions and 17 deletions

View File

@ -53,6 +53,9 @@ async def on_command_error(error, ctx):
elif isinstance(error.original, EntryNameNotUniqueError):
error_str = 'An entry in the database already has that name ding dong.'
database_interface.database.session.rollback()
elif isinstance(error.original, StringTooLong):
error_str = 'Use a shorter name you, dong ding.'
database_interface.database.session.rollback()
else:
error_str = bad_error_message.format(ctx.invoked_with, error)
@ -201,24 +204,25 @@ async def findaround(ctx, x_pos: int, z_pos: int, * args):
The radius defaults to 200 blocks if no value is given.
Default dimension is overworld.
?findaround [X Coordinate] [Z Coordinate] [Optional Flags]
?findaround [X Coordinate] [Z Coordinate] [Radius] [Optional Flags]
Optional Flags:
-r [radius]
-d [dimension]
'''
radius = 200
dimension = 'Overworld'
if len(args) == 1:
radius = args[0]
try:
if len(args) > 0:
if args[0] == '-d':
dimension = args[1]
else:
radius = int(args[0])
flags = get_args_dict(args)
if len(flags) > 0:
if '-d' in flags:
dimension = flags['-d']
if len(args) > 1:
if args[1] == '-d':
dimension = args[2]
base_list = database_interface.find_location_around(x_pos, z_pos, radius, dimension)
@ -230,6 +234,8 @@ async def findaround(ctx, x_pos: int, z_pos: int, * args):
else:
await bot.say('{}, there are no locations within {} blocks of that point'
.format(ctx.message.author.mention, radius))
except ValueError:
raise commands.UserInputError
@bot.command(pass_context=True)