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

Code before:
        '_state',
        '_icon',
        '_splash',
        '_discovery_splash',
        'id',
        'name',
        'emojis',
        'stickers',
        'features',
        'description',
        "approximate_member_count",
        "approximate_presence_count",
    )

    def __init__(self, *, data: GuildPreviewPayload, state: ConnectionState) -> None:
        self._state: ConnectionState = state
        self.id = int(data['id'])
        self.name: str = data['name']
        self._icon: Optional[str] = data.get('icon')
        self._splash: Optional[str] = data.get('splash')
        self._discovery_splash: Optional[str] = data.get('discovery_splash')
        self.emojis: Tuple[Emoji, ...] = (
            tuple(map(lambda d: state.store_emoji(self, d), data.get('emojis', [])))
            if state.cache_guild_expressions
            else ()
        )
        self.stickers: Tuple[GuildSticker, ...] = (
            tuple(map(lambda d: state.store_sticker(self, d), data.get('stickers', [])))
            if state.cache_guild_expressions
            else ()
        )
        self.features: List[GuildFeature] = data.get('features', [])
        self.description: Optional[str] = data.get('description')
        self.approximate_member_count: int = data.get('approximate_member_count')
        self.approximate_presence_count: int = data.get('approximate_presence_count')

    def __str__(self) -> str:
        return self.name

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

    @property
    def created_at(self) -> datetime.datetime:
        """:class:`datetime.datetime`: Returns the guild's creation time in UTC."""
        return utils.snowflake_time(self.id)

    @property

Review comment (bug):
This fails type checking: `GuildPreview != Guild`. Please mock guild object (`state._get_or_create_unavailable_guild(self.id)` does this).

Additionally, the internal cache must not populated with this data. Consider constructing `Emoji` object directly.
```suggestion
        self.emojis: Tuple[Emoji, ...] = tuple(map(lambda d: Emoji(guild=state._get_or_create_unavailable_guild(self.id), state=state, data=d), data.get('emojis', [])))
```
Do not respect `state.cache_guild_expressions` here.

Code after:
    """

    __slots__ = (
        '_state',
        '_icon',
        '_splash',
        '_discovery_splash',
        'id',
        'name',
        'emojis',
        'stickers',
        'features',
        'description',
        "approximate_member_count",
        "approximate_presence_count",
    )

    def __init__(self, *, data: GuildPreviewPayload, state: ConnectionState) -> None:
        self._state: ConnectionState = state
        self.id = int(data['id'])
        self.name: str = data['name']
        self._icon: Optional[str] = data.get('icon')
        self._splash: Optional[str] = data.get('splash')
        self._discovery_splash: Optional[str] = data.get('discovery_splash')
        self.emojis: Tuple[Emoji, ...] = tuple(
            map(
                lambda d: Emoji(guild=state._get_or_create_unavailable_guild(self.id), state=state, data=d),
                data.get('emojis', []),
            )
        )
        self.stickers: Tuple[GuildSticker, ...] = tuple(
            map(lambda d: GuildSticker(state=state, data=d), data.get('stickers', []))
        )
        self.features: List[GuildFeature] = data.get('features', [])
        self.description: Optional[str] = data.get('description')
        self.approximate_member_count: int = data.get('approximate_member_count')
        self.approximate_presence_count: int = data.get('approximate_presence_count')

    def __str__(self) -> str:
        return self.name

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

    @property
    def created_at(self) -> datetime.datetime:
        """:class:`datetime.datetime`: Returns the guild's creation time in UTC."""
        return utils.snowflake_time(self.id)