def from_user_chat_message()

in bot/gemini_model.py [0:0]


    def from_user_chat_message(cls, message: hikari.Message) -> list["ChatPart"]:
        """
        Create a user ChatPart object from hikari.Message.

        Stores the text content of the message as JSON encoded object and assigns the `role` as "user".
        This method also calculates and saves the token count.
        """
        author = getattr(message.member, "display_name", False)
        msg = json.dumps(
            {
                "author": author
                or message.author.username,
                "content": message.content,
            }
        )
        text_part = Part.from_text(text=msg)
        parts = [(text_part, cls._count_tokens(text_part))]

        for e in message.embeds:
            for embed_part in cls._parse_embed(author, e):
                parts.append((embed_part, cls._count_tokens(embed_part)))

        for a in message.attachments:
            if a.media_type not in ACCEPTED_MIMES:
                part = Part.from_text(
                    text=f"Here user uploaded a file in unsupported {a.media_type} type."
                )
            else:
                data = discord_cache.get_from_cache(a.url)
                part = Part.from_bytes(data=data, mime_type=a.media_type)
            parts.append((part, cls._count_tokens(part)))

        return [cls(part, "user", tokens) for part, tokens in parts]