diff --git a/api/commands.py b/api/commands.py index bc01eb5..edd5b59 100644 --- a/api/commands.py +++ b/api/commands.py @@ -84,13 +84,12 @@ def get_location(owner, name=None, loc_type=Location): def add_location(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None, loc_type=Location): player = get_player(discord_uuid, mc_uuid) - try: - get_location(player, name, loc_type=loc_type) - raise EntryNameNotUniqueError - except (Location.DoesNotExist, NoLocationsInDatabase, LocationLookUpError): - if name is None: - name = "{}'s {}".format(player.name, loc_type.__name__) + if name is None: + name = "{}'s {}".format(player.name, loc_type.__name__) + if Location.objects.filter(name__iexact=name).all().count() > 0: + raise EntryNameNotUniqueError + else: location = loc_type.objects.create(name=name, x_coord=x_pos, z_coord=z_pos) location.owner.add(player) location.save()