From 08b50943bfabd68a3c5a41376cb5130771273435 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Fri, 25 May 2018 16:33:18 -0500 Subject: [PATCH] Added deletebase command --- MCInfoBot.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/MCInfoBot.py b/MCInfoBot.py index 871b16d..d1f98d7 100644 --- a/MCInfoBot.py +++ b/MCInfoBot.py @@ -160,7 +160,7 @@ async def addbase(ctx, name: str, x_pos: int, y_pos: int, z_pos: int, * args): @bot.command(pass_context=True) async def findbase(ctx, name: str): ''' - Allows you to find a base in the database. + Finds a base in the database. ?findbase [Player name] ''' @@ -176,6 +176,22 @@ async def findbase(ctx, name: str): else: await bot.say('{}, {} is not in the database'.format(ctx.message.author.mention, name)) +@bot.command(pass_context=True) +async def deletebase(ctx, name: str): + ''' + Deletes a base from the database. + ?deletebase [Base name] + ''' + + user = str(ctx.message.author.nick) + base = session.query(Location).filter_by(owner=user, name=name) + + if base is not None: + base.delete() + await bot.say('{}, your base named "{}" has been deleted.'.format(ctx.message.author.mention, name)) + else: + await bot.say('{}, you do not have a base named "{}".'.format(ctx.message.author.mention, name)) + # Bot Startup ****************************************************************** try: