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,35 +204,38 @@ 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':
dimension = args[2]
if len(flags) > 0: base_list = database_interface.find_location_around(x_pos, z_pos, radius, dimension)
if '-d' in flags:
dimension = flags['-d']
base_list = database_interface.find_location_around(x_pos, z_pos, radius, dimension) if len(base_list) != 0:
base_string = loc_list_to_string(base_list, '{} \n{}')
if len(base_list) != 0: await bot.say('{}, there are **{}** locations(s) within **{}** blocks of that point: \n {}'.format(
base_string = loc_list_to_string(base_list, '{} \n{}') ctx.message.author.mention, len(base_list), radius, base_string))
else:
await bot.say('{}, there are **{}** locations(s) within **{}** blocks of that point: \n {}'.format( await bot.say('{}, there are no locations within {} blocks of that point'
ctx.message.author.mention, len(base_list), radius, base_string)) .format(ctx.message.author.mention, radius))
else: except ValueError:
await bot.say('{}, there are no locations within {} blocks of that point' raise commands.UserInputError
.format(ctx.message.author.mention, radius))
@bot.command(pass_context=True) @bot.command(pass_context=True)