fixed syntax error handling for findbasearound

doc_update
Joey Hines 2018-05-26 09:50:14 -05:00
parent 5b1195a895
commit 7b1df1922b
1 changed files with 13 additions and 5 deletions

View File

@ -1,6 +1,4 @@
import discord
import enum import enum
from math import sqrt
from discord.ext import commands from discord.ext import commands
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
@ -131,6 +129,7 @@ async def on_command_error(error, ctx):
error_str = 'Invalid syntax for {}, please read ?help {}.'.format(ctx.invoked_with, ctx.invoked_with) error_str = 'Invalid syntax for {}, please read ?help {}.'.format(ctx.invoked_with, ctx.invoked_with)
else: else:
error_str = bad_error_message.format(ctx.invoked_with) error_str = bad_error_message.format(ctx.invoked_with)
print(error)
await bot.send_message(ctx.message.channel, error_str) await bot.send_message(ctx.message.channel, error_str)
@ -206,9 +205,18 @@ async def deletebase(ctx, name: str):
@bot.command(pass_context=True) @bot.command(pass_context=True)
async def findbasearound(ctx, x_pos: int, z_pos: int, * args): async def findbasearound(ctx, x_pos: int, z_pos: int, * args):
'''
Finds all the base around a certain point that are registered in the database
The Radius argument defaults to 200 blocks if no value is given
?findbasearound [X Coordinate] [Z Coordinate] [Radius]
'''
radius = 200 radius = 200
if len(args) > 0: if len(args) > 0:
try :
radius = int(args[0]) radius = int(args[0])
except ValueError:
raise commands.UserInputError
base_list = session.query(Location).filter( base_list = session.query(Location).filter(
Location.x < x_pos + radius, Location.x > x_pos - radius, Location.z < z_pos + radius, Location.z > z_pos Location.x < x_pos + radius, Location.x > x_pos - radius, Location.z < z_pos + radius, Location.z > z_pos