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

Code before:
        features = set(self.features)

        if community is not MISSING:
            if community:
                if 'rules_channel_id' in fields and 'public_updates_channel_id' in fields:
                    features.add('COMMUNITY')
                else:
                    raise ValueError(
                        'community field requires both rules_channel and public_updates_channel fields to be provided'
                    )
            else:
                features.discard('COMMUNITY')

        if discoverable is not MISSING:
            if discoverable:
                features.add('DISCOVERABLE')
            else:
                features.discard('DISCOVERABLE')

        if invites_disabled is not MISSING:
            if invites_disabled:
                features.add('INVITES_DISABLED')
            else:
                features.discard('INVITES_DISABLED')

        fields['features'] = list(features)

        if premium_progress_bar_enabled is not MISSING:
            fields['premium_progress_bar_enabled'] = premium_progress_bar_enabled

        data = await http.edit_guild(self.id, reason=reason, **fields)
        return Guild(data=data, state=self._state)

    async def fetch_channels(self) -> Sequence[GuildChannel]:
        """|coro|

        Retrieves all :class:`abc.GuildChannel` that the guild has.

        .. note::

            This method is an API call. For general usage, consider :attr:`channels` instead.

        .. versionadded:: 1.2

        Raises
        -------
        InvalidData
            An unknown channel type was received from Discord.
        HTTPException
            Retrieving the channels failed.


Review comment (suggestion):
Might be better to only pay for the cost of this cast if the features are set. As it stands right now everyone pays for both casts to `set` and back to `list`.

Code after:
        if any(feat is not MISSING for feat in (community, discoverable, invites_disabled)):

            features = set(self.features)

            if community is not MISSING:
                if community:
                    if 'rules_channel_id' in fields and 'public_updates_channel_id' in fields:
                        features.add('COMMUNITY')
                    else:
                        raise ValueError(
                            'community field requires both rules_channel and public_updates_channel fields to be provided'
                        )
                else:
                    features.discard('COMMUNITY')

            if discoverable is not MISSING:
                if discoverable:
                    features.add('DISCOVERABLE')
                else:
                    features.discard('DISCOVERABLE')

            if invites_disabled is not MISSING:
                if invites_disabled:
                    features.add('INVITES_DISABLED')
                else:
                    features.discard('INVITES_DISABLED')

            fields['features'] = list(features)

        if premium_progress_bar_enabled is not MISSING:
            fields['premium_progress_bar_enabled'] = premium_progress_bar_enabled

        data = await http.edit_guild(self.id, reason=reason, **fields)
        return Guild(data=data, state=self._state)

    async def fetch_channels(self) -> Sequence[GuildChannel]:
        """|coro|

        Retrieves all :class:`abc.GuildChannel` that the guild has.

        .. note::

            This method is an API call. For general usage, consider :attr:`channels` instead.

        .. versionadded:: 1.2

        Raises
        -------
        InvalidData
            An unknown channel type was received from Discord.
        HTTPException