# Buggy code
def _parse(track, **kwargs) -> MutableMapping:
    returning = {}
    if (
        type(track) == type(LocalPath)
        and (track.is_file() or track.is_dir())
        and track.exists()
    ):
        returning["local"] = True
        returning["name"] = track.name
        if track.is_file():
            returning["single"] = True
        elif track.is_dir():
            returning["album"] = True
    else:
        track = str(track)
        if track.startswith("spotify:"):
            returning["spotify"] = True
            if ":playlist:" in track:
                returning["playlist"] = True
            elif ":album:" in track:
                returning["album"] = True
            elif ":track:" in track:
                returning["single"] = True
            _id = track.split(":", 2)[-1]
            _id = _id.split("?")[0]
            returning["id"] = _id
            if "#" in _id:
                match = re.search(_RE_SPOTIFY_TIMESTAMP, track)
                if match:
                    returning["start_time"] = (int(match.group(1)) * 60) + int(
                        match.group(2)
                    )
            returning["uri"] = track
            return returning
        if track.startswith("sc ") or track.startswith("list "):
            if track.startswith("sc "):
                returning["invoked_from"] = "sc search"
                returning["soundcloud"] = True
            elif track.startswith("list "):
                returning["invoked_from"] = "search list"
            track = _RE_REMOVE_START.sub("", track, 1)
            returning["queryforced"] = track

        _localtrack = LocalPath(track)
        if _localtrack.exists():
            if _localtrack.is_file():
                returning["local"] = True
                returning["single"] = True
                returning["name"] = _localtrack.name
                return returning
            elif _localtrack.is_dir():
                returning["album"] = True
                returning["local"] = True
                returning["name"] = _localtrack.name
                return returning
        try:
            query_url = urlparse(track)
            if all([query_url.scheme, query_url.netloc, query_url.path]):
                returning["url"] = track
                returning["is_url"] = True
                url_domain = ".".join(query_url.netloc.split(".")[-2:])
                if not query_url.netloc:
                    url_domain = ".".join(query_url.path.split("/")[0].split(".")[-2:])
                if url_domain in ["youtube.com", "youtu.be"]:
                    returning["youtube"] = True
                    _has_index = "&index=" in track
                    if "&t=" in track:
                        match = re.search(_RE_YOUTUBE_TIMESTAMP, track)
                        if match:
                            returning["start_time"] = int(match.group(1))
                    if _has_index:
                        match = re.search(_RE_YOUTUBE_INDEX, track)
                        if match:
                            returning["track_index"] = int(match.group(1)) - 1
                    if all(k in track for k in ["&list=", "watch?"]):
                        returning["track_index"] = 0
                        returning["playlist"] = True
                        returning["single"] = False
                    elif all(x in track for x in ["playlist?"]):
                        returning["playlist"] = not _has_index
                        returning["single"] = _has_index
                    elif any(k in track for k in ["list="]):
                        returning["track_index"] = 0
                        returning["playlist"] = True
                        returning["single"] = False
                    else:
                        returning["single"] = True
                elif url_domain == "spotify.com":
                    returning["spotify"] = True
                    if "/playlist/" in track:
                        returning["playlist"] = True
                    elif "/album/" in track:
                        returning["album"] = True
                    elif "/track/" in track:
                        returning["single"] = True
                    val = re.sub(_RE_SPOTIFY_URL, "", track).replace("/", ":")
                    if "user:" in val:
                        val = val.split(":", 2)[-1]
                    _id = val.split(":", 1)[-1]
                    _id = _id.split("?")[0]

                    if "#" in _id:
                        _id = _id.split("#")[0]
                        match = re.search(_RE_SPOTIFY_TIMESTAMP, track)
                        if match:
                            returning["start_time"] = (int(match.group(1)) * 60) + int(
                                match.group(2)
                            )

                    returning["id"] = _id
                    returning["uri"] = f"spotify:{val}"
                elif url_domain == "soundcloud.com":
                    returning["soundcloud"] = True
                    if "#t=" in track:
                        match = re.search(_RE_SOUNDCLOUD_TIMESTAMP, track)
                        if match:
                            returning["start_time"] = (int(match.group(1)) * 60) + int(
                                match.group(2)
                            )
                    if "/sets/" in track:
                        if "?in=" in track:
                            returning["single"] = True
                        else:
                            returning["playlist"] = True
                    else:
                        returning["single"] = True
                elif url_domain == "bandcamp.com":
                    returning["bandcamp"] = True
                    if "/album/" in track:
                        returning["album"] = True
                    else:
                        returning["single"] = True
                elif url_domain == "vimeo.com":
                    returning["vimeo"] = True
                elif url_domain in ["mixer.com", "beam.pro"]:
                    returning["mixer"] = True
                elif url_domain == "twitch.tv":
                    returning["twitch"] = True
                    if "?t=" in track:
                        match = re.search(_RE_TWITCH_TIMESTAMP, track)
                        if match:
                            returning["start_time"] = (
                                (int(match.group(1)) * 60 * 60)
                                + (int(match.group(2)) * 60)
                                + int(match.group(3))
                            )

                    if not any(x in track for x in ["/clip/", "/videos/"]):
                        returning["stream"] = True
                else:
                    returning["other"] = True
                    returning["single"] = True
            else:
                if kwargs.get("soundcloud", False):
                    returning["soundcloud"] = True
                else:
                    returning["youtube"] = True
                returning["search"] = True
                returning["single"] = True
        except Exception:
            returning["search"] = True
            returning["youtube"] = True
            returning["single"] = True
    return returning


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/bot/botenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 83, in wrapped
ret = await coro(*args, **kwargs)
File "/home/bot/botenv/lib/python3.8/site-packages/redbot/cogs/audio/audio.py", line 4937, in _playlist_list
playlists = await get_all_playlist(scope, self.bot, guild, author, specified_user)
File "/home/bot/botenv/lib/python3.8/site-packages/redbot/cogs/audio/playlists.py", line 475, in get_all_playlist
scope_standard, scope_id = _prepare_config_scope(scope, author, guild)
File "/home/bot/botenv/lib/python3.8/site-packages/redbot/cogs/audio/playlists.py", line 86, in _prepare_config_scope
scope = standardize_scope(scope)
File "/home/bot/botenv/lib/python3.8/site-packages/redbot/cogs/audio/playlists.py", line 62, in standardize_scope
scope = scope.upper()
AttributeError: 'NoneType' object has no attribute 'upper'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/bot/botenv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "/home/bot/botenv/lib/python3.8/site-packages/redbot/core/commands/commands.py", line 799, in invoke
await super().invoke(ctx)
File "/home/bot/botenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1234, in invoke
await ctx.invoked_subcommand.invoke(ctx)
File "/home/bot/botenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 797, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/bot/botenv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 92, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'upper'

