diff --git a/bot/urban.py b/bot/urban.py index 261b7e2..9391343 100644 --- a/bot/urban.py +++ b/bot/urban.py @@ -17,7 +17,7 @@ class Urban(Plugin): %%ud ... """ # Clean, strip and split term by whitespace - term = ' '.join(args.get('')).lower().strip().split() + term = ' '.join(args.get('')).lower().strip() if term[-1].isdigit(): # Parse number at end as index - 1 and slice term @@ -30,6 +30,9 @@ class Urban(Plugin): # Fetch data for term from urban dictionary as json data = requests.get(self.URL, params=dict(term=term)).json() + if data.get("list") is None: + return "API Error" + res_length = len(data['list']) # No results