async def on_message_edit(before: Message, after: Message): # Only care about messages that are in public channels if isinstance(before.channel, GuildChannel): # Message wasn't pinned if before.pinned == after.pinned: # Log any edits to messages original_message = db_session.query(LoggedMessage).filter(LoggedMessage.message_uid == before.id).first() if original_message: message_diff = MessageDiff(original_message=original_message.id, new_content=after.clean_content, created_at=(after.edited_at or datetime.utcnow())) db_session.add(message_diff) db_session.commit()
async def on_message_edit(self, before: Message, after: Message): # Only care about messages that are in public channels if isinstance(before.channel, GuildChannel): # Message wasn't pinned if before.pinned == after.pinned: # Log any edits to messages original_message = (db_session.query(LoggedMessage).filter( LoggedMessage.message_uid == before.id).first()) if original_message: message_diff = MessageDiff( original_message=original_message.id, new_content=after.clean_content, created_at=(after.edited_at or datetime.utcnow()), ) db_session.add(message_diff) try: db_session.commit() except (ScalarListException, SQLAlchemyError): db_session.rollback()