2018-08-05 22:20:37 +00:00
|
|
|
from discord.ext import commands
|
2018-08-12 19:00:04 +00:00
|
|
|
|
2018-08-05 22:20:37 +00:00
|
|
|
from BotErrors import *
|
|
|
|
from DiscordHelperFunctions import *
|
2018-08-11 21:07:33 +00:00
|
|
|
from bot import bot_commands
|
2018-08-05 22:20:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Delete_Commands:
|
2018-08-11 23:02:50 +00:00
|
|
|
"""
|
2018-08-05 22:20:37 +00:00
|
|
|
Commands to help Geoffrey forget.
|
|
|
|
|
|
|
|
*You must use ?register before using any of these commands!*
|
2018-08-11 23:02:50 +00:00
|
|
|
"""
|
2018-08-05 22:20:37 +00:00
|
|
|
|
2018-08-10 02:25:55 +00:00
|
|
|
def __init__(self, bot):
|
|
|
|
self.bot = bot
|
|
|
|
|
2018-08-05 22:20:37 +00:00
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def delete(self, ctx, *args):
|
2018-08-11 23:02:50 +00:00
|
|
|
"""
|
2018-08-05 22:20:37 +00:00
|
|
|
Deletes a location from the database.
|
|
|
|
?delete [Location name]
|
2018-08-11 23:02:50 +00:00
|
|
|
"""
|
2018-08-05 22:20:37 +00:00
|
|
|
loc = get_name(args)
|
|
|
|
try:
|
|
|
|
if loc is None:
|
|
|
|
raise commands.UserInputError
|
|
|
|
|
|
|
|
bot_commands.delete(loc, discord_uuid=ctx.message.author.id)
|
|
|
|
await self.bot.say(
|
|
|
|
'{}, 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))
|
|
|
|
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def delete_item(self, ctx, item: str, *args):
|
2018-08-11 23:02:50 +00:00
|
|
|
"""
|
2018-08-05 22:20:37 +00:00
|
|
|
Deletes an item listing from a shop inventory
|
|
|
|
|
|
|
|
?delete_name [Item] [Shop Name]
|
2018-08-11 23:02:50 +00:00
|
|
|
"""
|
2018-08-05 22:20:37 +00:00
|
|
|
|
|
|
|
shop = get_name(args)
|
|
|
|
try:
|
|
|
|
bot_commands.delete_item(item, shop, discord_uuid=ctx.message.author.id)
|
|
|
|
|
|
|
|
await self.bot.say('{}, **{}** has been removed from the inventory of **{}**.'.
|
2018-08-11 23:02:50 +00:00
|
|
|
format(ctx.message.author.mention, item, shop))
|
2018-08-05 22:20:37 +00:00
|
|
|
except LocationLookUpError:
|
|
|
|
if shop is None:
|
|
|
|
await self.bot.say('{}, 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))
|
|
|
|
except EntryNameNotUniqueError:
|
|
|
|
await self.bot.say('{}, you have more than one shop in the database, please specify a shop name.'
|
2018-08-11 23:02:50 +00:00
|
|
|
.format(ctx.message.author.mention))
|
2018-08-05 22:20:37 +00:00
|
|
|
except DeleteEntryError:
|
|
|
|
if shop is not None:
|
|
|
|
await self.bot.say('{}, **{}** 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))
|
|
|
|
|
|
|
|
|
|
|
|
def setup(bot):
|
|
|
|
bot.add_cog(Delete_Commands(bot))
|