gurudesh/pytracebugs huggingface dataset:
# Buggy code
async def mongo_to_json(current_data_dir: Path, storage_details: dict):
    from redbot.core.drivers.red_mongo import Mongo

    m = Mongo("Core", "0", **storage_details)
    db = m.db
    collection_names = await db.collection_names(include_system_collections=False)
    for c_name in collection_names:
        if c_name == "Core":
            c_data_path = current_data_dir / "core"
        else:
            c_data_path = current_data_dir / "cogs/{}".format(c_name)
        output = {}
        docs = await db[c_name].find().to_list(None)
        c_id = None
        for item in docs:
            item_id = item.pop("_id")
            if not c_id:
                c_id = str(hash(item_id))
            output[item_id] = item
        target = JSON(c_name, c_id, data_path_override=c_data_path)
        await target.jsonIO._threadsafe_save_json(output)


# Traceback (TypeError)
Would you like to import your data? (y/n) y
Traceback (most recent call last):
File "/home/red/.pyenv/versions/3.7.1/bin/redbot-setup", line 11, in <module>
load_entry_point('Red-DiscordBot==3.0.0rc3.post1', 'console_scripts', 'redbot-setup')()
File "/home/red/.pyenv/versions/3.7.1/lib/python3.7/site-packages/redbot/setup.py", line 378, in main
loop.run_until_complete(edit_instance())
File "/home/red/.pyenv/versions/3.7.1/lib/python3.7/asyncio/base_events.py", line 573, in run_until_complete
return future.result()
File "/home/red/.pyenv/versions/3.7.1/lib/python3.7/site-packages/redbot/setup.py", line 278, in edit_instance
await mongo_to_json(current_data_dir, storage_details)
File "/home/red/.pyenv/versions/3.7.1/lib/python3.7/site-packages/redbot/setup.py", line 201, in mongo_to_json
collection_names = await db.collection_names(include_system_collections=False)
File "/home/red/.pyenv/versions/3.7.1/lib/python3.7/site-packages/motor/core.py", line 554, in __call__
self.delegate.name)
TypeError: MotorCollection object is not callable. If you meant to call the 'collection_names' method on a MotorCollection object it is failing because no such method exists.

# Fixed code
async def mongo_to_json(current_data_dir: Path, storage_details: dict):
    from redbot.core.drivers.red_mongo import Mongo

    m = Mongo("Core", "0", **storage_details)
    db = m.db
    collection_names = await db.list_collection_names()
    for collection_name in collection_names:
        if collection_name == "Core":
            c_data_path = current_data_dir / "core"
        else:
            c_data_path = current_data_dir / "cogs" / collection_name
        c_data_path.mkdir(parents=True, exist_ok=True)
        # Every cog name has its own collection
        collection = db[collection_name]
        async for document in collection.find():
            # Every cog has its own document.
            # This means if two cogs have the same name but different identifiers, they will
            # be two separate documents in the same collection
            cog_id = document.pop("_id")
            driver = JSON(collection_name, cog_id, data_path_override=c_data_path)
            for key, value in document.items():
                await driver.set(key, value=value)
# Buggy code
async def next_page(
    ctx: commands.Context,
    pages: list,
    controls: dict,
    message: discord.Message,
    page: int,
    timeout: float,
    emoji: str,
):
    perms = message.channel.permissions_for(ctx.me)
    if perms.manage_messages:  # Can manage messages, so remove react
        try:
            await message.remove_reaction(emoji, ctx.author)
        except discord.NotFound:
            pass
    if page == len(pages) - 1:
        page = 0  # Loop around to the first item
    else:
        page = page + 1
    return await menu(ctx, pages, controls, message=message, page=page, timeout=timeout)


# Traceback (discord.errors.NotFound)
ERROR events on_command_error 208: Exception in command 'urban'
Traceback (most recent call last):
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\redbot\core\utils\menus.py", line 85, in menu
timeout=timeout,
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\asyncio\tasks.py", line 362, in wait_for
raise futures.TimeoutError()
concurrent.futures._base.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\discord\ext\commands\core.py", line 61, in wrapped
ret = await coro(*args, **kwargs)
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\redbot\cogs\general\general.py", line 301, in urban
timeout=30,
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\redbot\core\utils\menus.py", line 89, in menu
await message.clear_reactions()
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\discord\message.py", line 748, in clear_reactions
await self._state.http.clear_reactions(self.id, self.channel.id)
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\discord\http.py", line 211, in request
raise NotFound(r, data)
discord.errors.NotFound: NOT FOUND (status code: 404): Unknown Message

# Fixed code
async def next_page(
    ctx: commands.Context,
    pages: list,
    controls: dict,
    message: discord.Message,
    page: int,
    timeout: float,
    emoji: str,
):
    perms = message.channel.permissions_for(ctx.me)
    if perms.manage_messages:  # Can manage messages, so remove react
        with contextlib.suppress(discord.NotFound):
            await message.remove_reaction(emoji, ctx.author)
    if page == len(pages) - 1:
        page = 0  # Loop around to the first item
    else:
        page = page + 1
    return await menu(ctx, pages, controls, message=message, page=page, timeout=timeout)
