register now checks if a player is in the database

doc_update
Joey Hines 2018-07-22 20:37:06 -05:00
parent 847e33ed6e
commit 11266bf498
3 changed files with 11 additions and 2 deletions

View File

@ -39,5 +39,7 @@ class InvalidDimError(DataBaseError):
class InvalidTunnelError(DataBaseError):
"""Invalid tunnel name"""
class PlayerInDB(DataBaseError):
"""Player already registered in database"""

View File

@ -21,8 +21,12 @@ class Commands:
session = self.interface.database.Session()
try:
player = self.interface.add_player(session, player_name, discord_uuid)
player_name = player.name
try:
self.interface.find_player(session, player_name)
raise PlayerInDB
except PlayerNotFound:
player = self.interface.add_player(session, player_name, discord_uuid)
player_name = player.name
finally:
session.close()

View File

@ -75,6 +75,9 @@ async def register(ctx):
await bot.say('{}, run this command on 24CC whoever you are'.format(ctx.message.author.mention))
except LocationInitError:
raise commands.UserInputError
except PlayerInDB:
await bot.say('{}, you are already in the database. Ding dong.'.format(ctx.message.author.mention))
@bot.command(pass_context=True)