diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 1c1891447c..70c13daeb8 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -72,11 +72,17 @@ def player_data(self): @property def stardust(self): - return filter(lambda y: y['name'] == 'STARDUST', self._player['currencies'])[0]['amount'] + dust = filter(lambda y: y['name'] == 'STARDUST', self._player['currencies'])[0] + if 'amount' in dust: + return dust['amount'] + else: + return 0 @stardust.setter def stardust(self, value): - filter(lambda y: y['name'] == 'STARDUST', self._player['currencies'])[0]['amount'] = value + dust = filter(lambda y: y['name'] == 'STARDUST', self._player['currencies'])[0] + if 'amount' in dust: + dust['amount'] = value def __init__(self, db, config):