# Buggy code
async def prev_page(
    ctx: commands.Context,
    pages: list,
    controls: dict,
    message: discord.Message,
    page: int,
    timeout: float,
    emoji: str,
):
    perms = message.channel.permissions_for(ctx.me)
    if perms.manage_messages:  # Can manage messages, so remove react
        try:
            await message.remove_reaction(emoji, ctx.author)
        except discord.NotFound:
            pass
    if page == 0:
        page = len(pages) - 1  # Loop around to the last item
    else:
        page = page - 1
    return await menu(ctx, pages, controls, message=message, page=page, timeout=timeout)


# Traceback (discord.errors.NotFound)
ERROR events on_command_error 208: Exception in command 'urban'
Traceback (most recent call last):
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\redbot\core\utils\menus.py", line 85, in menu
timeout=timeout,
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\asyncio\tasks.py", line 362, in wait_for
raise futures.TimeoutError()
concurrent.futures._base.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\discord\ext\commands\core.py", line 61, in wrapped
ret = await coro(*args, **kwargs)
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\redbot\cogs\general\general.py", line 301, in urban
timeout=30,
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\redbot\core\utils\menus.py", line 89, in menu
await message.clear_reactions()
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\discord\message.py", line 748, in clear_reactions
await self._state.http.clear_reactions(self.id, self.channel.id)
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\discord\http.py", line 211, in request
raise NotFound(r, data)
discord.errors.NotFound: NOT FOUND (status code: 404): Unknown Message

# Fixed code
async def prev_page(
    ctx: commands.Context,
    pages: list,
    controls: dict,
    message: discord.Message,
    page: int,
    timeout: float,
    emoji: str,
):
    perms = message.channel.permissions_for(ctx.me)
    if perms.manage_messages:  # Can manage messages, so remove react
        with contextlib.suppress(discord.NotFound):
            await message.remove_reaction(emoji, ctx.author)
    if page == 0:
        page = len(pages) - 1  # Loop around to the last item
    else:
        page = page - 1
    return await menu(ctx, pages, controls, message=message, page=page, timeout=timeout)
# Buggy code
async def close_menu(
    ctx: commands.Context,
    pages: list,
    controls: dict,
    message: discord.Message,
    page: int,
    timeout: float,
    emoji: str,
):
    if message:
        await message.delete()
    return None


# Traceback (discord.errors.NotFound)
ERROR events on_command_error 208: Exception in command 'urban'
Traceback (most recent call last):
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\redbot\core\utils\menus.py", line 85, in menu
timeout=timeout,
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\asyncio\tasks.py", line 362, in wait_for
raise futures.TimeoutError()
concurrent.futures._base.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\discord\ext\commands\core.py", line 61, in wrapped
ret = await coro(*args, **kwargs)
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\redbot\cogs\general\general.py", line 301, in urban
timeout=30,
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\redbot\core\utils\menus.py", line 89, in menu
await message.clear_reactions()
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\discord\message.py", line 748, in clear_reactions
await self._state.http.clear_reactions(self.id, self.channel.id)
File "c:\users\Ferret\appdata\local\programs\python\python36\lib\site-packages\discord\http.py", line 211, in request
raise NotFound(r, data)
discord.errors.NotFound: NOT FOUND (status code: 404): Unknown Message

# Fixed code
async def close_menu(
    ctx: commands.Context,
    pages: list,
    controls: dict,
    message: discord.Message,
    page: int,
    timeout: float,
    emoji: str,
):
    with contextlib.suppress(discord.NotFound):
        await message.delete()
# Buggy code
async def json_to_mongo(current_data_dir: Path, storage_details: dict):
    from redbot.core.drivers.red_mongo import Mongo

    core_data_file = list(current_data_dir.glob("core/settings.json"))[0]
    m = Mongo("Core", "0", **storage_details)
    with core_data_file.open(mode="r") as f:
        core_data = json.loads(f.read())
    collection = m.get_collection()
    await collection.update_one(
        {"_id": m.unique_cog_identifier}, update={"$set": core_data["0"]}, upsert=True
    )
    for p in current_data_dir.glob("cogs/**/settings.json"):
        with p.open(mode="r") as f:
            cog_data = json.loads(f.read())
        cog_i = None
        for ident in list(cog_data.keys()):
            cog_i = str(hash(ident))
        cog_m = Mongo(p.parent.stem, cog_i, **storage_details)
        cog_c = cog_m.get_collection()
        for ident in list(cog_data.keys()):
            await cog_c.update_one(
                {"_id": cog_m.unique_cog_identifier},
                update={"$set": cog_data[cog_i]},
                upsert=True,
            )


# Traceback (KeyError)
Please choose your storage backend (if you re unsure, choose 1).
1. JSON (file storage, requires no database).
2. MongoDB
2
Enter URI scheme (mongodb or mongodb+srv): mongodb
Enter host address: 127.0.0.1:27017
Enter login username:
Enter login password:
Enter mongodb database name: Oxibot
Would you like to import your data? (y/n) y
Traceback (most recent call last):
File "/usr/local/bin/redbot-setup", line 11, in <module>
load_entry_point('Red-DiscordBot==3.0.0rc2', 'console_scripts', 'redbot-setup')()
File "/usr/local/lib/python3.6/dist-packages/redbot/setup.py", line 384, in main
loop.run_until_complete(edit_instance())
File "/usr/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
return future.result()
File "/usr/local/lib/python3.6/dist-packages/redbot/setup.py", line 278, in edit_instance
await json_to_mongo(current_data_dir, storage_details)
File "/usr/local/lib/python3.6/dist-packages/redbot/setup.py", line 198, in json_to_mongo
{"_id": cog_m.unique_cog_identifier}, update={"$set": cog_data[cog_i]}, upsert=True
KeyError: '-4851999857783813997'

