2019-01-14 20:20:16 +00:00
|
|
|
from discord.ext import commands
|
|
|
|
from GeoffreyBot.DiscordHelperFunctions import *
|
2019-07-26 23:17:46 +00:00
|
|
|
from GeoffreyBot.geoffrey_formatter import *
|
|
|
|
from GeoffreyBot.util import run_command, HandledError
|
2019-01-14 20:20:16 +00:00
|
|
|
|
|
|
|
|
2019-04-10 19:08:39 +00:00
|
|
|
class GeoffreyCommands(commands.Cog):
|
2019-01-14 20:20:16 +00:00
|
|
|
def __init__(self, bot):
|
|
|
|
self.bot = bot
|
2019-09-27 21:00:28 +00:00
|
|
|
self.api_url = bot.api_url
|
|
|
|
self.geoffrey_app_url = bot.geoffrey_app_url
|
2019-01-14 20:20:16 +00:00
|
|
|
self.api_token = bot.api_token
|
|
|
|
|
2019-05-13 14:49:47 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def add_attraction(self, ctx, x_pos: int, z_pos: int, *args):
|
|
|
|
"""
|
|
|
|
{}add_attraction <X Coordinate> <Z Coordinate> <Name>
|
|
|
|
The Name parameter is optional if this is your first attraction
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "you have more than one location. Please specify a name."
|
|
|
|
}
|
|
|
|
|
|
|
|
name = get_name(args)
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
attraction = await run_command(ctx, self.api_url, self.api_token, "POST", "add_attraction", x_pos=x_pos,
|
2019-05-13 14:49:47 +00:00
|
|
|
z_pos=z_pos, name=name, discord_uuid=ctx.message.author.id, errors=errors)
|
|
|
|
|
|
|
|
await ctx.send(
|
|
|
|
'{}, your attraction has been added to the database: \n{}'.format(ctx.message.author.mention,
|
|
|
|
formatted_location(attraction)))
|
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def add_base(self, ctx, x_pos: int, z_pos: int, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-02-02 16:12:58 +00:00
|
|
|
{}add_base <X Coordinate> <Z Coordinate> <Name>
|
|
|
|
The Name parameter is optional if this is your first base
|
|
|
|
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-10 21:22:10 +00:00
|
|
|
|
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "you have more than one location. Please specify a name."
|
|
|
|
}
|
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
name = get_name(args)
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
base = await run_command(ctx, self.api_url, self.api_token, "POST", "add_base", x_pos=x_pos, z_pos=z_pos,
|
2019-05-10 21:22:10 +00:00
|
|
|
name=name,
|
|
|
|
discord_uuid=ctx.message.author.id, errors=errors)
|
|
|
|
|
|
|
|
await ctx.send(
|
|
|
|
'{}, your base has been added to the database: \n{}'.format(ctx.message.author.mention,
|
|
|
|
formatted_location(base)))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-11 16:45:55 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def add_farm(self, ctx, x_pos: int, z_pos: int, *args):
|
|
|
|
"""
|
|
|
|
{}add_farm <X Coordinate> <Z Coordinate> <Farm Name>
|
|
|
|
The Name parameter is optional if this is your first farm
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "you have more than one location. Please specify a name."
|
|
|
|
}
|
|
|
|
|
|
|
|
name = get_name(args)
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
farm = await run_command(ctx, self.api_url, self.api_token, "POST", "add_farm", x_pos=x_pos, z_pos=z_pos,
|
2019-05-11 16:45:55 +00:00
|
|
|
name=name,
|
|
|
|
discord_uuid=ctx.message.author.id, errors=errors)
|
|
|
|
|
|
|
|
await ctx.send(
|
|
|
|
'{}, your farm has been added to the database: \n{}'.format(ctx.message.author.mention,
|
|
|
|
formatted_location(farm)))
|
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def add_item(self, ctx, item_name, quantity: int, diamond_price: int, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-02-02 16:12:58 +00:00
|
|
|
{}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
|
|
|
|
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "You do not have a shop by that name, goober.",
|
|
|
|
"EntryNameNotUniqueError": "You have more than one location. Please specify a name, dingus."
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
shop_name = get_name(args)
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
item = await run_command(ctx, self.api_url, self.api_token, "POST", "add_item",
|
2019-05-10 21:22:10 +00:00
|
|
|
item_name=item_name,
|
|
|
|
quantity=quantity,
|
|
|
|
diamond_price=diamond_price,
|
|
|
|
shop_name=shop_name,
|
|
|
|
discord_uuid=ctx.message.author.id,
|
|
|
|
errors=errors)
|
|
|
|
|
|
|
|
await ctx.send('{}, **{}** has been added to the inventory of **{}**'.format(ctx.message.author.mention,
|
|
|
|
item["item_name"],
|
|
|
|
item["shop"]["name"]))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-11 16:45:55 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def add_market(self, ctx, x_pos: int, z_pos: int, *args):
|
|
|
|
"""
|
|
|
|
{}add_market <X Coordinate> <Z Coordinate> <Name>
|
|
|
|
The Name parameter is optional if this is your first market
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "you have more than one location. Please specify a name."
|
|
|
|
}
|
|
|
|
|
|
|
|
name = get_name(args)
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
market = await run_command(ctx, self.api_url, self.api_token, "POST", "add_market", x_pos=x_pos, z_pos=z_pos,
|
|
|
|
name=name,
|
|
|
|
discord_uuid=ctx.message.author.id, errors=errors)
|
2019-05-11 16:45:55 +00:00
|
|
|
|
|
|
|
await ctx.send(
|
|
|
|
'{}, your market has been added to the database: \n{}'.format(ctx.message.author.mention,
|
|
|
|
formatted_location(market)))
|
|
|
|
|
2019-02-02 16:12:58 +00:00
|
|
|
@commands.command(pass_context=True)
|
2019-02-17 03:21:29 +00:00
|
|
|
async def add_owner(self, ctx, new_owner_name, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-02-02 16:12:58 +00:00
|
|
|
{}add_owner <New Owner's Name> <Location Name>
|
2019-05-14 22:38:39 +00:00
|
|
|
WARNING: The new owner has just as much power as you to edit or delete this location.
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
2019-05-14 22:38:39 +00:00
|
|
|
"OwnerNotFoundError": "ain't no one in this darn database named **{}** you goob".format(new_owner_name),
|
|
|
|
"IsOwnerError": "**{}** is already an owner, stop having amosia.".format(new_owner_name),
|
2019-05-10 21:22:10 +00:00
|
|
|
"LocationLookUpError": "you do not have a location by that name you ding dong goober."
|
|
|
|
}
|
2019-02-02 16:12:58 +00:00
|
|
|
|
2019-02-17 03:21:29 +00:00
|
|
|
location_name = get_name(args)
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "add_owner", errors=errors,
|
2019-05-10 21:22:10 +00:00
|
|
|
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"]))
|
2019-02-17 03:21:29 +00:00
|
|
|
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def add_resident(self, ctx, new_resident_name, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-15 13:14:50 +00:00
|
|
|
{}add_resident <New Residents's MC Username> <Town Name>
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"ResidentNotFoundError": "ain't no one in this darn database named **{}** you goob".format(
|
|
|
|
new_resident_name),
|
|
|
|
"IsResidentError": "**{}** is already a resident, stop having amosia.".format(new_resident_name),
|
2019-05-14 22:38:39 +00:00
|
|
|
"LocationLookUpError": "you do not have a town by that name you ding dong goober."
|
2019-05-10 21:22:10 +00:00
|
|
|
}
|
2019-02-17 03:21:29 +00:00
|
|
|
|
|
|
|
town_name = get_name(args)
|
2019-09-27 21:00:28 +00:00
|
|
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "add_resident", errors=errors,
|
2019-05-10 21:22:10 +00:00
|
|
|
new_resident_name=new_resident_name,
|
|
|
|
town_name=town_name, discord_uuid=ctx.message.author.id)
|
|
|
|
|
|
|
|
await ctx.send('{}, **{}** has been added as a resident to **{}**'.format(
|
|
|
|
ctx.message.author.mention, new_resident_name, location["name"]))
|
2019-02-02 16:12:58 +00:00
|
|
|
|
2019-05-11 16:45:55 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def add_resource(self, ctx, resource_name, *args):
|
|
|
|
"""
|
|
|
|
{}add_item <Resource Name> <Farm Name>
|
|
|
|
If resource name contains spaces, it must be wrapped in quotes. eg "Rotten Flesh"
|
|
|
|
The Farm Name parameter is optional if this is your first farm
|
|
|
|
|
|
|
|
"""
|
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "You do not have a farm by that name, goober.",
|
|
|
|
"EntryNameNotUniqueError": "You have more than one farm. Please specify a name, dingus."
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
farm_name = get_name(args)
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
resource = await run_command(ctx, self.api_url, self.api_token, "POST", "add_resource", errors=errors,
|
2019-05-11 16:45:55 +00:00
|
|
|
resource_name=resource_name,
|
|
|
|
farm_name=farm_name,
|
|
|
|
discord_uuid=ctx.message.author.id)
|
|
|
|
|
|
|
|
await ctx.send('{}, **{}** has been added to the farm.'.format(ctx.message.author.mention, resource["name"]))
|
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def add_shop(self, ctx, x_pos: int, z_pos: int, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-02-02 16:12:58 +00:00
|
|
|
{}add_shop <X Coordinate> <Z Coordinate> <Shop Name>
|
|
|
|
The Shop Name parameter is optional if this is your first shop
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "you have more than one location. Please specify a name."
|
|
|
|
}
|
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
name = get_name(args)
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
shop = await run_command(ctx, self.api_url, self.api_token, "POST", "add_shop", errors=errors, x_pos=x_pos,
|
2019-05-10 21:22:10 +00:00
|
|
|
z_pos=z_pos, name=name, discord_uuid=ctx.message.author.id)
|
|
|
|
|
|
|
|
await ctx.send('{}, your shop has been added to the database: \n{}'.format(ctx.message.author.mention,
|
|
|
|
formatted_location(shop)))
|
2019-02-17 03:21:29 +00:00
|
|
|
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def add_town(self, ctx, x_pos: int, z_pos: int, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-14 22:38:39 +00:00
|
|
|
{}add_town <X Coordinate> <Z Coordinate> <Town Name>
|
2019-02-17 03:21:29 +00:00
|
|
|
The Town Name parameter is optional if this is your first town
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "you have more than one location. Please specify a name."
|
|
|
|
}
|
2019-02-17 03:21:29 +00:00
|
|
|
|
|
|
|
name = get_name(args)
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
town = await run_command(ctx, self.api_url, self.api_token, "POST", "add_town", errors=errors, x_pos=x_pos,
|
2019-05-10 21:22:10 +00:00
|
|
|
z_pos=z_pos, name=name,
|
|
|
|
discord_uuid=ctx.message.author.id)
|
|
|
|
|
|
|
|
await ctx.send(
|
|
|
|
'{}, your town has been added to the database: \n{}'.format(ctx.message.author.mention,
|
|
|
|
formatted_location(town)))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def add_tunnel(self, ctx, tunnel_direction, tunnel_number: int, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-15 13:14:50 +00:00
|
|
|
{}add_tunnel <Tunnel Direction> <X or Z Tunnel Number> <Location Name>
|
2019-02-02 16:12:58 +00:00
|
|
|
The Name parameter is optional if you only have one location
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-14 22:38:39 +00:00
|
|
|
|
|
|
|
name = get_name(args)
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"InvalidTunnelError": "{} is not a valid tunnel direction ya gub".format(tunnel_direction),
|
2019-05-14 22:38:39 +00:00
|
|
|
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(name)
|
2019-05-10 21:22:10 +00:00
|
|
|
}
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
tunnel = await run_command(ctx, self.api_url, self.api_token, "POST", "add_tunnel", errors=errors,
|
2019-05-10 21:22:10 +00:00
|
|
|
tunnel_direction=tunnel_direction,
|
|
|
|
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))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def delete(self, ctx, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
{}delete <Location Name>
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-14 20:20:16 +00:00
|
|
|
name = get_name(args)
|
2019-05-10 21:22:10 +00:00
|
|
|
|
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(name)
|
|
|
|
}
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "delete", errors=errors, name=name,
|
2019-05-10 21:22:10 +00:00
|
|
|
discord_uuid=ctx.message.author.id)
|
|
|
|
|
|
|
|
await ctx.send("{}, **{}** has been deleted from Geoffrey, good riddance.".format(ctx.message.author.mention
|
|
|
|
, location))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def delete_item(self, ctx, item_name: str, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-02-02 16:12:58 +00:00
|
|
|
{}delete_item <Item Name> <Shop Name>
|
|
|
|
The Shop Name parameter is optional if you only have one location.
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
shop_name = get_name(args)
|
2019-05-10 21:22:10 +00:00
|
|
|
|
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "you do not have a shop by that name you ding dong goober.",
|
|
|
|
"EntryNameNotUniqueError": "you have more than one location. Please specify a name, dingus.",
|
|
|
|
"ItemNotFound": "your shop does not sell **{}**. Try again buddy boy.".format(item_name)
|
|
|
|
}
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
shop = await run_command(ctx, self.api_url, self.api_token, "POST", "delete_item", errors=errors,
|
2019-05-10 21:22:10 +00:00
|
|
|
item=item_name,
|
|
|
|
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"]))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-11 16:45:55 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def delete_resource(self, ctx, resource_name: str, *args):
|
|
|
|
"""
|
|
|
|
{}delete_resource <Resource Name> <Farm Name>
|
|
|
|
The Farm Name parameter is optional if you only have one location.
|
|
|
|
"""
|
|
|
|
|
|
|
|
farm_name = get_name(args)
|
|
|
|
|
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "you do not have a farm by that name you ding dong goober.",
|
|
|
|
"EntryNameNotUniqueError": "you have more than one location. Please specify a name, dingus.",
|
|
|
|
"ItemNotFound": "your farm does not produce **{}**. Try again buddy boy.".format(resource_name)
|
|
|
|
}
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
farm = await run_command(ctx, self.api_url, self.api_token, "POST", "delete_resource", errors=errors,
|
2019-05-11 16:45:55 +00:00
|
|
|
resource=resource_name,
|
|
|
|
farm_name=farm_name, discord_uuid=ctx.message.author.id)
|
|
|
|
|
|
|
|
await ctx.send("{}, **{}** has been deleted from {}, Hythe's farm is better anyway.".format(
|
|
|
|
ctx.message.author.mention, resource_name, farm["name"]))
|
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
@commands.command(pass_conext=True)
|
|
|
|
async def edit_name(self, ctx, new_name: str, old_name: str):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
{}edit_name <New Name> <Old Name>
|
|
|
|
If the name has spaces in it, it must be wrapped in quotes. eg "Cool Shop 123"
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"EntryNameNotUniqueError": "a location is already called **{}** you ding dong goober".format(old_name),
|
2019-05-14 22:38:39 +00:00
|
|
|
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(
|
2019-05-10 21:22:10 +00:00
|
|
|
old_name)
|
|
|
|
}
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "edit_name", errors=errors,
|
2019-05-10 21:22:10 +00:00
|
|
|
loc_name=old_name,
|
|
|
|
new_name=new_name, discord_uuid=ctx.message.author.id)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
await ctx.send("{}, **{}** has been renamed to **{}**.".format(ctx.message.author.mention, old_name,
|
|
|
|
location["name"]))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
|
|
|
@commands.command(pass_conext=True)
|
|
|
|
async def edit_pos(self, ctx, new_x: int, new_z: int, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-14 22:38:39 +00:00
|
|
|
{}edit_pos <New X Coordinate> <New Z Coordinate> <Location Name>
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
loc_name = get_name(args)
|
2019-05-10 21:22:10 +00:00
|
|
|
|
|
|
|
errors = {
|
2019-09-26 15:23:23 +00:00
|
|
|
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(
|
|
|
|
loc_name)
|
2019-05-10 21:22:10 +00:00
|
|
|
}
|
2019-09-27 21:00:28 +00:00
|
|
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "edit_pos", errors=errors, x=new_x,
|
2019-05-10 21:22:10 +00:00
|
|
|
z=new_z,
|
|
|
|
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"]))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
|
|
|
@commands.command(pass_conext=True)
|
|
|
|
async def edit_tunnel(self, ctx, new_tunnel_direction: str, new_tunnel_number: int, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
{}edit_tunnel <New Tunnel Direction> <New Tunnel Number> <Location Name>
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
loc_name = get_name(args)
|
2019-05-10 21:22:10 +00:00
|
|
|
|
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "you do not have a location by the name **{}** you ding dong goober.".format(
|
2019-05-14 22:38:39 +00:00
|
|
|
loc_name),
|
|
|
|
"InvalidTunnelError": "{} is not a valid tunnel direction ya gub".format(new_tunnel_direction)
|
2019-05-10 21:22:10 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "edit_tunnel", errors=errors,
|
|
|
|
tunnel_direction=new_tunnel_direction, tunnel_number=new_tunnel_number,
|
|
|
|
loc_name=loc_name, discord_uuid=ctx.message.author.id)
|
2019-05-10 21:22:10 +00:00
|
|
|
|
|
|
|
await ctx.send("{}, **{}**'s tunnel been moved to **{}**".format(ctx.message.author.mention,
|
|
|
|
location["name"],
|
|
|
|
location["tunnel"]))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def find_around(self, ctx, x_pos, z_pos, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-02-02 16:12:58 +00:00
|
|
|
{}find_around <X Coordinate> <Z Coordinate> <Radius>
|
|
|
|
The Radius parameter is optional and defaults to 200 blocks
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "there are no locations in that area."
|
|
|
|
}
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
if len(args) > 0:
|
|
|
|
radius = int(args[0])
|
|
|
|
else:
|
|
|
|
radius = 200
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
locations = await run_command(ctx, self.api_url, self.api_token, "GET", "find_around", errors=errors,
|
2019-05-14 22:38:39 +00:00
|
|
|
x_pos=x_pos, z_pos=z_pos, radius=radius)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
message = ["{}, the following locations are within **{}** blocks of (x={}, z={}):".format(
|
|
|
|
ctx.message.author.mention, radius, x_pos, z_pos)]
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
for location in locations:
|
|
|
|
message.append(formatted_location(location))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
await self.bot.send_list(ctx, message)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-14 22:38:39 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def find_farm(self, ctx, *args):
|
|
|
|
"""
|
|
|
|
{}find_farm <Resource>
|
|
|
|
"""
|
|
|
|
|
|
|
|
search = get_name(args)
|
|
|
|
|
|
|
|
errors = {
|
|
|
|
"ResourceNotFoundError": "there are no farms that match **{}**.".format(search)
|
|
|
|
}
|
2019-09-27 21:00:28 +00:00
|
|
|
locations = await run_command(ctx, self.api_url, self.api_token, "GET", "find_farm", errors=errors,
|
2019-05-14 22:38:39 +00:00
|
|
|
resource_name=search)
|
|
|
|
|
|
|
|
message = ["{}, the following farms produce **{}**:".format(ctx.message.author.mention, search)]
|
|
|
|
|
|
|
|
for location in locations:
|
|
|
|
message.append(formatted_location(location))
|
|
|
|
|
|
|
|
await self.bot.send_list(ctx, message)
|
|
|
|
|
2019-01-28 02:35:17 +00:00
|
|
|
@commands.command(pass_context=True, aliases=["find"])
|
|
|
|
async def find_location(self, ctx, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
{}find_location <Location or Player Name>
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
search = get_name(args)
|
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "there are no locations that match **{}**.".format(search)
|
|
|
|
}
|
2019-09-27 21:00:28 +00:00
|
|
|
locations = await run_command(ctx, self.api_url, self.api_token, "GET", "find_location", errors=errors,
|
2019-05-10 21:22:10 +00:00
|
|
|
search=search)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
message = ["{}, the following locations match **{}**:".format(ctx.message.author.mention, search)]
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
for location in locations:
|
|
|
|
message.append(formatted_location(location))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
await self.bot.send_list(ctx, message)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-01-28 02:35:17 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def help(self, ctx, *args):
|
2019-01-28 02:53:13 +00:00
|
|
|
if ctx.message.guild is not None:
|
|
|
|
await ctx.send("{}, I sent you some help in the DMs.".format(ctx.message.author.mention))
|
|
|
|
|
2019-01-28 02:35:17 +00:00
|
|
|
if len(args) > 0:
|
|
|
|
command = args[0].lower()
|
|
|
|
try:
|
|
|
|
await self.bot.send_list(ctx.message.author, self.bot.help_dict[command])
|
|
|
|
except KeyError:
|
|
|
|
await ctx.message.author.send("{}, no command named **{}** exists. Try {}help".format(
|
|
|
|
ctx.message.author.mention, command, self.bot.prefix))
|
|
|
|
else:
|
|
|
|
await self.bot.send_list(ctx.message.author, self.bot.help_page)
|
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def info(self, ctx, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
{}info <Location Name>
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
location_name = get_name(args)
|
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "there are no locations that match **{}**.".format(location_name)
|
|
|
|
}
|
2019-02-17 03:21:29 +00:00
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
location = await run_command(ctx, self.api_url, self.api_token, "GET", "info", location_name=location_name,
|
2019-05-10 21:22:10 +00:00
|
|
|
errors=errors)
|
2019-02-17 03:21:29 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
message = "{}, info on {}:\n".format(ctx.message.author.mention, location["name"])
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
if location["type"] == "Shop":
|
2019-09-27 21:00:28 +00:00
|
|
|
info_list = formatted_shop(location, self.geoffrey_app_url)
|
2019-05-10 21:22:10 +00:00
|
|
|
elif location["type"] == "Town":
|
2019-09-27 21:00:28 +00:00
|
|
|
info_list = formatted_town(location, self.geoffrey_app_url)
|
2019-05-11 16:45:55 +00:00
|
|
|
elif location["type"] == "PublicFarm":
|
2019-09-27 21:00:28 +00:00
|
|
|
info_list = formatted_farm(location, self.geoffrey_app_url)
|
2019-05-11 16:45:55 +00:00
|
|
|
elif location["type"] == "Market":
|
2019-09-27 21:00:28 +00:00
|
|
|
info_list = formatted_market(location, self.geoffrey_app_url)
|
2019-05-10 21:22:10 +00:00
|
|
|
else:
|
2019-09-27 21:00:28 +00:00
|
|
|
info_list = formatted_location_info(location, self.geoffrey_app_url)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
await ctx.send(message)
|
|
|
|
await self.bot.send_list(ctx, info_list)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def me(self, ctx):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
{}me
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
locations = await run_command(ctx, self.api_url, self.api_token, "GET", "me",
|
2019-05-10 21:22:10 +00:00
|
|
|
discord_uuid=ctx.message.author.id)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
|
|
|
message = ["{}, you have the following locations:".format(ctx.message.author.mention)]
|
|
|
|
|
|
|
|
for location in locations:
|
|
|
|
message.append(formatted_location(location))
|
|
|
|
|
|
|
|
await self.bot.send_list(ctx, message)
|
|
|
|
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def register(self, ctx):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
{}register
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
2019-05-14 13:02:14 +00:00
|
|
|
"PlayerInDBError": "you are already registered with Geoffrey you ding dong."
|
2019-05-10 21:22:10 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
await run_command(ctx, self.api_url, self.api_token, "POST", "register", errors=errors,
|
2019-05-10 21:22:10 +00:00
|
|
|
player_name=ctx.message.author.display_name,
|
|
|
|
discord_uuid=ctx.message.author.id)
|
2019-05-14 02:05:37 +00:00
|
|
|
await ctx.send("{}, you have been added to the database. Do {}help to see what this bot can do.".format(
|
2019-05-13 14:52:15 +00:00
|
|
|
ctx.message.author.mention,
|
2019-05-14 02:05:37 +00:00
|
|
|
self.bot.prefix))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-02-17 03:21:29 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def remove_resident(self, ctx, resident_name, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-02-17 03:21:29 +00:00
|
|
|
{}remove_resident <Resident Name> <Town Name>
|
|
|
|
The Town Name is optional if you only have one town.
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-02-17 03:21:29 +00:00
|
|
|
|
|
|
|
town_name = get_name(args)
|
2019-05-10 21:22:10 +00:00
|
|
|
|
|
|
|
errors = {
|
2019-05-14 22:38:39 +00:00
|
|
|
"ResidentNotFoundError": "ain't no one in your town named {} you goob".format(resident_name),
|
2019-05-10 21:22:10 +00:00
|
|
|
"LocationLookUpError": "you do not have a town called **{}** you ding dong goober.".format(town_name)
|
|
|
|
}
|
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
location = await run_command(ctx, self.api_url, self.api_token, "POST", "remove_resident", errors=errors,
|
2019-05-10 21:22:10 +00:00
|
|
|
resident_name=resident_name,
|
|
|
|
town_name=town_name, discord_uuid=ctx.message.author.id)
|
|
|
|
|
|
|
|
await ctx.send('{}, **{}** has been remove as a resident of **{}**'.format(
|
|
|
|
ctx.message.author.mention, resident_name, location["name"]))
|
2019-02-17 03:21:29 +00:00
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def selling(self, ctx, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-02-02 16:12:58 +00:00
|
|
|
{}selling <Item Name>
|
|
|
|
Sorts by most recently added
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-14 20:20:16 +00:00
|
|
|
item = get_name(args)
|
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"ItemNotFound": "no shop was found selling {}".format(item)
|
|
|
|
}
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
results = await run_command(ctx, self.api_url, self.api_token, "GET", "selling", errors=errors, item_name=item)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
message = ["{} The following shop(s) sell **{}**:".format(ctx.message.author.mention, item)]
|
2019-02-17 03:21:29 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
for shop in results:
|
2019-09-27 21:00:28 +00:00
|
|
|
for line in formatted_shop(shop, base_url=self.geoffrey_app_url):
|
2019-05-10 21:22:10 +00:00
|
|
|
message.append(line)
|
2019-02-17 03:21:29 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
message.append('')
|
2019-02-17 03:21:29 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
await self.bot.send_list(ctx, message)
|
2019-02-17 03:21:29 +00:00
|
|
|
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def selling_price(self, ctx, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-05-14 22:38:39 +00:00
|
|
|
{}selling_price <Item Name>
|
2019-05-10 21:22:10 +00:00
|
|
|
Sorts by best price
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-02-17 03:21:29 +00:00
|
|
|
item = get_name(args)
|
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"ItemNotFound": "no shop was found selling {}".format(item)
|
|
|
|
}
|
2019-02-17 03:21:29 +00:00
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
results = await run_command(ctx, self.api_url, self.api_token, "GET", "selling_price", errors=errors,
|
2019-05-10 21:22:10 +00:00
|
|
|
item_name=item)
|
2019-02-17 03:21:29 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
message = ["{} The following shop(s) sell **{}**:".format(ctx.message.author.mention, item)]
|
2019-02-17 03:21:29 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
for shop in results:
|
2019-09-27 21:00:28 +00:00
|
|
|
for line in formatted_shop(shop, base_url=self.geoffrey_app_url):
|
2019-05-10 21:22:10 +00:00
|
|
|
message.append(line)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
message.append('')
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
await self.bot.send_list(ctx, message)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def restock(self, ctx, item_name, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
{}restock <Item name> <Shop Name>
|
2019-02-02 16:12:58 +00:00
|
|
|
The Shop Name is optional if you only have one shop.
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
shop_name = get_name(args)
|
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"ItemNotFound": "that shop does not have **{}** in its inventory".format(item_name),
|
|
|
|
"LocationLookUpError": "you do not have a shop named **{}**.".format(shop_name),
|
|
|
|
"EntryNameNotUniqueError": "you have more than one location. Please specify a name, dingus."
|
|
|
|
}
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-09-27 21:00:28 +00:00
|
|
|
item = await run_command(ctx, self.api_url, self.api_token, "POST", "restock", errors=errors,
|
2019-05-10 21:22:10 +00:00
|
|
|
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"]))
|
2019-02-17 03:21:29 +00:00
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def tunnel(self, ctx, *args):
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
{}tunnel <Player Name>
|
2019-04-10 19:08:39 +00:00
|
|
|
"""
|
2019-01-28 02:35:17 +00:00
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
player_name = get_name(args)
|
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
errors = {
|
|
|
|
"LocationLookUpError": "**{}** has no tunnels in the database.".format(player_name)
|
|
|
|
}
|
2019-09-27 21:00:28 +00:00
|
|
|
tunnels = await run_command(ctx, self.api_url, self.api_token, "GET", "tunnel", errors=errors,
|
2019-05-10 21:22:10 +00:00
|
|
|
player_name=player_name)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
message = ["{}, **{}** has the following tunnels:".format(ctx.message.author.mention, player_name)]
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
for tunnel in tunnels:
|
|
|
|
message.append(formatted_tunnel(tunnel))
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-05-10 21:22:10 +00:00
|
|
|
await self.bot.send_list(ctx, message)
|
2019-01-14 20:20:16 +00:00
|
|
|
|
2019-02-02 16:12:58 +00:00
|
|
|
|
2019-01-14 20:20:16 +00:00
|
|
|
def setup(bot):
|
|
|
|
bot.add_cog(GeoffreyCommands(bot))
|