# Buggy code
async def stream_alert(self, ctx: commands.Context, _class, channel_name):
    stream = self.get_stream(_class, channel_name)
    if not stream:
        token = await self.bot.get_shared_api_tokens(_class.token_name)
        is_yt = _class.__name__ == "YoutubeStream"
        is_twitch = _class.__name__ == "TwitchStream"
        if is_yt and not self.check_name_or_id(channel_name):
            stream = _class(id=channel_name, token=token, config=self.config)
        elif is_twitch:
            await self.maybe_renew_twitch_bearer_token()
            stream = _class(
                name=channel_name,
                token=token.get("client_id"),
                bearer=self.ttv_bearer_cache.get("access_token", None),
            )
        else:
            stream = _class(name=channel_name, token=token)
        try:
            exists = await self.check_exists(stream)
        except InvalidTwitchCredentials:
            await ctx.send(
                _(
                    "The Twitch token is either invalid or has not been set. See {command}."
                ).format(command=f"`{ctx.clean_prefix}streamset twitchtoken`")
            )
            return
        except InvalidYoutubeCredentials:
            await ctx.send(
                _(
                    "The YouTube API key is either invalid or has not been set. See "
                    "{command}."
                ).format(command=f"`{ctx.clean_prefix}streamset youtubekey`")
            )
            return
        except YoutubeQuotaExceeded:
            await ctx.send(
                _(
                    "YouTube quota has been exceeded."
                    " Try again later or contact the owner if this continues."
                )
            )
        except APIError as e:
            log.error(
                "Something went wrong whilst trying to contact the stream service's API.\n"
                "Raw response data:\n%r",
                e,
            )
            await ctx.send(
                _(
                    "Something went wrong whilst trying to contact the stream service's API."
                )
            )
            return
        else:
            if not exists:
                await ctx.send(_("That channel doesn't seem to exist."))
                return

    await self.add_or_remove(ctx, stream)


# Traceback (KeyError)
Exception in command 'streamalert youtube'
Traceback (most recent call last):
File "/home/ubuntu/red-venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/ubuntu/red-venv/lib/python3.8/site-packages/redbot/cogs/streams/streams.py", line 322, in youtube_alert
await self.stream_alert(ctx, YoutubeStream, channel_name_or_id)
File "/home/ubuntu/red-venv/lib/python3.8/site-packages/redbot/cogs/streams/streams.py", line 411, in stream_alert
stream = _class(name=channel_name, token=token)
File "/home/ubuntu/red-venv/lib/python3.8/site-packages/redbot/cogs/streams/streamtypes.py", line 92, in __init__
self._config = kwargs.pop("config")
KeyError: 'config'

# Fixed code
async def stream_alert(self, ctx: commands.Context, _class, channel_name):
    stream = self.get_stream(_class, channel_name)
    if not stream:
        token = await self.bot.get_shared_api_tokens(_class.token_name)
        is_yt = _class.__name__ == "YoutubeStream"
        is_twitch = _class.__name__ == "TwitchStream"
        if is_yt and not self.check_name_or_id(channel_name):
            stream = _class(id=channel_name, token=token, config=self.config)
        elif is_twitch:
            await self.maybe_renew_twitch_bearer_token()
            stream = _class(
                name=channel_name,
                token=token.get("client_id"),
                bearer=self.ttv_bearer_cache.get("access_token", None),
            )
        else:
            if is_yt:
                stream = _class(name=channel_name, token=token, config=self.config)
            else:
                stream = _class(name=channel_name, token=token)
        try:
            exists = await self.check_exists(stream)
        except InvalidTwitchCredentials:
            await ctx.send(
                _(
                    "The Twitch token is either invalid or has not been set. See {command}."
                ).format(command=f"`{ctx.clean_prefix}streamset twitchtoken`")
            )
            return
        except InvalidYoutubeCredentials:
            await ctx.send(
                _(
                    "The YouTube API key is either invalid or has not been set. See "
                    "{command}."
                ).format(command=f"`{ctx.clean_prefix}streamset youtubekey`")
            )
            return
        except YoutubeQuotaExceeded:
            await ctx.send(
                _(
                    "YouTube quota has been exceeded."
                    " Try again later or contact the owner if this continues."
                )
            )
        except APIError as e:
            log.error(
                "Something went wrong whilst trying to contact the stream service's API.\n"
                "Raw response data:\n%r",
                e,
            )
            await ctx.send(
                _(
                    "Something went wrong whilst trying to contact the stream service's API."
                )
            )
            return
        else:
            if not exists:
                await ctx.send(_("That channel doesn't seem to exist."))
                return

    await self.add_or_remove(ctx, stream)