# Buggy code
async def localpath(self, ctx: commands.Context, *, local_path=None):
    """Set the localtracks path if the Lavalink.jar is not run from the Audio data folder.

    Leave the path blank to reset the path to the default, the Audio data directory.
    """

    if not local_path:
        await self.config.localpath.set(str(cog_data_path(raw_name="Audio")))
        pass_config_to_dependencies(
            self.config, self.bot, str(cog_data_path(raw_name="Audio"))
        )
        return await self._embed_msg(
            ctx,
            _("The localtracks path location has been reset to the default location."),
        )

    info_msg = _(
        "This setting is only for bot owners to set a localtracks folder location "
        "In the example below, the full path for 'ParentDirectory' "
        "must be passed to this command.\n"
        "The path must not contain spaces.\n"
        "```\n"
        "ParentDirectory\n"
        "  |__ localtracks  (folder)\n"
        "  |     |__ Awesome Album Name  (folder)\n"
        "  |           |__01 Cool Song.mp3\n"
        "  |           |__02 Groovy Song.mp3\n"
        "```\n"
        "The folder path given to this command must contain the localtracks folder.\n"
        "**This folder and files need to be visible to the user where `"
        "Lavalink.jar` is being run from.**\n"
        "Use this command with no path given to reset it to the default, "
        "the Audio data directory for this bot.\n"
        "Do you want to continue to set the provided path for local tracks?"
    )
    info = await ctx.maybe_send_embed(info_msg)

    start_adding_reactions(info, ReactionPredicate.YES_OR_NO_EMOJIS)
    pred = ReactionPredicate.yes_or_no(info, ctx.author)
    await ctx.bot.wait_for("reaction_add", check=pred)

    if not pred.result:
        with contextlib.suppress(discord.HTTPException):
            await info.delete()
        return
    temp = audio_dataclasses.LocalPath(local_path, forced=True)
    if not temp.exists() or not temp.is_dir():
        return await self._embed_msg(
            ctx,
            _("{local_path} does not seem like a valid path.").format(
                local_path=local_path
            ),
        )

    if not temp.localtrack_folder.exists():
        warn_msg = _(
            "`{localtracks}` does not exist. "
            "The path will still be saved, but please check the path and "
            "create a localtracks folder in `{localfolder}` before attempting "
            "to play local tracks."
        ).format(
            localfolder=temp.absolute(), localtracks=temp.localtrack_folder.absolute()
        )
        await ctx.send(
            embed=discord.Embed(
                title=_("Incorrect environment."),
                description=warn_msg,
                colour=await ctx.embed_colour(),
            )
        )
    local_path = str(temp.localtrack_folder.absolute())
    await self.config.localpath.set(local_path)
    pass_config_to_dependencies(self.config, self.bot, local_path)
    await self._embed_msg(
        ctx, _("Localtracks path set to: {local_path}.").format(local_path=local_path)
    )


# 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 localpath(self, ctx: commands.Context, *, local_path=None):
    """Set the localtracks path if the Lavalink.jar is not run from the Audio data folder.

    Leave the path blank to reset the path to the default, the Audio data directory.
    """

    if not local_path:
        await self.config.localpath.set(str(cog_data_path(raw_name="Audio")))
        pass_config_to_dependencies(
            self.config, self.bot, str(cog_data_path(raw_name="Audio"))
        )
        return await self._embed_msg(
            ctx,
            title=_("Setting Changed"),
            description=_(
                "The localtracks path location has been reset to {localpath}"
            ).format(localpath=str(cog_data_path(raw_name="Audio").absolute())),
        )

    info_msg = _(
        "This setting is only for bot owners to set a localtracks folder location "
        "In the example below, the full path for 'ParentDirectory' "
        "must be passed to this command.\n"
        "The path must not contain spaces.\n"
        "```\n"
        "ParentDirectory\n"
        "  |__ localtracks  (folder)\n"
        "  |     |__ Awesome Album Name  (folder)\n"
        "  |           |__01 Cool Song.mp3\n"
        "  |           |__02 Groovy Song.mp3\n"
        "```\n"
        "The folder path given to this command must contain the localtracks folder.\n"
        "**This folder and files need to be visible to the user where `"
        "Lavalink.jar` is being run from.**\n"
        "Use this command with no path given to reset it to the default, "
        "the Audio data directory for this bot.\n"
        "Do you want to continue to set the provided path for local tracks?"
    )
    info = await ctx.maybe_send_embed(info_msg)

    start_adding_reactions(info, ReactionPredicate.YES_OR_NO_EMOJIS)
    pred = ReactionPredicate.yes_or_no(info, ctx.author)
    await ctx.bot.wait_for("reaction_add", check=pred)

    if not pred.result:
        with contextlib.suppress(discord.HTTPException):
            await info.delete()
        return
    temp = audio_dataclasses.LocalPath(local_path, forced=True)
    if not temp.exists() or not temp.is_dir():
        return await self._embed_msg(
            ctx,
            title=_("Invalid Path"),
            description=_("{local_path} does not seem like a valid path.").format(
                local_path=local_path
            ),
        )

    if not temp.localtrack_folder.exists():
        warn_msg = _(
            "`{localtracks}` does not exist. "
            "The path will still be saved, but please check the path and "
            "create a localtracks folder in `{localfolder}` before attempting "
            "to play local tracks."
        ).format(
            localfolder=temp.absolute(), localtracks=temp.localtrack_folder.absolute()
        )
        await self._embed_msg(ctx, title=_("Invalid Environment"), description=warn_msg)
    local_path = str(temp.localtrack_folder.absolute())
    await self.config.localpath.set(local_path)
    pass_config_to_dependencies(self.config, self.bot, local_path)
    return await self._embed_msg(
        ctx,
        title=_("Setting Changed"),
        description=_(
            "The localtracks path location has been set to {localpath}"
        ).format(localpath=local_path),
    )