# Buggy code
def __init__(self, bot):
    super().__init__()
    self.bot = bot
    self.config = Config.get_conf(self, 2711759130, force_registration=True)
    self.skip_votes = {}
    self.session = aiohttp.ClientSession()
    self._connect_task = None
    self._disconnect_task = None
    self._cleaned_up = False
    self._connection_aborted = False
    self.play_lock = {}
    self._manager: Optional[ServerManager] = None
    self._cog_name = None
    self._cog_id = None
    default_global = dict(
        schema_version=1,
        cache_level=0,
        cache_age=365,
        status=False,
        use_external_lavalink=False,
        restrict=True,
        current_version=redbot.core.VersionInfo.from_str("3.0.0a0").to_json(),
        localpath=str(cog_data_path(raw_name="Audio")),
        **self._default_lavalink_settings,
    )

    default_guild = dict(
        auto_play=False,
        autoplaylist=dict(enabled=False, id=None, name=None, scope=None),
        disconnect=False,
        dj_enabled=False,
        dj_role=None,
        emptydc_enabled=False,
        emptydc_timer=0,
        emptypause_enabled=False,
        emptypause_timer=0,
        jukebox=False,
        jukebox_price=0,
        maxlength=0,
        notify=False,
        repeat=False,
        shuffle=False,
        thumbnail=False,
        volume=100,
        vote_enabled=False,
        vote_percent=0,
        room_lock=None,
        url_keyword_blacklist=[],
        url_keyword_whitelist=[],
    )
    _playlist = dict(id=None, author=None, name=None, playlist_url=None, tracks=[])
    self.config.init_custom("EQUALIZER", 1)
    self.config.register_custom("EQUALIZER", eq_bands=[], eq_presets={})
    self.config.init_custom(PlaylistScope.GLOBAL.value, 1)
    self.config.register_custom(PlaylistScope.GLOBAL.value, **_playlist)
    self.config.init_custom(PlaylistScope.GUILD.value, 2)
    self.config.register_custom(PlaylistScope.GUILD.value, **_playlist)
    self.config.init_custom(PlaylistScope.USER.value, 2)
    self.config.register_custom(PlaylistScope.USER.value, **_playlist)
    self.config.register_guild(**default_guild)
    self.config.register_global(**default_global)
    self.music_cache = MusicCache(
        bot, self.session, path=str(cog_data_path(raw_name="Audio"))
    )
    self.play_lock = {}

    self._manager: Optional[ServerManager] = None
    # These has to be a task since this requires the bot to be ready
    # If it waits for ready in startup, we cause a deadlock during initial load
    # as initial load happens before the bot can ever be ready.
    self._init_task = self.bot.loop.create_task(self.initialize())
    self._ready_event = asyncio.Event()


# 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, bot):
    super().__init__()
    self.bot: Red = bot
    self.config: Config = Config.get_conf(self, 2711759130, force_registration=True)
    self.skip_votes: MutableMapping[discord.Guild, List[discord.Member]] = {}
    self.play_lock: MutableMapping[int, bool] = {}
    self._dj_status_cache: MutableMapping[int, Optional[bool]] = {}
    self._dj_role_cache: MutableMapping[int, Optional[int]] = {}
    self.session: aiohttp.ClientSession = aiohttp.ClientSession()
    self._connect_task: Optional[asyncio.Task] = None
    self._disconnect_task: Optional[asyncio.Task] = None
    self._cleaned_up: bool = False
    self._connection_aborted: bool = False
    self._manager: Optional[ServerManager] = None
    default_global: Mapping = dict(
        schema_version=1,
        cache_level=0,
        cache_age=365,
        status=False,
        use_external_lavalink=False,
        restrict=True,
        localpath=str(cog_data_path(raw_name="Audio")),
        url_keyword_blacklist=[],
        url_keyword_whitelist=[],
        **self._default_lavalink_settings,
    )

    default_guild: Mapping = dict(
        auto_play=False,
        autoplaylist=dict(enabled=False, id=None, name=None, scope=None),
        disconnect=False,
        dj_enabled=False,
        dj_role=None,
        emptydc_enabled=False,
        emptydc_timer=0,
        emptypause_enabled=False,
        emptypause_timer=0,
        jukebox=False,
        jukebox_price=0,
        maxlength=0,
        notify=False,
        repeat=False,
        shuffle=False,
        shuffle_bumped=True,
        thumbnail=False,
        volume=100,
        vote_enabled=False,
        vote_percent=0,
        room_lock=None,
        url_keyword_blacklist=[],
        url_keyword_whitelist=[],
    )
    _playlist: Mapping = dict(
        id=None, author=None, name=None, playlist_url=None, tracks=[]
    )
    self.config.init_custom("EQUALIZER", 1)
    self.config.register_custom("EQUALIZER", eq_bands=[], eq_presets={})
    self.config.init_custom(PlaylistScope.GLOBAL.value, 1)
    self.config.register_custom(PlaylistScope.GLOBAL.value, **_playlist)
    self.config.init_custom(PlaylistScope.GUILD.value, 2)
    self.config.register_custom(PlaylistScope.GUILD.value, **_playlist)
    self.config.init_custom(PlaylistScope.USER.value, 2)
    self.config.register_custom(PlaylistScope.USER.value, **_playlist)
    self.config.register_guild(**default_guild)
    self.config.register_global(**default_global)
    self.music_cache: Optional[MusicCache] = None
    self._error_counter: Counter = Counter()
    self._error_timer: MutableMapping[int, int] = {}
    self._disconnected_players: MutableMapping[int, bool] = {}

    # These has to be a task since this requires the bot to be ready
    # If it waits for ready in startup, we cause a deadlock during initial load
    # as initial load happens before the bot can ever be ready.
    self._init_task: asyncio.Task = self.bot.loop.create_task(self.initialize())
    self._ready_event: asyncio.Event = asyncio.Event()