Skip to content

Commit

Permalink
Add remove non-merged activity message on update
Browse files Browse the repository at this point in the history
  • Loading branch information
0x16c3 committed Oct 22, 2021
1 parent 51b7a9b commit 70c0a32
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions cogs/api/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ async def send_embed(

if channel:
try:
if activity and merged:
if activity:
for idx, feed in enumerate(activity.feed.entries_processed):
feed: "CListActivity"

Expand All @@ -571,20 +571,26 @@ async def send_embed(
):
continue
else:
try:
await feed.sent_message.delete()
except Exception as e:
logger.info(
f"Cannot remove message -> {str(channel.id)} : {item.username} {e}"
)
if not merged:
pass
else:
try:
await feed.sent_message.delete()
except Exception as e:
logger.info(
f"Cannot remove message -> {str(channel.id)} : {item.username}\n{e}"
)

item.sent_message = await channel.send(embed=embed)
activity.feed.entries[item_idx] = item

return "List[CListActivity]", activity.feed.entries, item

else:
await channel.send(embed=embed)
item.sent_message = await channel.send(embed=embed)
activity.feed.entries[item_idx] = item

return "List[CListActivity]", activity.feed.entries, item

except Exception as e:
logger.debug(
Expand Down

0 comments on commit 70c0a32

Please sign in to comment.