# Fixed code
async def json_to_mongo(current_data_dir: Path, storage_details: dict):
    from redbot.core.drivers.red_mongo import Mongo

    core_data_file = current_data_dir / "core" / "settings.json"
    driver = Mongo(cog_name="Core", identifier="0", **storage_details)
    with core_data_file.open(mode="r") as f:
        core_data = json.loads(f.read())
    data = core_data.get("0", {})
    for key, value in data.items():
        await driver.set(key, value=value)
    for p in current_data_dir.glob("cogs/**/settings.json"):
        cog_name = p.parent.stem
        with p.open(mode="r") as f:
            cog_data = json.load(f)
        for identifier, data in cog_data.items():
            driver = Mongo(cog_name, identifier, **storage_details)
            for key, value in data.items():
                await driver.set(key, value=value)
# Buggy code
async def load_streams(self):
    streams = []

    for raw_stream in await self.db.streams():
        _class = getattr(_streamtypes, raw_stream["type"], None)
        if not _class:
            continue
        raw_msg_cache = raw_stream["messages"]
        raw_stream["_messages_cache"] = []
        for raw_msg in raw_msg_cache:
            chn = self.bot.get_channel(raw_msg["channel"])
            msg = await chn.get_message(raw_msg["message"])
            raw_stream["_messages_cache"].append(msg)
        token = await self.db.tokens.get_raw(_class.__name__, default=None)
        if token is not None:
            raw_stream["token"] = token
        streams.append(_class(**raw_stream))

    return streams


# Traceback (discord.errors.NotFound)
Exception during loading of cog
Traceback (most recent call last):
File "/home/jjay/rewrite/lib/python3.6/site-packages/redbot/core/core_commands.py", line 100, in _load
await bot.load_extension(spec)
File "/home/jjay/rewrite/lib/python3.6/site-packages/redbot/core/bot.py", line 228, in load_extension
await lib.setup(self)
File "/home/jjay/rewrite/lib/python3.6/site-packages/redbot/cogs/streams/__init__.py", line 6, in setup
await cog.initialize()
File "/home/jjay/rewrite/lib/python3.6/site-packages/redbot/cogs/streams/streams.py", line 74, in initialize
self.streams = await self.load_streams()
File "/home/jjay/rewrite/lib/python3.6/site-packages/redbot/cogs/streams/streams.py", line 629, in load_streams
msg = await chn.get_message(raw_msg["message"])
File "/home/jjay/rewrite/lib/python3.6/site-packages/discord/abc.py", line 844, in get_message
data = await self._state.http.get_message(channel.id, id)
File "/home/jjay/rewrite/lib/python3.6/site-packages/discord/http.py", line 211, in request
raise NotFound(r, data)
discord.errors.NotFound: NOT FOUND (status code: 404): Unknown Message

# Fixed code
async def load_streams(self):
    streams = []

    for raw_stream in await self.db.streams():
        _class = getattr(_streamtypes, raw_stream["type"], None)
        if not _class:
            continue
        raw_msg_cache = raw_stream["messages"]
        raw_stream["_messages_cache"] = []
        for raw_msg in raw_msg_cache:
            chn = self.bot.get_channel(raw_msg["channel"])
            if chn is not None:
                try:
                    msg = await chn.get_message(raw_msg["message"])
                except discord.HTTPException:
                    pass
                else:
                    raw_stream["_messages_cache"].append(msg)
        token = await self.db.tokens.get_raw(_class.__name__, default=None)
        if token is not None:
            raw_stream["token"] = token
        streams.append(_class(**raw_stream))

    return streams
# Buggy code
async def dj(self, ctx):
    """Toggle DJ mode.

    DJ mode allows users with the DJ role to use audio commands.
    """
    dj_role_id = await self.config.guild(ctx.guild).dj_role()
    if dj_role_id is None and ctx.guild.get_role(dj_role_id):
        await self._embed_msg(
            ctx,
            _("Please set a role to use with DJ mode. Enter the role name or ID now."),
        )

        try:
            pred = MessagePredicate.valid_role(ctx)
            await ctx.bot.wait_for("message", timeout=15.0, check=pred)
            await ctx.invoke(self.role, pred.result)
        except asyncio.TimeoutError:
            return await self._embed_msg(ctx, _("Response timed out, try again later."))

    dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
    await self.config.guild(ctx.guild).dj_enabled.set(not dj_enabled)
    await self._embed_msg(ctx, "DJ role enabled: {}.".format(not dj_enabled))


