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

Code before:
    def _store(self, data: TemplatePayload) -> None:
        self.code: str = data['code']
        self.uses: int = data['usage_count']
        self.name: str = data['name']
        self.description: Optional[str] = data['description']
        creator_data = data.get('creator')
        self.creator: Optional[User] = None if creator_data is None else self._state.create_user(creator_data)

        self.created_at: Optional[datetime.datetime] = parse_time(data.get('created_at'))
        self.updated_at: Optional[datetime.datetime] = parse_time(data.get('updated_at'))

        source_serialised = data['serialized_source_guild']
        source_serialised['id'] = int(data['source_guild_id'])
        state = _PartialTemplateState(state=self._state)
        # Guild expects a ConnectionState, we're passing a _PartialTemplateState
        self.source_guild = Guild(data=source_serialised, state=state)  # type: ignore

        self.is_dirty: Optional[bool] = data.get('is_dirty', None)

    def __repr__(self) -> str:
        return (
            f'<Template code={self.code!r} uses={self.uses} name={self.name!r}'
            f' creator={self.creator!r} source_guild={self.source_guild!r} is_dirty={self.is_dirty}>'
        )

    async def create_guild(self, name: str, icon: bytes = MISSING) -> Guild:
        """|coro|

        Creates a :class:`.Guild` using the template.

        Bot accounts in more than 10 guilds are not allowed to create guilds.

        .. versionchanged:: 2.0
            The ``region`` parameter has been removed.

        .. versionchanged:: 2.0
            This function will now raise :exc:`ValueError` instead of
            ``InvalidArgument``.

        Parameters
        ----------
        name: :class:`str`
            The name of the guild.
        icon: :class:`bytes`
            The :term:`py:bytes-like object` representing the icon. See :meth:`.ClientUser.edit`
            for more details on what is expected.

        Raises
        ------
        HTTPException
            Guild creation failed.

Review comment (suggestion):
```suggestion
    @deprecated('This function is no longer supported by Discord')
```

Code after:
    def _store(self, data: TemplatePayload) -> None:
        self.code: str = data['code']
        self.uses: int = data['usage_count']
        self.name: str = data['name']
        self.description: Optional[str] = data['description']
        creator_data = data.get('creator')
        self.creator: Optional[User] = None if creator_data is None else self._state.create_user(creator_data)

        self.created_at: Optional[datetime.datetime] = parse_time(data.get('created_at'))
        self.updated_at: Optional[datetime.datetime] = parse_time(data.get('updated_at'))

        source_serialised = data['serialized_source_guild']
        source_serialised['id'] = int(data['source_guild_id'])
        state = _PartialTemplateState(state=self._state)
        # Guild expects a ConnectionState, we're passing a _PartialTemplateState
        self.source_guild = Guild(data=source_serialised, state=state)  # type: ignore

        self.is_dirty: Optional[bool] = data.get('is_dirty', None)

    def __repr__(self) -> str:
        return (
            f'<Template code={self.code!r} uses={self.uses} name={self.name!r}'
            f' creator={self.creator!r} source_guild={self.source_guild!r} is_dirty={self.is_dirty}>'
        )

    @deprecated()
    async def create_guild(self, name: str, icon: bytes = MISSING) -> Guild:
        """|coro|

        Creates a :class:`.Guild` using the template.

        Bot accounts in more than 10 guilds are not allowed to create guilds.

        .. versionchanged:: 2.0
            The ``region`` parameter has been removed.

        .. versionchanged:: 2.0
            This function will now raise :exc:`ValueError` instead of
            ``InvalidArgument``.

        .. deprecated:: 2.6
            This function is deprecated and will be removed in a future version.

        Parameters
        ----------
        name: :class:`str`
            The name of the guild.
        icon: :class:`bytes`
            The :term:`py:bytes-like object` representing the icon. See :meth:`.ClientUser.edit`
            for more details on what is expected.