From 410107f657dd62a9796a15d97fe5c37b78ca4e6e Mon Sep 17 00:00:00 2001 From: David Westerink Date: Fri, 20 Jan 2017 11:55:32 +0100 Subject: [PATCH] Fixes #5883 This fixes an issue when you have a brand new account (no stardust yet) and run the bot. This makes sure the key is there before we do something with it. --- pokemongo_bot/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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):