Skip to content
Discussion options

You must be logged in to vote

Hopefully this is helpful to someone else, but this is basically what I did to solve this:

import asyncio
import logging
from importlib import import_module
from inspect import isclass
from pathlib import Path
from pkgutil import iter_modules
from typing import TYPE_CHECKING

from discord.ext import commands
from discord.ext.commands import Bot

from mybot.cogs import FooCog
from mybot.cogs import BarCog
from mybot.cogs import BazCog
# ...

if TYPE_CHECKING:
    from mybot.client import MyBot

logger = logging.getLogger(__name__)

__all__ = [
    "FooCog",
    "BarCog",
    "BazCog",
    #...
]

async def load_all_cogs(bot: Bot) -> Bot:
    # iterate through the modules in the current pac…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@scarletcafe
Comment options

@lexicalunit
Comment options

@Rapptz
Comment options

@scarletcafe
Comment options

@lexicalunit
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by lexicalunit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants