# Buggy code
async def spotify_query(
    self,
    ctx: commands.Context,
    query_type: str,
    uri: str,
    skip_youtube: bool = False,
    notifier: Optional[Notifier] = None,
) -> List[str]:
    """
    Queries the Database then falls back to Spotify and YouTube APIs.

    Parameters
    ----------
    ctx: commands.Context
        The context this method is being called under.
    query_type : str
        Type of query to perform (Pl
    uri: str
        Spotify URL ID .
    skip_youtube:bool
        Whether or not to skip YouTube API Calls.
    notifier: Notifier
        A Notifier object to handle the user UI notifications while tracks are loaded.
    Returns
    -------
    List[str]
        List of Youtube URLs.
    """
    current_cache_level = (
        CacheLevel(await self.config.cache_level()) if HAS_SQL else CacheLevel.none()
    )
    cache_enabled = CacheLevel.set_spotify().is_subset(current_cache_level)
    if query_type == "track" and cache_enabled:
        update = True
        with contextlib.suppress(SQLError):
            val, update = await self.fetch_one(
                "spotify", "track_info", {"uri": f"spotify:track:{uri}"}
            )
        if update:
            val = None
    else:
        val = None
    youtube_urls = []
    if val is None:
        urls = await self._spotify_first_time_query(
            ctx,
            query_type,
            uri,
            notifier,
            skip_youtube,
            current_cache_level=current_cache_level,
        )
        youtube_urls.extend(urls)
    else:
        if query_type == "track" and cache_enabled:
            task = ("update", ("spotify", {"uri": f"spotify:track:{uri}"}))
            self.append_task(ctx, *task)
        youtube_urls.append(val)
    return youtube_urls


# 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 spotify_query(
    self,
    ctx: commands.Context,
    query_type: str,
    uri: str,
    skip_youtube: bool = False,
    notifier: Optional[Notifier] = None,
) -> List[str]:
    """Queries the Database then falls back to Spotify and YouTube APIs.

    Parameters
    ----------
    ctx: commands.Context
        The context this method is being called under.
    query_type : str
        Type of query to perform (Pl
    uri: str
        Spotify URL ID .
    skip_youtube:bool
        Whether or not to skip YouTube API Calls.
    notifier: Notifier
        A Notifier object to handle the user UI notifications while tracks are loaded.
    Returns
    -------
    List[str]
        List of Youtube URLs.
    """
    current_cache_level = CacheLevel(await self.config.cache_level())
    cache_enabled = CacheLevel.set_spotify().is_subset(current_cache_level)
    if query_type == "track" and cache_enabled:
        update = True
        with contextlib.suppress(SQLError):
            (val, update) = await self.database.fetch_one(
                "spotify", "track_info", {"uri": f"spotify:track:{uri}"}
            )
        if update:
            val = None
    else:
        val = None
    youtube_urls = []
    if val is None:
        urls = await self._spotify_first_time_query(
            ctx,
            query_type,
            uri,
            notifier,
            skip_youtube,
            current_cache_level=current_cache_level,
        )
        youtube_urls.extend(urls)
    else:
        if query_type == "track" and cache_enabled:
            task = ("update", ("spotify", {"uri": f"spotify:track:{uri}"}))
            self.append_task(ctx, *task)
        youtube_urls.append(val)
    return youtube_urls