# Buggy code
def parse_voice_state_update(self, data):
    guild = self._get_guild(utils._get_as_snowflake(data, "guild_id"))
    channel_id = utils._get_as_snowflake(data, "channel_id")
    flags = self._member_cache_flags
    self_id = self.user.id
    if guild is not None:
        if int(data["user_id"]) == self_id:
            voice = self._get_voice_client(guild.id)
            if voice is not None:
                coro = voice.on_voice_state_update(data)
                asyncio.ensure_future(
                    logging_coroutine(
                        coro, info="Voice Protocol voice state update handler"
                    )
                )

        member, before, after = guild._update_voice_state(data, channel_id)
        if member is not None:
            if flags.voice:
                if channel_id is None and flags._voice_only and member.id != self_id:
                    # Only remove from cache iff we only have the voice flag enabled
                    guild._remove_member(member)
                elif channel_id is not None:
                    guild._add_member(member)

            self.dispatch("voice_state_update", member, before, after)
        else:
            log.debug(
                "VOICE_STATE_UPDATE referencing an unknown member ID: %s. Discarding.",
                data["user_id"],
            )
    else:
        # in here we're either at private or group calls
        call = self._calls.get(channel_id)
        if call is not None:
            call._update_voice_state(data)


# Traceback (AttributeError)
Ignoring exception in command guild:
Traceback (most recent call last):
File "\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\\Desktop\Coding\Python\Lost... Bot\Cogs\staff.py", line 36, in guild
temp = await self.bot.fetch_template(code)
File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 1144, in fetch_template
return Template(data=data, state=self._connection)
File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\template.py", line 120, in __init__
self.source_guild = Guild(data=source_serialised, state=state)
File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\guild.py", line 190, in __init__
self._from_data(data)
File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\guild.py", line 308, in _from_data
cache_online_members = self._state._member_cache_flags.online
File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\template.py", line 75, in __getattr__
raise AttributeError('PartialTemplateState does not support {0!r}.'.format(attr))
AttributeError: PartialTemplateState does not support '_member_cache_flags'.

# Fixed code
def parse_voice_state_update(self, data):
    guild = self._get_guild(utils._get_as_snowflake(data, "guild_id"))
    channel_id = utils._get_as_snowflake(data, "channel_id")
    flags = self.member_cache_flags
    self_id = self.user.id
    if guild is not None:
        if int(data["user_id"]) == self_id:
            voice = self._get_voice_client(guild.id)
            if voice is not None:
                coro = voice.on_voice_state_update(data)
                asyncio.ensure_future(
                    logging_coroutine(
                        coro, info="Voice Protocol voice state update handler"
                    )
                )

        member, before, after = guild._update_voice_state(data, channel_id)
        if member is not None:
            if flags.voice:
                if channel_id is None and flags._voice_only and member.id != self_id:
                    # Only remove from cache iff we only have the voice flag enabled
                    guild._remove_member(member)
                elif channel_id is not None:
                    guild._add_member(member)

            self.dispatch("voice_state_update", member, before, after)
        else:
            log.debug(
                "VOICE_STATE_UPDATE referencing an unknown member ID: %s. Discarding.",
                data["user_id"],
            )
    else:
        # in here we're either at private or group calls
        call = self._calls.get(channel_id)
        if call is not None:
            call._update_voice_state(data)