Repository: Rapptz/discord.py
File: discord/message.py (Python)

Code before:
    name: :class:`str`
        The application's name.

    .. versionadded:: 2.0

    """

    __slots__ = (
        '_state',
        '_icon',
        '_cover_image',
        'id',
        'description',
        'name',
    )

    def __init__(self, *, state: ConnectionState, data: MessageApplicationPayload) -> None:
        self._state: ConnectionState = state
        self.id: int = int(data['id'])
        self.description: str = data['description']
        self.name: str = data['name']
        self._icon: Optional[str] = data['icon']
        self._cover_image: Optional[str] = data.get('cover_image')

    def __repr__(self) -> str:
        return f"<MessageApplication id={self.id} name={self.name!r}>"

    @property
    def icon(self) -> Optional[Asset]:
        """Optional[:class:`Asset`]: The application's icon, if any."""
        if self._icon:
            return Asset._from_app_icon(state=self._state, object_id=self.id, icon_hash=self._icon, asset_type='icon')

    @property
    def cover(self) -> Optional[Asset]:
        """Optional[:class:`Asset`]: The application's cover image, if any."""
        if self._cover_image:
            return Asset._from_app_icon(
                state=self._state, object_id=self.id, icon_hash=self._cover_image, asset_type='cover_image'
            )


class PartialMessage(Hashable):
    """Represents a partial message to aid with working messages when only
    a message and channel ID are present.

    There are two ways to construct this class. The first one is through
    the constructor itself, and the second is via the following:

    - :meth:`TextChannel.get_partial_message`
    - :meth:`VoiceChannel.get_partial_message`

Review comment (suggestion):
```suggestion
        return f'<MessageApplication id={self.id} name={self.name!r}>'
```

Code after:
    description: :class:`str`
        The application description.
    name: :class:`str`
        The application's name.
    """

    __slots__ = ('_state', '_icon', '_cover_image', 'id', 'description', 'name')

    def __init__(self, *, state: ConnectionState, data: MessageApplicationPayload) -> None:
        self._state: ConnectionState = state
        self.id: int = int(data['id'])
        self.description: str = data['description']
        self.name: str = data['name']
        self._icon: Optional[str] = data['icon']
        self._cover_image: Optional[str] = data.get('cover_image')

    def __repr__(self) -> str:
        return f'<MessageApplication id={self.id} name={self.name!r}>'

    @property
    def icon(self) -> Optional[Asset]:
        """Optional[:class:`Asset`]: The application's icon, if any."""
        if self._icon:
            return Asset._from_app_icon(state=self._state, object_id=self.id, icon_hash=self._icon, asset_type='icon')
        return None

    @property
    def cover(self) -> Optional[Asset]:
        """Optional[:class:`Asset`]: The application's cover image, if any."""
        if self._cover_image:
            return Asset._from_app_icon(
                state=self._state, object_id=self.id, icon_hash=self._cover_image, asset_type='cover_image'
            )
        return None


class PartialMessage(Hashable):
    """Represents a partial message to aid with working messages when only
    a message and channel ID are present.

    There are two ways to construct this class. The first one is through
    the constructor itself, and the second is via the following:

    - :meth:`TextChannel.get_partial_message`
    - :meth:`VoiceChannel.get_partial_message`
    - :meth:`Thread.get_partial_message`
    - :meth:`DMChannel.get_partial_message`

    Note that this class is trimmed down and has no rich attributes.

    .. versionadded:: 1.6