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): elif isinstance(error.original, EntryNameNotUniqueError):
error_str = 'An entry in the database already has that name ding dong.' error_str = 'An entry in the database already has that name ding dong.'
database_interface.database.session.rollback() 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: else:
error_str = bad_error_message.format(ctx.invoked_with, error) 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. The radius defaults to 200 blocks if no value is given.
Default dimension is overworld. Default dimension is overworld.
?findaround [X Coordinate] [Z Coordinate] [Optional Flags] ?findaround [X Coordinate] [Z Coordinate] [Radius] [Optional Flags]
Optional Flags: Optional Flags:
-r [radius]
-d [dimension] -d [dimension]
''' '''
radius = 200 radius = 200
dimension = 'Overworld' dimension = 'Overworld'
if len(args) == 1: try:
radius = args[0] if len(args) > 0:
if args[0] == '-d':
dimension = args[1]
else:
radius = int(args[0])
flags = get_args_dict(args) if len(args) > 1:
if args[1] == '-d':
if len(flags) > 0: dimension = args[2]
if '-d' in flags:
dimension = flags['-d']
base_list = database_interface.find_location_around(x_pos, z_pos, radius, dimension) 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: else:
await bot.say('{}, there are no locations within {} blocks of that point' await bot.say('{}, there are no locations within {} blocks of that point'
.format(ctx.message.author.mention, radius)) .format(ctx.message.author.mention, radius))
except ValueError:
raise commands.UserInputError
@bot.command(pass_context=True) @bot.command(pass_context=True)