# Buggy code
def parse_guild_member_update(self, data):
    guild = self._get_guild(int(data["guild_id"]))
    user = data["user"]
    user_id = int(user["id"])
    if guild is None:
        log.debug(
            "GUILD_MEMBER_UPDATE referencing an unknown guild ID: %s. Discarding.",
            data["guild_id"],
        )
        return

    member = guild.get_member(user_id)
    if member is not None:
        old_member = Member._copy(member)
        member._update(data)
        user_update = member._update_inner_user(user)
        if user_update:
            self.dispatch("user_update", user_update[0], user_update[1])

        self.dispatch("member_update", old_member, member)
    else:
        if self._member_cache_flags.joined:
            member = Member(data=data, guild=guild, state=self)
            guild._add_member(member)
        log.debug(
            "GUILD_MEMBER_UPDATE referencing an unknown member ID: %s. Discarding.",
            user_id,
        )


# 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_guild_member_update(self, data):
    guild = self._get_guild(int(data["guild_id"]))
    user = data["user"]
    user_id = int(user["id"])
    if guild is None:
        log.debug(
            "GUILD_MEMBER_UPDATE referencing an unknown guild ID: %s. Discarding.",
            data["guild_id"],
        )
        return

    member = guild.get_member(user_id)
    if member is not None:
        old_member = Member._copy(member)
        member._update(data)
        user_update = member._update_inner_user(user)
        if user_update:
            self.dispatch("user_update", user_update[0], user_update[1])

        self.dispatch("member_update", old_member, member)
    else:
        if self.member_cache_flags.joined:
            member = Member(data=data, guild=guild, state=self)
            guild._add_member(member)
        log.debug(
            "GUILD_MEMBER_UPDATE referencing an unknown member ID: %s. Discarding.",
            user_id,
        )