# Buggy code
def __init__(self, query: Union[LocalPath, str], **kwargs):
    query = kwargs.get("queryforced", query)
    self._raw: Union[LocalPath, str] = query

    _localtrack: LocalPath = LocalPath(query)

    self.track: Union[LocalPath, str] = (
        _localtrack
        if ((_localtrack.is_file() or _localtrack.is_dir()) and _localtrack.exists())
        else query
    )

    self.valid: bool = query != "InvalidQueryPlaceHolderName"
    self.is_local: bool = kwargs.get("local", False)
    self.is_spotify: bool = kwargs.get("spotify", False)
    self.is_youtube: bool = kwargs.get("youtube", False)
    self.is_soundcloud: bool = kwargs.get("soundcloud", False)
    self.is_bandcamp: bool = kwargs.get("bandcamp", False)
    self.is_vimeo: bool = kwargs.get("vimeo", False)
    self.is_mixer: bool = kwargs.get("mixer", False)
    self.is_twitch: bool = kwargs.get("twitch", False)
    self.is_other: bool = kwargs.get("other", False)
    self.is_playlist: bool = kwargs.get("playlist", False)
    self.is_album: bool = kwargs.get("album", False)
    self.is_search: bool = kwargs.get("search", False)
    self.is_stream: bool = kwargs.get("stream", False)
    self.single_track: bool = kwargs.get("single", False)
    self.id: Optional[str] = kwargs.get("id", None)
    self.invoked_from: Optional[str] = kwargs.get("invoked_from", None)
    self.local_name: Optional[str] = kwargs.get("name", None)
    self.search_subfolders: bool = kwargs.get("search_subfolders", False)
    self.spotify_uri: Optional[str] = kwargs.get("uri", None)

    self.start_time: int = kwargs.get("start_time", 0)
    self.track_index: Optional[int] = kwargs.get("track_index", None)

    if self.invoked_from == "sc search":
        self.is_youtube = False
        self.is_soundcloud = True

    self.lavalink_query: str = self._get_query()

    if self.is_playlist or self.is_album:
        self.single_track = False


# 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
def __init__(self, query: Union[LocalPath, str], **kwargs):
    query = kwargs.get("queryforced", query)
    self._raw: Union[LocalPath, str] = query

    _localtrack: LocalPath = LocalPath(query)

    self.track: Union[LocalPath, str] = (
        _localtrack
        if ((_localtrack.is_file() or _localtrack.is_dir()) and _localtrack.exists())
        else query
    )

    self.valid: bool = query != "InvalidQueryPlaceHolderName"
    self.is_local: bool = kwargs.get("local", False)
    self.is_spotify: bool = kwargs.get("spotify", False)
    self.is_youtube: bool = kwargs.get("youtube", False)
    self.is_soundcloud: bool = kwargs.get("soundcloud", False)
    self.is_bandcamp: bool = kwargs.get("bandcamp", False)
    self.is_vimeo: bool = kwargs.get("vimeo", False)
    self.is_mixer: bool = kwargs.get("mixer", False)
    self.is_twitch: bool = kwargs.get("twitch", False)
    self.is_other: bool = kwargs.get("other", False)
    self.is_playlist: bool = kwargs.get("playlist", False)
    self.is_album: bool = kwargs.get("album", False)
    self.is_search: bool = kwargs.get("search", False)
    self.is_stream: bool = kwargs.get("stream", False)
    self.single_track: bool = kwargs.get("single", False)
    self.id: Optional[str] = kwargs.get("id", None)
    self.invoked_from: Optional[str] = kwargs.get("invoked_from", None)
    self.local_name: Optional[str] = kwargs.get("name", None)
    self.search_subfolders: bool = kwargs.get("search_subfolders", False)
    self.spotify_uri: Optional[str] = kwargs.get("uri", None)
    self.uri: Optional[str] = kwargs.get("url", None)
    self.is_url: bool = kwargs.get("is_url", False)

    self.start_time: int = kwargs.get("start_time", 0)
    self.track_index: Optional[int] = kwargs.get("track_index", None)

    if self.invoked_from == "sc search":
        self.is_youtube = False
        self.is_soundcloud = True

    self.lavalink_query: str = self._get_query()

    if self.is_playlist or self.is_album:
        self.single_track = False
    self._hash = hash(
        (
            self.valid,
            self.is_local,
            self.is_spotify,
            self.is_youtube,
            self.is_soundcloud,
            self.is_bandcamp,
            self.is_vimeo,
            self.is_mixer,
            self.is_twitch,
            self.is_other,
            self.is_playlist,
            self.is_album,
            self.is_search,
            self.is_stream,
            self.single_track,
            self.id,
            self.spotify_uri,
            self.start_time,
            self.track_index,
            self.uri,
        )
    )