The bot now uses the rewrite... like it should have this whole time...

doc_update
Joey Hines 2018-09-12 16:11:56 -05:00
parent 6e6ba39fab
commit 3f477eefc5
7 changed files with 80 additions and 80 deletions

View File

@ -306,7 +306,7 @@ class Commands:
expr = (ItemListing.name == item) & (ItemListing.shop == shop)
self.interface.database.delete_entry(session, ItemListing, expr)
shop_str = shop.full_str(self.bot_config)
shop_str = shop.name
finally:
session.close()

View File

@ -61,16 +61,16 @@ class GeoffreyBot(commands.Bot):
logger.info("Bot url: %s", url)
await self.change_presence(activity=Game(self.default_status))
async def on_command(self, command, ctx):
async def on_command(self, ctx):
if ctx.invoked_subcommand is None:
subcommand = ""
else:
subcommand = ":" + ctx.invoked_subcommand
subcommand = ":" + ctx.invoked_subcommand.__str__()
logger.info("User %s, used command %s%s with context: %s", ctx.message.author, command, subcommand,
logger.info("User %s, used command %s%s with context: %s", ctx.message.author, ctx.command, subcommand,
ctx.args)
async def on_command_error(self, error, ctx):
async def on_command_error(self, ctx, error):
error_str = ''
if hasattr(ctx, 'cog'):
if "Admin_Commands" in ctx.cog.__str__():
@ -98,7 +98,7 @@ class GeoffreyBot(commands.Bot):
error_str = 'Invalid syntax for **{}** you ding dong:' \
.format(ctx.invoked_with, ctx.invoked_with)
pages = self.formatter.format_help_for(ctx, ctx.command)
pages = await self.formatter.format_help_for(ctx, ctx.command)
for page in pages:
error_str = error_str + '\n' + page
elif isinstance(error, commands.CommandNotFound):
@ -111,13 +111,13 @@ class GeoffreyBot(commands.Bot):
logger.error("Geoffrey encountered exception: %s", error)
await self.send_message(ctx.message.channel, '{} **Error Running Command:** {}'.format(
await ctx.message.channel.send('{} **Error Running Command:** {}'.format(
ctx.message.author.mention, error_str))
async def send_error_message(self, msg):
for user_id in self.error_users:
user = await self.get_user_info(user_id)
await self.send_message(user, msg)
await user.send(msg)
async def username_update(bot):

View File

@ -25,11 +25,11 @@ class Add_Commands:
try:
player_name = get_nickname(ctx.message.author, self.bot.special_users)
self.bot.bot_commands.register(player_name, ctx.message.author.id)
await self.bot.say('{}, you have been added to the database.'.format(ctx.message.author.mention))
await ctx.send('{}, you have been added to the database.'.format(ctx.message.author.mention))
except AttributeError:
raise NotOnServerError
except PlayerInDBError:
await self.bot.say('{}, you are already in the database. Ding dong.'.format(ctx.message.author.mention))
await ctx.send('{}, you are already in the database. Ding dong.'.format(ctx.message.author.mention))
@commands.command(pass_context=True)
@commands.cooldown(5, 60, commands.BucketType.user)
@ -43,16 +43,16 @@ class Add_Commands:
try:
base = self.bot.bot_commands.add_base(x_pos, z_pos, base_name=name, discord_uuid=ctx.message.author.id)
await self.bot.say(
await ctx.send(
'{}, your base has been added to the database: \n\n{}'.format(ctx.message.author.mention, base))
except LocationInitError:
raise commands.UserInputError
except EntryNameNotUniqueError:
if name is None:
await self.bot.say('{}, you already have one base in the database, you need to specify a base'
await ctx.send('{}, you already have one base in the database, you need to specify a base'
' name'.format(ctx.message.author.mention))
else:
await self.bot.say(
await ctx.send(
'{}, a base called **{}** already exists. You need to specify a different name.'.format(
ctx.message.author.mention, name))
@ -68,17 +68,17 @@ class Add_Commands:
try:
shop = self.bot.bot_commands.add_shop(x_pos, z_pos, shop_name=name, discord_uuid=ctx.message.author.id)
await self.bot.say(
await ctx.send(
'{}, your shop has been added to the database: \n\n{}'.format(ctx.message.author.mention, shop))
except LocationInitError:
raise commands.UserInputError
except EntryNameNotUniqueError:
if name is None:
await self.bot.say(
await ctx.send(
'{}, you already have one shop in the database, you need to specify a shop name'.format(
ctx.message.author.mention))
else:
await self.bot.say(
await ctx.send(
'{}, a shop called **{}** already exists. You need to specify a different name.'.format(
ctx.message.author.mention, name))
@ -94,19 +94,19 @@ class Add_Commands:
try:
self.bot.bot_commands.add_tunnel(tunnel_color, tunnel_number, discord_uuid=ctx.message.author.id,
location_name=loc_name)
await self.bot.say('{}, your tunnel has been added to the database'.format(ctx.message.author.mention))
await ctx.send('{}, your tunnel has been added to the database'.format(ctx.message.author.mention))
except LocationLookUpError:
await self.bot.say('{}, you do not have a location called **{}**.'.format(
await ctx.send('{}, you do not have a location called **{}**.'.format(
ctx.message.author.mention, loc_name))
except LocationHasTunnelError:
await self.bot.say('{}, **{}** already has a tunnel.'.format(ctx.message.author.mention, loc_name))
await ctx.send('{}, **{}** already has a tunnel.'.format(ctx.message.author.mention, loc_name))
except TunnelInitError:
await self.bot.say('{}, invalid tunnel color.'.format(ctx.message.author.mention))
await ctx.send('{}, invalid tunnel color.'.format(ctx.message.author.mention))
except EntryNameNotUniqueError:
await self.bot.say('{}, you have more than one location, you need to specify a location.'
await ctx.send('{}, you have more than one location, you need to specify a location.'
.format(ctx.message.author.mention))
except InvalidTunnelError:
await self.bot.say(
await ctx.send(
'{}, **{}** is an invalid tunnel color.'.format(ctx.message.author.mention, tunnel_color))
@commands.command(pass_context=True)
@ -115,22 +115,22 @@ class Add_Commands:
"""
Adds an item to a shop's inventory. If you have one shop, the shop name is not required.
Quantity for Diamond Price. eg. 32 Dirt for 1D
?additem [Item Name] [Quantity] [Price] [Shop name]
?add_item [Item Name] [Quantity] [Price] [Shop name]
"""
shop_name = get_name(args)
try:
self.bot.bot_commands.add_item(item_name, quantity, diamond_price, shop_name=shop_name,
discord_uuid=ctx.message.author.id)
await self.bot.say(
await ctx.send(
'{}, **{}** has been added to the inventory of your shop.'.format(ctx.message.author.mention,
item_name))
except PlayerNotFound:
await self.bot.say('{}, you don\'t have any shops in the database.'.format(ctx.message.author.mention))
await ctx.send('{}, you don\'t have any shops in the database.'.format(ctx.message.author.mention))
except LocationInitError:
await self.bot.say('{}, you have more than one shop in the database, please specify a shop name.'
await ctx.send('{}, you have more than one shop in the database, please specify a shop name.'
.format(ctx.message.author.mention))
except LocationLookUpError:
await self.bot.say(
await ctx.send(
'{}, you don\'t have any shops named **{}** in the database.'.format(ctx.message.author.mention,
shop_name))

View File

@ -7,7 +7,7 @@ from geoffrey.BotErrors import *
def check_mod(user, admin_users):
try:
for role in user.roles:
if role.id in admin_users:
if str(role.id) in admin_users:
return True
except AttributeError:
raise NotOnServerError
@ -23,7 +23,7 @@ class Admin_Commands:
def __init__(self, bot):
self.bot = bot
async def error(self, error, ctx):
async def error(self, ctx, error):
if isinstance(error, PlayerNotFound):
error_str = 'that player is not in the database.'
elif isinstance(error, DeleteEntryError):
@ -31,7 +31,7 @@ class Admin_Commands:
else:
error_str = 'the bot encountered the following error: {}'.format(error.__str__())
await self.bot.send_message(ctx.message.channel, '{}, {}'.format(ctx.message.author.mention, error_str))
await ctx.send('{}, {}'.format(ctx.message.author.mention, error_str))
@commands.command(pass_context=True)
async def test(self, ctx):
@ -39,7 +39,7 @@ class Admin_Commands:
Checks if the bot is alive.
"""
if check_mod(ctx.message.author, self.bot.admin_users):
await self.bot.say('I\'m here you ding dong')
await ctx.send('I\'m here you ding dong')
else:
raise NoPermissionError
@ -50,7 +50,7 @@ class Admin_Commands:
"""
if check_mod(ctx.message.author, self.bot.admin_users):
if ctx.invoked_subcommand is None:
await self.bot.say('{}, invalid sub-command for command **mod**.'.format(ctx.message.author.mention))
await ctx.send('{}, invalid sub-command for command **mod**.'.format(ctx.message.author.mention))
else:
raise NoPermissionError
@ -60,11 +60,11 @@ class Admin_Commands:
Deletes a location in the database.
"""
self.bot.bot_commands.delete(location_name, discord_uuid=discord_uuid)
await self.bot.say('{}, **{}** has been deleted.'.format(ctx.message.author.mention, location_name))
await ctx.send('{}, **{}** has been deleted.'.format(ctx.message.author.mention, location_name))
@delete.error
async def delete_error(self, error, ctx):
await self.error(error, ctx)
async def delete_error(self, ctx, error):
await self.error(ctx, error)
@mod.command(pass_context=True)
async def edit_name(self, ctx, discord_uuid: str, new_name: str, current_name: str):
@ -72,12 +72,12 @@ class Admin_Commands:
Edits the name of a location in the database.
"""
self.bot.bot_commands.edit_name(new_name, current_name, discord_uuid=discord_uuid)
await self.bot.say('{}, **{}** has been rename to **{}**.'.format(ctx.message.author.mention, current_name,
await ctx.send('{}, **{}** has been rename to **{}**.'.format(ctx.message.author.mention, current_name,
new_name))
@edit_name.error
async def edit_error(self, error, ctx):
await self.error(error, ctx)
async def edit_error(self, ctx, error):
await self.error(ctx, error)
@mod.command(pass_context=True)
async def update_mc_uuid(self, ctx, discord_uuid: str, mc_uuid: str):
@ -85,11 +85,11 @@ class Admin_Commands:
Updates a user's MC UUID.
"""
self.bot.bot_commands.update_mc_uuid(discord_uuid, mc_uuid)
await self.bot.say('{}, **{}** has been updated.'.format(ctx.message.author.mention, discord_uuid))
await ctx.send('{}, **{}** has been updated.'.format(ctx.message.author.mention, discord_uuid))
@update_mc_uuid.error
async def update_mc_uuid_error(self, error, ctx):
await self.error(error, ctx)
async def update_mc_uuid_error(self, ctx, error):
await self.error(ctx, error)
@mod.command(pass_context=True)
async def update_discord_uuid(self, ctx, current_discord_uuid: str, new_discord_uuid: str):
@ -97,11 +97,11 @@ class Admin_Commands:
Updates a user's Discord UUID.
"""
self.bot.bot_commands.update_mc_uuid(current_discord_uuid, new_discord_uuid)
await self.bot.say('{}, user **{}** has been updated.'.format(ctx.message.author.mention, current_discord_uuid))
await ctx.send('{}, user **{}** has been updated.'.format(ctx.message.author.mention, current_discord_uuid))
@update_discord_uuid.error
async def update_discord_uuid_error(self, error, ctx):
await self.error(error, ctx)
async def update_discord_uuid_error(self, ctx, error):
await self.error(ctx, error)
@mod.command(pass_context=True)
async def update_mc_name(self, ctx, discord_uuid: str):
@ -109,19 +109,19 @@ class Admin_Commands:
Updates a user's MC name to the current name on the MC UUID.
"""
self.bot.bot_commands.update_mc_name(discord_uuid)
await self.bot.say('{}, user **{}**\'s MC name has update.'.format(ctx.message.author.mention, discord_uuid))
await ctx.send('{}, user **{}**\'s MC name has update.'.format(ctx.message.author.mention, discord_uuid))
@update_mc_name.error
async def update_mc_name_error(self, error, ctx):
await self.error(error, ctx)
async def update_mc_name_error(self, ctx, error):
await self.error(ctx, error)
@mod.command(pass_context=True)
async def status(self, ctx, status: str):
"""
Updates "playing [game]" status of the bot.
"""
await self.bot.change_presence(game=Game(name=status))
await self.bot.say('{}, status has been changed'.format(ctx.message.author.mention))
await self.bot.change_presence(activity=Game(status))
await ctx.send('{}, status has been changed'.format(ctx.message.author.mention))
def setup(bot):

View File

@ -26,10 +26,10 @@ class Delete_Commands:
raise commands.UserInputError
self.bot.bot_commands.delete(loc, discord_uuid=ctx.message.author.id)
await self.bot.say(
await ctx.send(
'{}, your location named **{}** has been deleted.'.format(ctx.message.author.mention, loc))
except (DeleteEntryError, PlayerNotFound):
await self.bot.say('{}, you do not have a location named **{}**.'.format(ctx.message.author.mention, loc))
await ctx.send('{}, you do not have a location named **{}**.'.format(ctx.message.author.mention, loc))
@commands.command(pass_context=True)
async def delete_item(self, ctx, item: str, *args):
@ -41,23 +41,23 @@ class Delete_Commands:
shop = get_name(args)
try:
self.bot.bot_commands.delete_item(item, shop, discord_uuid=ctx.message.author.id)
shop_name = self.bot.bot_commands.delete_item(item, shop, discord_uuid=ctx.message.author.id)
await self.bot.say('{}, **{}** has been removed from the inventory of **{}**.'.
format(ctx.message.author.mention, item, shop))
await ctx.send('{}, **{}** has been removed from the inventory of **{}**.'.
format(ctx.message.author.mention, item, shop_name))
except LocationLookUpError:
if shop is None:
await self.bot.say('{}, you do have any shops in the database.'.format(ctx.message.author.mention))
await ctx.send('{}, you do have any shops in the database.'.format(ctx.message.author.mention))
else:
await self.bot.say('{}, you do not have a shop called **{}**.'.format(ctx.message.author.mention, shop))
await ctx.send('{}, you do not have a shop called **{}**.'.format(ctx.message.author.mention, shop))
except EntryNameNotUniqueError:
await self.bot.say('{}, you have more than one shop in the database, please specify a shop name.'
await ctx.send('{}, you have more than one shop in the database, please specify a shop name.'
.format(ctx.message.author.mention))
except DeleteEntryError:
if shop is not None:
await self.bot.say('{}, **{}** does not sell **{}**.'.format(ctx.message.author.mention, shop, item))
await ctx.send('{}, **{}** does not sell **{}**.'.format(ctx.message.author.mention, shop, item))
else:
await self.bot.say('{}, your shop does not sell **{}**.'.format(ctx.message.author.mention, item))
await ctx.send('{}, your shop does not sell **{}**.'.format(ctx.message.author.mention, item))
def setup(bot):

View File

@ -22,10 +22,10 @@ class Edit_Commands:
try:
loc_str = self.bot.bot_commands.edit_pos(x_pos, y_pos, loc, discord_uuid=ctx.message.author.id)
await self.bot.say(
await ctx.send(
'{}, the following location has been updated: \n\n{}'.format(ctx.message.author.mention, loc_str))
except LocationLookUpError:
await self.bot.say('{}, you do not have a location called **{}**.'.format(
await ctx.send('{}, you do not have a location called **{}**.'.format(
ctx.message.author.mention, loc))
@commands.command(pass_context=True)
@ -40,13 +40,13 @@ class Edit_Commands:
loc_str = self.bot.bot_commands.edit_tunnel(tunnel_color, tunnel_number, loc,
discord_uuid=ctx.message.author.id)
await self.bot.say(
await ctx.send(
'{}, the following location has been updated: \n\n{}'.format(ctx.message.author.mention, loc_str))
except LocationLookUpError:
await self.bot.say('{}, you do not have a location called **{}**.'.format(
await ctx.send('{}, you do not have a location called **{}**.'.format(
ctx.message.author.mention, loc))
except InvalidTunnelError:
await self.bot.say(
await ctx.send(
'{}, **{}** is an invalid tunnel color.'.format(ctx.message.author.mention, tunnel_color))
@commands.command(pass_context=True)
@ -60,10 +60,10 @@ class Edit_Commands:
try:
loc_str = self.bot.bot_commands.edit_name(new_name, current_name, discord_uuid=ctx.message.author.id)
await self.bot.say(
await ctx.send(
'{}, the following location has been updated: \n\n{}'.format(ctx.message.author.mention, loc_str))
except LocationLookUpError:
await self.bot.say('{}, you do not have a location called **{}**.'.format(
await ctx.send('{}, you do not have a location called **{}**.'.format(
ctx.message.author.mention, current_name))

View File

@ -27,10 +27,10 @@ class Search_Commands:
result = self.bot.bot_commands.find(search)
await self.bot.say(
await ctx.send(
'{}, The following entries match **{}**:\n{}'.format(ctx.message.author.mention, search, result))
except LocationLookUpError:
await self.bot.say(
await ctx.send(
'{}, no matches to **{}** were found in the database.'.format(ctx.message.author.mention, search))
@commands.command(pass_context=True)
@ -43,10 +43,10 @@ class Search_Commands:
try:
result = self.bot.bot_commands.tunnel(player)
await self.bot.say(
await ctx.send(
'{}, **{}** owns the following tunnels: \n{}'.format(ctx.message.author.mention, player, result))
except LocationLookUpError:
await self.bot.say('{}, no tunnels for **{}** were found in the database.'
await ctx.send('{}, no tunnels for **{}** were found in the database.'
.format(ctx.message.author.mention, player))
@commands.command(pass_context=True)
@ -80,17 +80,17 @@ class Search_Commands:
base_string = self.bot.bot_commands.find_around(x_pos, z_pos, radius, dimension)
if len(base_string) != 0:
await self.bot.say('{}, the following locations(s) within **{}** blocks of that point: \n {}'.format(
await ctx.send('{}, the following locations(s) within **{}** blocks of that point: \n {}'.format(
ctx.message.author.mention, radius, base_string))
else:
await self.bot.say('{}, there are no locations within {} blocks of that point'
await ctx.send('{}, there are no locations within {} blocks of that point'
.format(ctx.message.author.mention, radius))
except ValueError:
await self.bot.say(
await ctx.send(
'{}, invalid radius, the radius must be a whole number.'.format(ctx.message.author.mention,
radius))
except InvalidDimError:
await self.bot.say('{}, {} is an invalid dimension.'.format(ctx.message.author.mention, dimension))
await ctx.send('{}, {} is an invalid dimension.'.format(ctx.message.author.mention, dimension))
@commands.command(pass_context=True)
@commands.cooldown(5, 60, commands.BucketType.user)
@ -101,10 +101,10 @@ class Search_Commands:
"""
try:
result = self.bot.bot_commands.selling(item_name)
await self.bot.say(
await ctx.send(
'{}, the following shops sell **{}**: \n{}'.format(ctx.message.author.mention, item_name, result))
except ItemNotFound:
await self.bot.say('{}, no shop sells **{}**.'.format(ctx.message.author.mention, item_name))
await ctx.send('{}, no shop sells **{}**.'.format(ctx.message.author.mention, item_name))
@commands.command(pass_context=True)
@commands.cooldown(5, 60, commands.BucketType.user)
@ -121,9 +121,9 @@ class Search_Commands:
raise commands.UserInputError
info_str = self.bot.bot_commands.info(loc)
await self.bot.say(info_str)
await ctx.send(info_str)
except IndexError:
await self.bot.say('{}, no locations in the database match **{}**.'.format(ctx.message.author.mention, loc))
await ctx.send('{}, no locations in the database match **{}**.'.format(ctx.message.author.mention, loc))
@commands.command(pass_context=True)
@commands.cooldown(5, 60, commands.BucketType.user)
@ -133,10 +133,10 @@ class Search_Commands:
"""
try:
loc_str = self.bot.bot_commands.me(discord_uuid=ctx.message.author.id)
await self.bot.say('{}, here are your locations in the database: \n {}'.format(ctx.message.author.mention,
await ctx.send('{}, here are your locations in the database: \n {}'.format(ctx.message.author.mention,
loc_str))
except PlayerNotFound:
await self.bot.say('{}, you don\'t have any locations in the database.'.format(ctx.message.author.mention))
await ctx.send('{}, you don\'t have any locations in the database.'.format(ctx.message.author.mention))
def setup(bot):