# Buggy code
async def local_play(
    self, ctx: commands.Context, play_subfolders: Optional[bool] = True
):
    """Play a local track."""
    if not await self._localtracks_check(ctx):
        return
    localtracks_folders = await self._localtracks_folders(
        ctx, search_subfolders=play_subfolders
    )
    if not localtracks_folders:
        return await self._embed_msg(ctx, _("No album folders found."))
    async with ctx.typing():
        len_folder_pages = math.ceil(len(localtracks_folders) / 5)
        folder_page_list = []
        for page_num in range(1, len_folder_pages + 1):
            embed = await self._build_search_page(ctx, localtracks_folders, page_num)
            folder_page_list.append(embed)

    async def _local_folder_menu(
        ctx: commands.Context,
        pages: list,
        controls: dict,
        message: discord.Message,
        page: int,
        timeout: float,
        emoji: str,
    ):
        if message:
            with contextlib.suppress(discord.HTTPException):
                await message.delete()
            await self._search_button_action(ctx, localtracks_folders, emoji, page)
            return None

    local_folder_controls = {
        "1⃣": _local_folder_menu,
        "2⃣": _local_folder_menu,
        "3⃣": _local_folder_menu,
        "4⃣": _local_folder_menu,
        "5⃣": _local_folder_menu,
        "⬅": prev_page,
        "❌": close_menu,
        "➡": next_page,
    }

    dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
    if dj_enabled and not await self._can_instaskip(ctx, ctx.author):
        return await menu(ctx, folder_page_list, DEFAULT_CONTROLS)
    else:
        await menu(ctx, folder_page_list, local_folder_controls)


# 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 local_play(
    self, ctx: commands.Context, play_subfolders: Optional[bool] = True
):
    """Play a local track."""
    if not await self._localtracks_check(ctx):
        return
    localtracks_folders = await self._localtracks_folders(
        ctx, search_subfolders=play_subfolders
    )
    if not localtracks_folders:
        return await self._embed_msg(ctx, title=_("No album folders found."))
    async with ctx.typing():
        len_folder_pages = math.ceil(len(localtracks_folders) / 5)
        folder_page_list = []
        for page_num in range(1, len_folder_pages + 1):
            embed = await self._build_search_page(ctx, localtracks_folders, page_num)
            folder_page_list.append(embed)

    async def _local_folder_menu(
        ctx: commands.Context,
        pages: list,
        controls: MutableMapping,
        message: discord.Message,
        page: int,
        timeout: float,
        emoji: str,
    ):
        if message:
            with contextlib.suppress(discord.HTTPException):
                await message.delete()
            await self._search_button_action(ctx, localtracks_folders, emoji, page)
            return None

    local_folder_controls = {
        "\N{DIGIT ONE}\N{COMBINING ENCLOSING KEYCAP}": _local_folder_menu,
        "\N{DIGIT TWO}\N{COMBINING ENCLOSING KEYCAP}": _local_folder_menu,
        "\N{DIGIT THREE}\N{COMBINING ENCLOSING KEYCAP}": _local_folder_menu,
        "\N{DIGIT FOUR}\N{COMBINING ENCLOSING KEYCAP}": _local_folder_menu,
        "\N{DIGIT FIVE}\N{COMBINING ENCLOSING KEYCAP}": _local_folder_menu,
        "\N{LEFTWARDS BLACK ARROW}": prev_page,
        "\N{CROSS MARK}": close_menu,
        "\N{BLACK RIGHTWARDS ARROW}": next_page,
    }

    dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
    if dj_enabled and not await self._can_instaskip(ctx, ctx.author):
        return await menu(ctx, folder_page_list, DEFAULT_CONTROLS)
    else:
        await menu(ctx, folder_page_list, local_folder_controls)