# Fixed code
def _parse(track, _local_folder_current_path: Path, **kwargs) -> MutableMapping:
    """Parse a track into all the relevant metadata"""
    returning: MutableMapping = {}
    if (
        type(track) == type(LocalPath)
        and (track.is_file() or track.is_dir())
        and track.exists()
    ):
        returning["local"] = True
        returning["name"] = track.name
        if track.is_file():
            returning["single"] = True
        elif track.is_dir():
            returning["album"] = True
    else:
        track = str(track)
        if track.startswith("spotify:"):
            returning["spotify"] = True
            if ":playlist:" in track:
                returning["playlist"] = True
            elif ":album:" in track:
                returning["album"] = True
            elif ":track:" in track:
                returning["single"] = True
            _id = track.split(":", 2)[-1]
            _id = _id.split("?")[0]
            returning["id"] = _id
            if "#" in _id:
                match = re.search(_RE_SPOTIFY_TIMESTAMP, track)
                if match:
                    returning["start_time"] = (int(match.group(1)) * 60) + int(
                        match.group(2)
                    )
            returning["uri"] = track
            return returning
        if track.startswith("sc ") or track.startswith("list "):
            if track.startswith("sc "):
                returning["invoked_from"] = "sc search"
                returning["soundcloud"] = True
            elif track.startswith("list "):
                returning["invoked_from"] = "search list"
            track = _RE_REMOVE_START.sub("", track, 1)
            returning["queryforced"] = track

        _localtrack = LocalPath(track, _local_folder_current_path)
        if _localtrack.exists():
            if _localtrack.is_file():
                returning["local"] = True
                returning["single"] = True
                returning["name"] = _localtrack.name
                return returning
            elif _localtrack.is_dir():
                returning["album"] = True
                returning["local"] = True
                returning["name"] = _localtrack.name
                return returning
        try:
            query_url = urlparse(track)
            if all([query_url.scheme, query_url.netloc, query_url.path]):
                returning["url"] = track
                returning["is_url"] = True
                url_domain = ".".join(query_url.netloc.split(".")[-2:])
                if not query_url.netloc:
                    url_domain = ".".join(query_url.path.split("/")[0].split(".")[-2:])
                if url_domain in ["youtube.com", "youtu.be"]:
                    returning["youtube"] = True
                    _has_index = "&index=" in track
                    if "&t=" in track or "?t=" in track:
                        match = re.search(_RE_YOUTUBE_TIMESTAMP, track)
                        if match:
                            returning["start_time"] = int(match.group(1))
                    if _has_index:
                        match = re.search(_RE_YOUTUBE_INDEX, track)
                        if match:
                            returning["track_index"] = int(match.group(1)) - 1
                    if all(k in track for k in ["&list=", "watch?"]):
                        returning["track_index"] = 0
                        returning["playlist"] = True
                        returning["single"] = False
                    elif all(x in track for x in ["playlist?"]):
                        returning["playlist"] = not _has_index
                        returning["single"] = _has_index
                    elif any(k in track for k in ["list="]):
                        returning["track_index"] = 0
                        returning["playlist"] = True
                        returning["single"] = False
                    else:
                        returning["single"] = True
                elif url_domain == "spotify.com":
                    returning["spotify"] = True
                    if "/playlist/" in track:
                        returning["playlist"] = True
                    elif "/album/" in track:
                        returning["album"] = True
                    elif "/track/" in track:
                        returning["single"] = True
                    val = re.sub(_RE_SPOTIFY_URL, "", track).replace("/", ":")
                    if "user:" in val:
                        val = val.split(":", 2)[-1]
                    _id = val.split(":", 1)[-1]
                    _id = _id.split("?")[0]

                    if "#" in _id:
                        _id = _id.split("#")[0]
                        match = re.search(_RE_SPOTIFY_TIMESTAMP, track)
                        if match:
                            returning["start_time"] = (int(match.group(1)) * 60) + int(
                                match.group(2)
                            )

                    returning["id"] = _id
                    returning["uri"] = f"spotify:{val}"
                elif url_domain == "soundcloud.com":
                    returning["soundcloud"] = True
                    if "#t=" in track:
                        match = re.search(_RE_SOUNDCLOUD_TIMESTAMP, track)
                        if match:
                            returning["start_time"] = (int(match.group(1)) * 60) + int(
                                match.group(2)
                            )
                    if "/sets/" in track:
                        if "?in=" in track:
                            returning["single"] = True
                        else:
                            returning["playlist"] = True
                    else:
                        returning["single"] = True
                elif url_domain == "bandcamp.com":
                    returning["bandcamp"] = True
                    if "/album/" in track:
                        returning["album"] = True
                    else:
                        returning["single"] = True
                elif url_domain == "vimeo.com":
                    returning["vimeo"] = True
                elif url_domain in ["mixer.com", "beam.pro"]:
                    returning["mixer"] = True
                elif url_domain == "twitch.tv":
                    returning["twitch"] = True
                    if "?t=" in track:
                        match = re.search(_RE_TWITCH_TIMESTAMP, track)
                        if match:
                            returning["start_time"] = (
                                (int(match.group(1)) * 60 * 60)
                                + (int(match.group(2)) * 60)
                                + int(match.group(3))
                            )

                    if not any(x in track for x in ["/clip/", "/videos/"]):
                        returning["stream"] = True
                else:
                    returning["other"] = True
                    returning["single"] = True
            else:
                if kwargs.get("soundcloud", False):
                    returning["soundcloud"] = True
                else:
                    returning["youtube"] = True
                returning["search"] = True
                returning["single"] = True
        except Exception:
            returning["search"] = True
            returning["youtube"] = True
            returning["single"] = True
    return returning