Added add_owner command and made help messages more consistent
parent
0593318df5
commit
cb4a173508
|
@ -44,18 +44,19 @@ class GeoffreyCommands:
|
|||
@commands.command(pass_context=True)
|
||||
async def add_base(self, ctx, x_pos: int, z_pos: int, *args):
|
||||
'''
|
||||
{}add_base <x_pos> <z_pos> <Name>
|
||||
The name parameter is optional.
|
||||
{}add_base <X Coordinate> <Z Coordinate> <Name>
|
||||
The Name parameter is optional if this is your first base
|
||||
|
||||
'''
|
||||
name = get_name(args)
|
||||
|
||||
try:
|
||||
base = run_command(self.base_url, self.api_token, "POST", "add_base", x_pos=x_pos, z_pos=z_pos, name=name,
|
||||
discord_uuid=ctx.message.author.id)
|
||||
discord_uuid=ctx.message.author.id)
|
||||
|
||||
await ctx.send(
|
||||
'{}, your base has been added to the database: \n\n{}'.format(ctx.message.author.mention,
|
||||
formatted_location(base)))
|
||||
formatted_location(base)))
|
||||
except Exception as e:
|
||||
error_list = [
|
||||
{"error": "EntryNameNotUniqueError",
|
||||
|
@ -70,16 +71,20 @@ class GeoffreyCommands:
|
|||
@commands.command(pass_context=True)
|
||||
async def add_item(self, ctx, item_name, quantity: int, diamond_price: int, *args):
|
||||
'''
|
||||
{}add_item <item name> <quantity> <diamond price> <Shop Name>
|
||||
The name parameter is optional.
|
||||
{}add_item <Item Name> <Quantity> <Diamond Price> <Shop Name>
|
||||
If item name contains spaces, it must be wrapped in quotes. eg "Diamond Pickaxe"
|
||||
The Shop Name parameter is optional if this is your first shop
|
||||
|
||||
'''
|
||||
shop_name = get_name(args)
|
||||
|
||||
try:
|
||||
item = run_command(self.base_url, self.api_token, "POST", "add_item", item_name=item_name, quantity=quantity,
|
||||
item = run_command(self.base_url, self.api_token, "POST", "add_item", item_name=item_name,
|
||||
quantity=quantity,
|
||||
diamond_price=diamond_price, shop_name=shop_name, discord_uuid=ctx.message.author.id)
|
||||
await ctx.send('{}, {} has been added to the inventory of {}'.format(ctx.message.author.mention,
|
||||
item["item_name"], item["shop"]["name"]))
|
||||
item["item_name"],
|
||||
item["shop"]["name"]))
|
||||
except Exception as e:
|
||||
error_list = [
|
||||
{"error": "LocationLookUpError",
|
||||
|
@ -93,11 +98,45 @@ class GeoffreyCommands:
|
|||
msg = check_error(e, error_list)
|
||||
await ctx.send(msg)
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
async def add_owner(self, ctx, new_owner_name, location_name):
|
||||
'''
|
||||
{}add_owner <New Owner's Name> <Location Name>
|
||||
WARNING: The new owner had just as much power as you to edit or delete this location.
|
||||
'''
|
||||
|
||||
try:
|
||||
location = run_command(self.base_url, self.api_token, "POST", "add_owner", new_owner_name=new_owner_name,
|
||||
location_name=location_name, discord_uuid=ctx.message.author.id)
|
||||
|
||||
await ctx.send('{}, **{}** has been added as an owner to **{}**'.format(
|
||||
ctx.message.author.mention, new_owner_name, location["name"]))
|
||||
except Exception as e:
|
||||
error_list = [
|
||||
{"error": "PlayerNotFound",
|
||||
"message": "{}, ain't no one in this darn database named {} you goob".format(
|
||||
ctx.message.author.mention, new_owner_name)
|
||||
},
|
||||
{"error": "PlayerInDBError",
|
||||
"message": "{}, **{}** is already an owner, stop having amosia.".format(
|
||||
ctx.message.author.mention, new_owner_name)
|
||||
},
|
||||
{"error": "LocationLookUpError",
|
||||
"message": "{}, you do not have a location by the name you ding dong goober.".format(
|
||||
ctx.message.author)
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
msg = check_error(e, error_list)
|
||||
|
||||
await ctx.send(msg)
|
||||
|
||||
@commands.command(pass_context=True)
|
||||
async def add_shop(self, ctx, x_pos: int, z_pos: int, *args):
|
||||
'''
|
||||
{}add_shop <x_pos> <z_pos> <Name>
|
||||
The name parameter is optional.
|
||||
{}add_shop <X Coordinate> <Z Coordinate> <Shop Name>
|
||||
The Shop Name parameter is optional if this is your first shop
|
||||
'''
|
||||
|
||||
name = get_name(args)
|
||||
|
@ -123,15 +162,15 @@ class GeoffreyCommands:
|
|||
@commands.command(pass_context=True)
|
||||
async def add_tunnel(self, ctx, tunnel_direction, tunnel_number: int, *args):
|
||||
'''
|
||||
{}add_tunnel <tunnel_direction> <tunnel_number> <Location Name>
|
||||
The name parameter is optional.
|
||||
{}add_tunnel <Tunnel Direction> <Tunnel Number> <Location Name>
|
||||
The Name parameter is optional if you only have one location
|
||||
'''
|
||||
|
||||
name = get_name(args)
|
||||
|
||||
try:
|
||||
tunnel = run_command(self.base_url, self.api_token, "POST", "add_tunnel", tunnel_direction=tunnel_direction,
|
||||
tunnel_number=tunnel_number, location_name=name, discord_uuid=ctx.message.author.id)
|
||||
tunnel_number=tunnel_number, location_name=name, discord_uuid=ctx.message.author.id)
|
||||
|
||||
await ctx.send("{}, your tunnel has been added to the database!".format(ctx.message.author.mention))
|
||||
|
||||
|
@ -176,14 +215,14 @@ class GeoffreyCommands:
|
|||
@commands.command(pass_context=True)
|
||||
async def delete_item(self, ctx, item_name: str, *args):
|
||||
'''
|
||||
{}delete_item <Item Name> <Location Name>
|
||||
The name parameter is optional.
|
||||
{}delete_item <Item Name> <Shop Name>
|
||||
The Shop Name parameter is optional if you only have one location.
|
||||
'''
|
||||
|
||||
shop_name = get_name(args)
|
||||
try:
|
||||
shop = run_command(self.base_url, self.api_token, "POST", "delete_item", item=item_name,
|
||||
shop_name=shop_name, discord_uuid=ctx.message.author.id)
|
||||
shop_name=shop_name, discord_uuid=ctx.message.author.id)
|
||||
|
||||
await ctx.send("{}, **{}** has been deleted from {}, no one bought it anyway.".format(
|
||||
ctx.message.author.mention, item_name, shop["name"]))
|
||||
|
@ -215,7 +254,7 @@ class GeoffreyCommands:
|
|||
new_name=new_name, discord_uuid=ctx.message.author.id)
|
||||
|
||||
await ctx.send("{}, **{}** has been renamed to **{}**.".format(ctx.message.author.mention, old_name,
|
||||
location["name"]))
|
||||
location["name"]))
|
||||
except Exception as e:
|
||||
error_list = [
|
||||
{"error": "EntryNameNotUniqueError",
|
||||
|
@ -232,7 +271,7 @@ class GeoffreyCommands:
|
|||
@commands.command(pass_conext=True)
|
||||
async def edit_pos(self, ctx, new_x: int, new_z: int, *args):
|
||||
'''
|
||||
{}edit_post <New X Coord> <New Z Coord> <Location Name>
|
||||
{}edit_post <New X Coordinate> <New Z Coordinate> <Location Name>
|
||||
'''
|
||||
|
||||
loc_name = get_name(args)
|
||||
|
@ -241,7 +280,7 @@ class GeoffreyCommands:
|
|||
loc_name=loc_name, discord_uuid=ctx.message.author.id)
|
||||
|
||||
await ctx.send("{}, **{}** has been moved to **{}**".format(ctx.message.author.mention, location["name"],
|
||||
location["location"]))
|
||||
location["location"]))
|
||||
except Exception as e:
|
||||
error_list = [
|
||||
{"error": "LocationLookUpError",
|
||||
|
@ -284,7 +323,8 @@ class GeoffreyCommands:
|
|||
@commands.command(pass_context=True)
|
||||
async def find_around(self, ctx, x_pos, z_pos, *args):
|
||||
'''
|
||||
{}find_around <X Position> <Z Position> <radius>
|
||||
{}find_around <X Coordinate> <Z Coordinate> <Radius>
|
||||
The Radius parameter is optional and defaults to 200 blocks
|
||||
'''
|
||||
|
||||
try:
|
||||
|
@ -299,7 +339,7 @@ class GeoffreyCommands:
|
|||
ctx.message.author.mention, radius, x_pos, z_pos)]
|
||||
|
||||
for location in locations:
|
||||
message.append(formatted_location(location))
|
||||
message.append(formatted_location(location))
|
||||
|
||||
await self.bot.send_list(ctx, message)
|
||||
|
||||
|
@ -378,7 +418,7 @@ class GeoffreyCommands:
|
|||
error_list = [
|
||||
{"error": "LocationLookUpError",
|
||||
"message": "{}, there are no locations that match **{}**.".format(ctx.message.author.mention,
|
||||
location_name)
|
||||
location_name)
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -424,7 +464,8 @@ class GeoffreyCommands:
|
|||
@commands.command(pass_context=True)
|
||||
async def selling(self, ctx, *args):
|
||||
'''
|
||||
{}selling <item name>
|
||||
{}selling <Item Name>
|
||||
Sorts by most recently added
|
||||
'''
|
||||
item = get_name(args)
|
||||
|
||||
|
@ -452,7 +493,7 @@ class GeoffreyCommands:
|
|||
async def restock(self, ctx, item_name, *args):
|
||||
'''
|
||||
{}restock <Item name> <Shop Name>
|
||||
The shop name is optional
|
||||
The Shop Name is optional if you only have one shop.
|
||||
'''
|
||||
|
||||
shop_name = get_name(args)
|
||||
|
@ -461,12 +502,12 @@ class GeoffreyCommands:
|
|||
item = run_command(self.base_url, self.api_token, "POST", "restock", item_name=item_name,
|
||||
shop_name=shop_name, discord_uuid=ctx.message.author.id)
|
||||
await ctx.send('{}, **{}** has been restocked at **{}**'.format(ctx.message.author.mention, item_name,
|
||||
item[0]["shop"]["name"]))
|
||||
item[0]["shop"]["name"]))
|
||||
except Exception as e:
|
||||
error_list = [
|
||||
{"error": "ItemNotFound",
|
||||
"message": "{}, that shop does not have **{}** in its inventory".format(ctx.message.author.mention,
|
||||
item_name)},
|
||||
item_name)},
|
||||
{"error": "LocationLookUpError",
|
||||
"message": "{}, you do not have a shop named **{}**.".format(ctx.message.author.mention, shop_name)
|
||||
},
|
||||
|
@ -505,5 +546,6 @@ class GeoffreyCommands:
|
|||
msg = check_error(e, error_list)
|
||||
await ctx.send(msg)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(GeoffreyCommands(bot))
|
||||
|
|
Loading…
Reference in New Issue