register now checks if a player is in the database
parent
847e33ed6e
commit
11266bf498
|
@ -39,5 +39,7 @@ class InvalidDimError(DataBaseError):
|
||||||
class InvalidTunnelError(DataBaseError):
|
class InvalidTunnelError(DataBaseError):
|
||||||
"""Invalid tunnel name"""
|
"""Invalid tunnel name"""
|
||||||
|
|
||||||
|
class PlayerInDB(DataBaseError):
|
||||||
|
"""Player already registered in database"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,10 @@ class Commands:
|
||||||
session = self.interface.database.Session()
|
session = self.interface.database.Session()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
try:
|
||||||
|
self.interface.find_player(session, player_name)
|
||||||
|
raise PlayerInDB
|
||||||
|
except PlayerNotFound:
|
||||||
player = self.interface.add_player(session, player_name, discord_uuid)
|
player = self.interface.add_player(session, player_name, discord_uuid)
|
||||||
player_name = player.name
|
player_name = player.name
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -75,6 +75,9 @@ async def register(ctx):
|
||||||
await bot.say('{}, run this command on 24CC whoever you are'.format(ctx.message.author.mention))
|
await bot.say('{}, run this command on 24CC whoever you are'.format(ctx.message.author.mention))
|
||||||
except LocationInitError:
|
except LocationInitError:
|
||||||
raise commands.UserInputError
|
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)
|
@bot.command(pass_context=True)
|
||||||
|
|
Loading…
Reference in New Issue