# Traceback (KeyError)
[06/10/2018 13:59] ERROR events on_command_error 208: Exception in command 'playlist list'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 61, in wrapped
ret = await coro(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/redbot/cogs/audio/audio.py", line 1100, in _playlist_list
_("Author: {name}").format(self.bot.get_user(author)),
KeyError: 'name'
[06/10/2018 13:59] ERROR events on_command_error 213: Exception in command 'playlist list'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 61, in wrapped
ret = await coro(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/redbot/cogs/audio/audio.py", line 1100, in _playlist_list
_("Author: {name}").format(self.bot.get_user(author)),
KeyError: 'name'

# Fixed code
async def dj(self, ctx):
    """Toggle DJ mode.

    DJ mode allows users with the DJ role to use audio commands.
    """
    dj_role_id = await self.config.guild(ctx.guild).dj_role()
    if dj_role_id is None and ctx.guild.get_role(dj_role_id):
        await self._embed_msg(
            ctx,
            _("Please set a role to use with DJ mode. Enter the role name or ID now."),
        )

        try:
            pred = MessagePredicate.valid_role(ctx)
            await ctx.bot.wait_for("message", timeout=15.0, check=pred)
            await ctx.invoke(self.role, pred.result)
        except asyncio.TimeoutError:
            return await self._embed_msg(ctx, _("Response timed out, try again later."))

    dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
    await self.config.guild(ctx.guild).dj_enabled.set(not dj_enabled)
    await self._embed_msg(
        ctx, _("DJ role enabled: {true_or_false}.".format(true_or_false=not dj_enabled))
    )
# Buggy code
async def thumbnail(self, ctx):
    """Toggle displaying a thumbnail on audio messages."""
    thumbnail = await self.config.guild(ctx.guild).thumbnail()
    await self.config.guild(ctx.guild).thumbnail.set(not thumbnail)
    await self._embed_msg(ctx, _("Thumbnail display: {}.").format(not thumbnail))


# Traceback (KeyError)
[06/10/2018 13:59] ERROR events on_command_error 208: Exception in command 'playlist list'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 61, in wrapped
ret = await coro(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/redbot/cogs/audio/audio.py", line 1100, in _playlist_list
_("Author: {name}").format(self.bot.get_user(author)),
KeyError: 'name'
[06/10/2018 13:59] ERROR events on_command_error 213: Exception in command 'playlist list'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 61, in wrapped
ret = await coro(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/redbot/cogs/audio/audio.py", line 1100, in _playlist_list
_("Author: {name}").format(self.bot.get_user(author)),
KeyError: 'name'

# Fixed code
async def thumbnail(self, ctx):
    """Toggle displaying a thumbnail on audio messages."""
    thumbnail = await self.config.guild(ctx.guild).thumbnail()
    await self.config.guild(ctx.guild).thumbnail.set(not thumbnail)
    await self._embed_msg(
        ctx,
        _("Thumbnail display: {true_or_false}.").format(true_or_false=not thumbnail),
    )
# Buggy code
async def wsport(self, ctx, ws_port: int):
    """Set the lavalink websocket server port."""
    await self.config.ws_port.set(ws_port)
    if await self._check_external():
        embed = discord.Embed(
            colour=await ctx.embed_colour(),
            title=_("Websocket port set to {}.").format(ws_port),
        )
        embed.set_footer(text=_("External lavalink server set to True."))
        await ctx.send(embed=embed)
    else:
        await self._embed_msg(
            ctx, _("Websocket port set to {port}.").format(port=ws_port)
        )


# Traceback (KeyError)
[06/10/2018 13:59] ERROR events on_command_error 208: Exception in command 'playlist list'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 61, in wrapped
ret = await coro(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/redbot/cogs/audio/audio.py", line 1100, in _playlist_list
_("Author: {name}").format(self.bot.get_user(author)),
KeyError: 'name'
[06/10/2018 13:59] ERROR events on_command_error 213: Exception in command 'playlist list'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 61, in wrapped
ret = await coro(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/redbot/cogs/audio/audio.py", line 1100, in _playlist_list
_("Author: {name}").format(self.bot.get_user(author)),
KeyError: 'name'

# Fixed code
async def wsport(self, ctx, ws_port: int):
    """Set the lavalink websocket server port."""
    await self.config.ws_port.set(ws_port)
    if await self._check_external():
        embed = discord.Embed(
            colour=await ctx.embed_colour(),
            title=_("Websocket port set to {port}.").format(port=ws_port),
        )
        embed.set_footer(text=_("External lavalink server set to True."))
        await ctx.send(embed=embed)
    else:
        await self._embed_msg(
            ctx, _("Websocket port set to {port}.").format(port=ws_port)
        )
# Buggy code
def setup(bot: Red):
    bot.add_cog(Downloader(bot))


# Traceback (UnicodeDecodeError)
Task exception was never retrieved
future: <Task finished coro=<RepoManager._load_repos() done, defined at /home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py:618> exception=UnicodeDecodeError('utf-8', b"\x01D\xc79\x12b\x9e\xd6\xa4\xb8\x13\x93TDR \xe3w\xd3@\xc4H$H=2\x0e48\xac\xa6V\xb2\xb3\x19\x1cu\xe9\xed\xae'\xac\xb2\xe7!j\xc7^\xb1\xca\xe2\xa6\xd8\xa8\x9e\xd8\xad\x95\xe6\xa7v)\x9a\x81\xef\xdc\xa2h\x9c~\xba&amp;\xc6G\x1d\x1c\x80\xc3\x10\xd7\xda\x96\xc7\x885$\xc0,\xb3\x12\x18\x89\xec\xb5\xa9e\x8ax1\x91\xc7\\\xa2\x04\x879\x14\xc3\x8a\xcaek*\xda\x9d\xda&amp;\xc6G\x1dL\x01\x92\xc6G\x1dr\x89\xa2r:$z", 2, 3, 'invalid continuation byte')>
Traceback (most recent call last):
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 621, in _load_repos
ret[folder.stem] = await Repo.from_folder(folder)
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 487, in from_folder
repo._update_available_modules()
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 153, in _update_available_modules
curr_modules.append(Installable(location=self.folder_path / name))
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/installable.py", line 68, in __init__
super().__init__(location)
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/json_mixins.py", line 18, in __init__
self._read_info_file()
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/installable.py", line 125, in _read_info_file
super()._read_info_file()
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/json_mixins.py", line 28, in _read_info_file
info = json.load(f)
File "/usr/lib/python3.6/json/__init__.py", line 296, in load
return loads(fp.read(),
File "/home/aikaterna/v3/lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 2: invalid continuation byte

# Fixed code
async def setup(bot):
    cog = Downloader(bot)
    await cog.initialize()
    bot.add_cog(cog)
# Buggy code
def validate_and_normalize_repo_name(name: str) -> str:
    if not name.isidentifier():
        raise InvalidRepoName("Not a valid Python variable name.")
    return name.lower()


# Traceback (UnicodeDecodeError)
Task exception was never retrieved
future: <Task finished coro=<RepoManager._load_repos() done, defined at /home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py:618> exception=UnicodeDecodeError('utf-8', b"\x01D\xc79\x12b\x9e\xd6\xa4\xb8\x13\x93TDR \xe3w\xd3@\xc4H$H=2\x0e48\xac\xa6V\xb2\xb3\x19\x1cu\xe9\xed\xae'\xac\xb2\xe7!j\xc7^\xb1\xca\xe2\xa6\xd8\xa8\x9e\xd8\xad\x95\xe6\xa7v)\x9a\x81\xef\xdc\xa2h\x9c~\xba&amp;\xc6G\x1d\x1c\x80\xc3\x10\xd7\xda\x96\xc7\x885$\xc0,\xb3\x12\x18\x89\xec\xb5\xa9e\x8ax1\x91\xc7\\\xa2\x04\x879\x14\xc3\x8a\xcaek*\xda\x9d\xda&amp;\xc6G\x1dL\x01\x92\xc6G\x1dr\x89\xa2r:$z", 2, 3, 'invalid continuation byte')>
Traceback (most recent call last):
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 621, in _load_repos
ret[folder.stem] = await Repo.from_folder(folder)
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 487, in from_folder
repo._update_available_modules()
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 153, in _update_available_modules
curr_modules.append(Installable(location=self.folder_path / name))
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/installable.py", line 68, in __init__
super().__init__(location)
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/json_mixins.py", line 18, in __init__
self._read_info_file()
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/installable.py", line 125, in _read_info_file
super()._read_info_file()
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/json_mixins.py", line 28, in _read_info_file
info = json.load(f)
File "/usr/lib/python3.6/json/__init__.py", line 296, in load
return loads(fp.read(),
File "/home/aikaterna/v3/lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 2: invalid continuation byte

# Fixed code
def validate_and_normalize_repo_name(name: str) -> str:
    if not name.isidentifier():
        raise errors.InvalidRepoName("Not a valid Python variable name.")
    return name.lower()
# Buggy code
async def delete_repo(self, name: str):
    """Delete a repository and its folders.

    Parameters
    ----------
    name : str
        The name of the repository to delete.

    Raises
    ------
    MissingGitRepo
        If the repo does not exist.

    """
    repo = self.get_repo(name)
    if repo is None:
        raise MissingGitRepo("There is no repo with the name {}".format(name))

    safe_delete(repo.folder_path)

    try:
        del self._repos[name]
    except KeyError:
        pass


# Traceback (UnicodeDecodeError)
Task exception was never retrieved
future: <Task finished coro=<RepoManager._load_repos() done, defined at /home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py:618> exception=UnicodeDecodeError('utf-8', b"\x01D\xc79\x12b\x9e\xd6\xa4\xb8\x13\x93TDR \xe3w\xd3@\xc4H$H=2\x0e48\xac\xa6V\xb2\xb3\x19\x1cu\xe9\xed\xae'\xac\xb2\xe7!j\xc7^\xb1\xca\xe2\xa6\xd8\xa8\x9e\xd8\xad\x95\xe6\xa7v)\x9a\x81\xef\xdc\xa2h\x9c~\xba&amp;\xc6G\x1d\x1c\x80\xc3\x10\xd7\xda\x96\xc7\x885$\xc0,\xb3\x12\x18\x89\xec\xb5\xa9e\x8ax1\x91\xc7\\\xa2\x04\x879\x14\xc3\x8a\xcaek*\xda\x9d\xda&amp;\xc6G\x1dL\x01\x92\xc6G\x1dr\x89\xa2r:$z", 2, 3, 'invalid continuation byte')>
Traceback (most recent call last):
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 621, in _load_repos
ret[folder.stem] = await Repo.from_folder(folder)
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 487, in from_folder
repo._update_available_modules()
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/repo_manager.py", line 153, in _update_available_modules
curr_modules.append(Installable(location=self.folder_path / name))
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/installable.py", line 68, in __init__
super().__init__(location)
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/json_mixins.py", line 18, in __init__
self._read_info_file()
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/installable.py", line 125, in _read_info_file
super()._read_info_file()
File "/home/aikaterna/v3/lib/python3.6/site-packages/redbot/cogs/downloader/json_mixins.py", line 28, in _read_info_file
info = json.load(f)
File "/usr/lib/python3.6/json/__init__.py", line 296, in load
return loads(fp.read(),
File "/home/aikaterna/v3/lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 2: invalid continuation byte

# Fixed code
async def delete_repo(self, name: str):
    """Delete a repository and its folders.

    Parameters
    ----------
    name : str
        The name of the repository to delete.

    Raises
    ------
    .MissingGitRepo
        If the repo does not exist.

    """
    repo = self.get_repo(name)
    if repo is None:
        raise errors.MissingGitRepo("There is no repo with the name {}".format(name))

    safe_delete(repo.folder_path)

    try:
        del self._repos[name]
    except KeyError:
        pass
# Buggy code
async def is_alias(
    self,
    guild: discord.Guild,
    alias_name: str,
    server_aliases: Iterable[AliasEntry] = (),
) -> (bool, AliasEntry):
    if not server_aliases:
        server_aliases = await self.unloaded_aliases(guild)

    global_aliases = await self.unloaded_global_aliases()

    for aliases in (server_aliases, global_aliases):
        for alias in aliases:
            if alias.name == alias_name:
                return True, alias

    return False, None


# Traceback (AttributeError)
[19/08/2018 19:47] ERROR events on_error 181: Exception in on_command_error
Traceback (most recent call last):
File "/home/tobyh/PycharmProjects/Red-DiscordBot/.venv/src/discord.py/discord/client.py", line 220, in _run_event
await coro(*args, **kwargs)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/events.py", line 234, in on_command_error
fuzzy_result = await fuzzy_command_search(ctx, ctx.invoked_with)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/utils/__init__.py", line 52, in fuzzy_command_search
is_alias, alias = await alias_cog.is_alias(ctx.guild, term)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/cogs/alias/alias.py", line 60, in is_alias
server_aliases = await self.unloaded_aliases(guild)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/cogs/alias/alias.py", line 41, in unloaded_aliases
return (AliasEntry.from_json(d) for d in (await self._aliases.guild(guild).entries()))
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/config.py", line 761, in guild
return self._get_base_group(self.GUILD, guild.id)
AttributeError: 'NoneType' object has no attribute 'id'

# Fixed code
async def is_alias(
    self,
    guild: Optional[discord.Guild],
    alias_name: str,
    server_aliases: Iterable[AliasEntry] = (),
) -> Tuple[bool, Optional[AliasEntry]]:
    if not server_aliases and guild is not None:
        server_aliases = await self.unloaded_aliases(guild)

    global_aliases = await self.unloaded_global_aliases()

    for aliases in (server_aliases, global_aliases):
        for alias in aliases:
            if alias.name == alias_name:
                return True, alias

    return False, None
# Buggy code
def pm_check(self, ctx):
    return isinstance(ctx.channel, discord.DMChannel)


# Traceback (AttributeError)
[19/08/2018 19:47] ERROR events on_error 181: Exception in on_command_error
Traceback (most recent call last):
File "/home/tobyh/PycharmProjects/Red-DiscordBot/.venv/src/discord.py/discord/client.py", line 220, in _run_event
await coro(*args, **kwargs)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/events.py", line 234, in on_command_error
fuzzy_result = await fuzzy_command_search(ctx, ctx.invoked_with)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/utils/__init__.py", line 52, in fuzzy_command_search
is_alias, alias = await alias_cog.is_alias(ctx.guild, term)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/cogs/alias/alias.py", line 60, in is_alias
server_aliases = await self.unloaded_aliases(guild)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/cogs/alias/alias.py", line 41, in unloaded_aliases
return (AliasEntry.from_json(d) for d in (await self._aliases.guild(guild).entries()))
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/config.py", line 761, in guild
return self._get_base_group(self.GUILD, guild.id)
AttributeError: 'NoneType' object has no attribute 'id'

# Fixed code
def pm_check(ctx):
    return isinstance(ctx.channel, discord.DMChannel)
# Buggy code
def _add_subcommands(self, cmds):
    entries = ""
    for name, command in cmds:
        if name in command.aliases:
            # skip aliases
            continue

        if self.is_cog() or self.is_bot():
            name = "{0}{1}".format(self.clean_prefix, name)

        entries += "**{0}**   {1}\n".format(name, command.short_doc)
    return entries


# Traceback (AttributeError)
[19/08/2018 19:47] ERROR events on_error 181: Exception in on_command_error
Traceback (most recent call last):
File "/home/tobyh/PycharmProjects/Red-DiscordBot/.venv/src/discord.py/discord/client.py", line 220, in _run_event
await coro(*args, **kwargs)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/events.py", line 234, in on_command_error
fuzzy_result = await fuzzy_command_search(ctx, ctx.invoked_with)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/utils/__init__.py", line 52, in fuzzy_command_search
is_alias, alias = await alias_cog.is_alias(ctx.guild, term)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/cogs/alias/alias.py", line 60, in is_alias
server_aliases = await self.unloaded_aliases(guild)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/cogs/alias/alias.py", line 41, in unloaded_aliases
return (AliasEntry.from_json(d) for d in (await self._aliases.guild(guild).entries()))
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/config.py", line 761, in guild
return self._get_base_group(self.GUILD, guild.id)
AttributeError: 'NoneType' object has no attribute 'id'

# Fixed code
def _add_subcommands(self, cmds):
    entries = ""
    for name, command in cmds:
        if name in command.aliases:
            # skip aliases
            continue

        if self.is_cog() or self.is_bot():
            name = "{0}{1}".format(self.context.clean_prefix, name)

        entries += "**{0}**   {1}\n".format(name, command.short_doc)
    return entries
# Buggy code
def get_ending_note(self):
    # command_name = self.context.invoked_with
    return (
        "Type {0}help <command> for more info on a command.\n"
        "You can also type {0}help <category> for more info on a category.".format(
            self.clean_prefix
        )
    )


# Traceback (AttributeError)
[19/08/2018 19:47] ERROR events on_error 181: Exception in on_command_error
Traceback (most recent call last):
File "/home/tobyh/PycharmProjects/Red-DiscordBot/.venv/src/discord.py/discord/client.py", line 220, in _run_event
await coro(*args, **kwargs)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/events.py", line 234, in on_command_error
fuzzy_result = await fuzzy_command_search(ctx, ctx.invoked_with)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/utils/__init__.py", line 52, in fuzzy_command_search
is_alias, alias = await alias_cog.is_alias(ctx.guild, term)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/cogs/alias/alias.py", line 60, in is_alias
server_aliases = await self.unloaded_aliases(guild)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/cogs/alias/alias.py", line 41, in unloaded_aliases
return (AliasEntry.from_json(d) for d in (await self._aliases.guild(guild).entries()))
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/config.py", line 761, in guild
return self._get_base_group(self.GUILD, guild.id)
AttributeError: 'NoneType' object has no attribute 'id'

# Fixed code
def get_ending_note(self):
    # command_name = self.context.invoked_with
    return (
        "Type {0}help <command> for more info on a command.\n"
        "You can also type {0}help <category> for more info on a category.".format(
            self.context.clean_prefix
        )
    )
# Buggy code
def group_fields(self, fields: List[EmbedField], max_chars=1000):
    curr_group = []
    ret = []
    for f in fields:
        curr_group.append(f)
        if sum(len(f.value) for f in curr_group) > max_chars:
            ret.append(curr_group)
            curr_group = []

    if len(curr_group) > 0:
        ret.append(curr_group)

    return ret


# Traceback (AttributeError)
[19/08/2018 19:47] ERROR events on_error 181: Exception in on_command_error
Traceback (most recent call last):
File "/home/tobyh/PycharmProjects/Red-DiscordBot/.venv/src/discord.py/discord/client.py", line 220, in _run_event
await coro(*args, **kwargs)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/events.py", line 234, in on_command_error
fuzzy_result = await fuzzy_command_search(ctx, ctx.invoked_with)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/utils/__init__.py", line 52, in fuzzy_command_search
is_alias, alias = await alias_cog.is_alias(ctx.guild, term)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/cogs/alias/alias.py", line 60, in is_alias
server_aliases = await self.unloaded_aliases(guild)
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/cogs/alias/alias.py", line 41, in unloaded_aliases
return (AliasEntry.from_json(d) for d in (await self._aliases.guild(guild).entries()))
File "/home/tobyh/PycharmProjects/Red-DiscordBot/redbot/core/config.py", line 761, in guild
return self._get_base_group(self.GUILD, guild.id)
AttributeError: 'NoneType' object has no attribute 'id'

# Fixed code
def group_fields(fields: List[EmbedField], max_chars=1000):
    curr_group = []
    ret = []
    for f in fields:
        curr_group.append(f)
        if sum(len(f.value) for f in curr_group) > max_chars:
            ret.append(curr_group)
            curr_group = []

    if len(curr_group) > 0:
        ret.append(curr_group)

    return ret
# Buggy code
async def cc_command(self, ctx, *cc_args, raw_response, **cc_kwargs) -> None:
    cc_args = (*cc_args, *cc_kwargs.values())
    results = re.findall(r"\{([^}]+)\}", raw_response)
    for result in results:
        param = self.transform_parameter(result, ctx.message)
        raw_response = raw_response.replace("{" + result + "}", param)
    results = re.findall(r"\{((\d+)[^\.}]*(\.[^:}]+)?[^}]*)\}", raw_response)
    low = min(int(result[1]) for result in results)
    for result in results:
        index = int(result[1]) - low
        arg = self.transform_arg(result[0], result[2], cc_args[index])
        raw_response = raw_response.replace("{" + result[0] + "}", arg)
    await ctx.send(raw_response)


# Traceback (ValueError)
[09/09/2018 14:13] ERROR events on_error 182: Exception in message
Traceback (most recent call last):
File "/home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/discord/client.py", line 221, in _run_event
await coro(*args, **kwargs)
File "/home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/redbot/cogs/customcom/customcom.py", line 325, in on_message
await self.call_cc_command(ctx, raw_response, message)
File "/home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/redbot/cogs/customcom/customcom.py", line 334, in call_cc_command
await self.cc_command(*ctx.args, **ctx.kwargs, raw_response=raw_response)
File "/home/tobyh/Red-DiscordBot/.venv/lib/python3.7/site-packages/redbot/cogs/customcom/customcom.py", line 352, in cc_command
low = min(int(result[1]) for result in results)
ValueError: min() arg is an empty sequence

# Fixed code
async def cc_command(self, ctx, *cc_args, raw_response, **cc_kwargs) -> None:
    cc_args = (*cc_args, *cc_kwargs.values())
    results = re.findall(r"\{([^}]+)\}", raw_response)
    for result in results:
        param = self.transform_parameter(result, ctx.message)
        raw_response = raw_response.replace("{" + result + "}", param)
    results = re.findall(r"\{((\d+)[^\.}]*(\.[^:}]+)?[^}]*)\}", raw_response)
    if results:
        low = min(int(result[1]) for result in results)
        for result in results:
            index = int(result[1]) - low
            arg = self.transform_arg(result[0], result[2], cc_args[index])
            raw_response = raw_response.replace("{" + result[0] + "}", arg)
    await ctx.send(raw_response)
# Buggy code
def _initialize(**kwargs):
    host = kwargs["HOST"]
    port = kwargs["PORT"]
    admin_user = kwargs["USERNAME"]
    admin_pass = kwargs["PASSWORD"]
    db_name = kwargs.get("DB_NAME", "default_db")

    if admin_user is not None and admin_pass is not None:
        url = "mongodb://{}:{}@{}:{}/{}".format(
            admin_user, admin_pass, host, port, db_name
        )
    else:
        url = "mongodb://{}:{}/{}".format(host, port, db_name)

    global _conn
    _conn = motor.motor_asyncio.AsyncIOMotorClient(url)


# Traceback (pymongo.errors.InvalidURI)
Traceback (most recent call last):
File "/home/zephyrkul/.pyenv/versions/red/bin/redbot", line 11, in <module>
load_entry_point('Red-DiscordBot==3.0.0b20', 'console_scripts', 'redbot')()
File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/__main__.py", line 131, in main
red = Red(cli_flags=cli_flags, description=description, pm_help=None)
File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/bot.py", line 42, in __init__
self.db = Config.get_core_conf(force_registration=True)
File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/config.py", line 579, in get_core_conf
driver_name, "Core", "0", data_path_override=core_path, **driver_details
File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/drivers/__init__.py", line 32, in get_driver
return Mongo(*args, **kwargs)
File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/drivers/red_mongo.py", line 35, in __init__
_initialize(**kwargs)
File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/redbot/core/drivers/red_mongo.py", line 23, in _initialize
_conn = motor.motor_asyncio.AsyncIOMotorClient(url)
File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/motor/core.py", line 141, in __init__
delegate = self.__delegate_class__(*args, **kwargs)
File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/pymongo/mongo_client.py", line 494, in __init__
res = uri_parser.parse_uri(entity, port, warn=True)
File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/pymongo/uri_parser.py", line 379, in parse_uri
user, passwd = parse_userinfo(userinfo)
File "/home/zephyrkul/.pyenv/versions/red/lib/python3.7/site-packages/pymongo/uri_parser.py", line 97, in parse_userinfo
"RFC 3986, use %s()." % quote_fn)
pymongo.errors.InvalidURI: Username and password must be escaped according to RFC 3986, use urllib.parse.quote_plus().

# Fixed code
def _initialize(**kwargs):
    host = kwargs["HOST"]
    port = kwargs["PORT"]
    admin_user = kwargs["USERNAME"]
    admin_pass = kwargs["PASSWORD"]
    db_name = kwargs.get("DB_NAME", "default_db")

    if admin_user is not None and admin_pass is not None:
        url = "mongodb://{}:{}@{}:{}/{}".format(
            quote_plus(admin_user), quote_plus(admin_pass), host, port, db_name
        )
    else:
        url = "mongodb://{}:{}/{}".format(host, port, db_name)

    global _conn
    _conn = motor.motor_asyncio.AsyncIOMotorClient(url)
# Buggy code
def get_stream(self, _class, name):
    for stream in self.streams:
        # if isinstance(stream, _class) and stream.name == name:
        #    return stream
        # Reloading this cog causes an issue with this check ^
        # isinstance will always return False
        # As a workaround, we'll compare the class' name instead.
        # Good enough.
        if _class.__name__ == "YoutubeStream" and stream.type == _class.__name__:
            # Because name could be a username or a channel id
            if self.check_name_or_id(name) and stream.name.lower() == name.lower():
                return stream
            elif not self.check_name_or_id(name) and stream.id == name:
                return stream
        if stream.type == _class.__name__ and stream.name.lower() == name.lower():
            return stream


# Traceback (AttributeError)
Exception during loading of cog
Traceback (most recent call last):
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\redbot\core\core_commands.py", line 87, in _load
await bot.load_extension(spec)
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\redbot\core\bot.py", line 222, in load_extension
await lib.setup(self)
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\redbot\cogs\streams\__init__.py", line 6, in setup
await cog.initialize()
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\redbot\cogs\streams\streams.py", line 71, in initialize
self.streams = await self.load_streams()
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\redbot\cogs\streams\streams.py", line 618, in load_streams
return [x for x in streams if not (x.name.lower() in seen or seen_add(x.name.lower()))]
File "C:\Users\jason\AppData\Local\Programs\Python\Python36\lib\site-packages\redbot\cogs\streams\streams.py", line 618, in <listcomp>
return [x for x in streams if not (x.name.lower() in seen or seen_add(x.name.lower()))]
AttributeError: 'NoneType' object has no attribute 'lower'

# Fixed code
def get_stream(self, _class, name):
    for stream in self.streams:
        # if isinstance(stream, _class) and stream.name == name:
        #    return stream
        # Reloading this cog causes an issue with this check ^
        # isinstance will always return False
        # As a workaround, we'll compare the class' name instead.
        # Good enough.
        if _class.__name__ == "YoutubeStream" and stream.type == _class.__name__:
            # Because name could be a username or a channel id
            if self.check_name_or_id(name) and stream.name.lower() == name.lower():
                return stream
            elif not self.check_name_or_id(name) and stream.id == name:
                return stream
        elif stream.type == _class.__name__ and stream.name.lower() == name.lower():
            return stream