Try/catch wrap on timeline fetching

This commit is contained in:
GlitterButts 2021-11-11 23:23:51 +00:00
parent d8f035096d
commit b0ba4d3349

View file

@ -43,7 +43,10 @@ class TwitterCog(commands.Cog):
handles = Twitter.objects.distinct("handle")
twitter_data = {}
for handle in handles:
twitter_data[handle] = self.api.user_timeline(screen_name=handle)
try:
twitter_data[handle] = self.api.user_timeline(screen_name=handle)
except Exception as e:
logger.error(f"Error with fetching: {e}")
for twitter in twitters:
try:
tweets = list(filter(lambda x: x.id > twitter.last_tweet, twitter_data[twitter.handle]))