# Buggy code
async def _load_v3_playlist(
    self,
    ctx: commands.Context,
    scope: str,
    uploaded_playlist_name: str,
    uploaded_playlist_url: str,
    track_list,
    author: Union[discord.User, discord.Member],
    guild: Union[discord.Guild],
):
    embed1 = discord.Embed(
        colour=await ctx.embed_colour(), title=_("Please wait, adding tracks...")
    )
    playlist_msg = await ctx.send(embed=embed1)
    track_count = len(track_list)
    uploaded_track_count = len(track_list)
    await asyncio.sleep(1)
    embed2 = discord.Embed(
        colour=await ctx.embed_colour(),
        title=_("Loading track {num}/{total}...").format(
            num=track_count, total=uploaded_track_count
        ),
    )
    await playlist_msg.edit(embed=embed2)
    playlist = await create_playlist(
        ctx,
        scope,
        uploaded_playlist_name,
        uploaded_playlist_url,
        track_list,
        author,
        guild,
    )
    scope_name = humanize_scope(
        scope, ctx=guild if scope == PlaylistScope.GUILD.value else author
    )
    if not track_count:
        msg = _("Empty playlist {name} (`{id}`) [**{scope}**] created.").format(
            name=playlist.name, id=playlist.id, scope=scope_name
        )
    elif uploaded_track_count != track_count:
        bad_tracks = uploaded_track_count - track_count
        msg = _(
            "Added {num} tracks from the {playlist_name} playlist. {num_bad} track(s) "
            "could not be loaded."
        ).format(num=track_count, playlist_name=playlist.name, num_bad=bad_tracks)
    else:
        msg = _("Added {num} tracks from the {playlist_name} playlist.").format(
            num=track_count, playlist_name=playlist.name
        )
    embed3 = discord.Embed(
        colour=await ctx.embed_colour(), title=_("Playlist Saved"), description=msg
    )
    await playlist_msg.edit(embed=embed3)
    database_entries = []
    time_now = str(datetime.datetime.now(datetime.timezone.utc))
    for t in track_list:
        uri = t.get("info", {}).get("uri")
        if uri:
            t = {"loadType": "V2_COMPAT", "tracks": [t], "query": uri}
            database_entries.append(
                {
                    "query": uri,
                    "data": json.dumps(t),
                    "last_updated": time_now,
                    "last_fetched": time_now,
                }
            )
    if database_entries and HAS_SQL:
        await self.music_cache.insert("lavalink", database_entries)


# Traceback (RuntimeError)
Traceback (most recent call last):
File "/home/martinebots/martinebotsvenv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 79, in wrapped
ret = await coro(*args, **kwargs)
File "/home/martinebots/martinebotscogs/cogs_modified/audio/audio.py", line 3183, in play
await self._enqueue_tracks(ctx, query)
File "/home/martinebots/martinebotscogs/cogs_modified/audio/audio.py", line 3885, in _enqueue_tracks
result, called_api = await self.music_cache.lavalink_query(ctx, player, query)
File "/home/martinebots/martinebotscogs/cogs_modified/audio/apis.py", line 911, in lavalink_query
results = await player.load_tracks(query)
File "/home/martinebots/martinebotsvenv/lib/python3.7/site-packages/lavalink/rest_api.py", line 300, in load_tracks
self.__check_node_ready()
File "/home/martinebots/martinebotsvenv/lib/python3.7/site-packages/lavalink/rest_api.py", line 268, in __check_node_ready
raise RuntimeError("Cannot execute REST request when node not ready.")
RuntimeError: Cannot execute REST request when node not ready.

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

Traceback (most recent call last):
File "/home/martinebots/martinebotsvenv/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 863, in invoke
await ctx.command.invoke(ctx)
File "/home/martinebots/martinebotsvenv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 728, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/martinebots/martinebotsvenv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 88, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: Cannot execute REST request when node not ready.```

# Fixed code
async def _load_v3_playlist(
    self,
    ctx: commands.Context,
    scope: str,
    uploaded_playlist_name: str,
    uploaded_playlist_url: str,
    track_list,
    author: Union[discord.User, discord.Member],
    guild: Union[discord.Guild],
):
    embed1 = discord.Embed(title=_("Please wait, adding tracks..."))
    playlist_msg = await self._embed_msg(ctx, embed=embed1)
    track_count = len(track_list)
    uploaded_track_count = len(track_list)
    await asyncio.sleep(1)
    embed2 = discord.Embed(
        colour=await ctx.embed_colour(),
        title=_("Loading track {num}/{total}...").format(
            num=track_count, total=uploaded_track_count
        ),
    )
    await playlist_msg.edit(embed=embed2)
    playlist = await create_playlist(
        ctx,
        scope,
        uploaded_playlist_name,
        uploaded_playlist_url,
        track_list,
        author,
        guild,
    )
    scope_name = humanize_scope(
        scope, ctx=guild if scope == PlaylistScope.GUILD.value else author
    )
    if not track_count:
        msg = _("Empty playlist {name} (`{id}`) [**{scope}**] created.").format(
            name=playlist.name, id=playlist.id, scope=scope_name
        )
    elif uploaded_track_count != track_count:
        bad_tracks = uploaded_track_count - track_count
        msg = _(
            "Added {num} tracks from the {playlist_name} playlist. {num_bad} track(s) "
            "could not be loaded."
        ).format(num=track_count, playlist_name=playlist.name, num_bad=bad_tracks)
    else:
        msg = _("Added {num} tracks from the {playlist_name} playlist.").format(
            num=track_count, playlist_name=playlist.name
        )
    embed3 = discord.Embed(
        colour=await ctx.embed_colour(), title=_("Playlist Saved"), description=msg
    )
    await playlist_msg.edit(embed=embed3)
    database_entries = []
    time_now = int(datetime.datetime.now(datetime.timezone.utc).timestamp())
    for t in track_list:
        uri = t.get("info", {}).get("uri")
        if uri:
            t = {"loadType": "V2_COMPACT", "tracks": [t], "query": uri}
            database_entries.append(
                {
                    "query": uri,
                    "data": json.dumps(t),
                    "last_updated": time_now,
                    "last_fetched": time_now,
                }
            )
    if database_entries:
        await self.music_cache.database.insert("lavalink", database_entries)