Fix error with no attribute 'retweeted_status'

This commit is contained in:
Zeva Rose 2021-11-01 17:04:14 -06:00
parent 8b568d3daa
commit 8048622707

View file

@ -57,11 +57,12 @@ class TwitterCog(commands.Cog):
self._channel_cache[twitter.channel] = find(lambda x: x.id == twitter.channel, channels)
channel = self._channel_cache[twitter.channel]
for tweet in tweets:
if tweet.retweeted_status and not twitter.retweets:
retweet = "retweeted_status" in tweet.__dict__
if retweet and not twitter.retweets:
continue
timestamp = int(tweet.created_at.timestamp())
url = f"https://twitter.com/{twitter.handle}/status/{tweet.id}"
verb = "re" if tweet.retweeted_status else ""
verb = "re" if retweet else ""
await channel.send(f"`@{twitter.handle}` {verb}tweeted this at <t:{timestamp}:f>: {url}")
newest = max(tweets, key=lambda x: x.id)
twitter.last_tweet = newest.id