baseAdd now uses the location class
parent
0a26e22dbe
commit
e14a7ddb70
23
MCInfoBot.py
23
MCInfoBot.py
|
@ -15,14 +15,14 @@ class Location:
|
||||||
y = 0;
|
y = 0;
|
||||||
z = 0;
|
z = 0;
|
||||||
|
|
||||||
def __init__(self,str) :
|
def __init__(self,args) :
|
||||||
try:
|
self.name = args[0]
|
||||||
name = args[0]
|
self.x = int(args[1])
|
||||||
x = int(args[1])
|
self.y = int(args[2])
|
||||||
y = int(args[2])
|
self.z = int(args[3])
|
||||||
z = int(args[3])
|
|
||||||
except ValueError:
|
def posToStr(self) :
|
||||||
raise parseError
|
return '(x=' + str(self.x) + ', y=' + str(self.y) + ', z=' + str(self.z) + ')'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,10 +40,11 @@ async def test():
|
||||||
|
|
||||||
@bot.command(pass_context=True)
|
@bot.command(pass_context=True)
|
||||||
async def addBase(ctx, * args):
|
async def addBase(ctx, * args):
|
||||||
if (len(args) > 0) :
|
if (len(args) == 4) :
|
||||||
try:
|
try:
|
||||||
base = location(args)
|
base = Location(args)
|
||||||
except parseError:
|
await bot.say('{}, your base named {} located at {} has been added to the database.'.format(ctx.message.author.mention, base.name, base.posToStr()))
|
||||||
|
except ValueError:
|
||||||
await bot.say('Invalid syntax, try again (?addbase [name] [x coord] [z coord])')
|
await bot.say('Invalid syntax, try again (?addbase [name] [x coord] [z coord])')
|
||||||
|
|
||||||
else :
|
else :
|
||||||
|
|
Loading…
Reference in New Issue