Added support to re-register to add a discord uuid

+ With plugin support, users can be created without discord uuids
+ When a player wants to use geoffrey in discord, they just need to register in discord
doc_update
Joey Hines 2019-12-21 15:52:57 -05:00
parent 9104ae9bd0
commit c6fadd4a00
1 changed files with 8 additions and 2 deletions

View File

@ -151,8 +151,14 @@ def register(player_name, discord_uuid):
mc_uuid = grab_UUID(player_name) mc_uuid = grab_UUID(player_name)
try: try:
get_player(mc_uuid=mc_uuid) player = get_player(mc_uuid=mc_uuid)
raise PlayerInDBError
if len(discord_uuid) != 0 and len(player.discord_uuid) == 0:
player.discord_uuid = discord_uuid
player.save()
return player
else:
raise PlayerInDBError
except PlayerNotFound: except PlayerNotFound:
player = Player.objects.create(name=player_name, mc_uuid=mc_uuid, discord_uuid=discord_uuid) player = Player.objects.create(name=player_name, mc_uuid=mc_uuid, discord_uuid=discord_uuid)
player.save() player.save()