aboutsummaryrefslogtreecommitdiffstats
path: root/bot/utils/extensions.py
diff options
context:
space:
mode:
authorGravatar Xithrius <[email protected]>2022-11-02 02:07:29 -0700
committerGravatar GitHub <[email protected]>2022-11-02 02:07:29 -0700
commit43a2acf5ee4eb354ce3dfaeef9504eee9b9b46b4 (patch)
treecbdfeb08f8d582aa98acec6a529f0fa3dcd7933c /bot/utils/extensions.py
parentAppeased the formatter (diff)
parentMerge pull request #1137 from DivyanshuBist/bug-issue1122-message-of-type-None (diff)
Merge branch 'main' into main
Diffstat (limited to 'bot/utils/extensions.py')
-rw-r--r--bot/utils/extensions.py45
1 files changed, 0 insertions, 45 deletions
diff --git a/bot/utils/extensions.py b/bot/utils/extensions.py
deleted file mode 100644
index 09192ae2..00000000
--- a/bot/utils/extensions.py
+++ /dev/null
@@ -1,45 +0,0 @@
-import importlib
-import inspect
-import pkgutil
-from collections.abc import Iterator
-from typing import NoReturn
-
-from discord.ext.commands import Context
-
-from bot import exts
-
-
-def unqualify(name: str) -> str:
- """Return an unqualified name given a qualified module/package `name`."""
- return name.rsplit(".", maxsplit=1)[-1]
-
-
-def walk_extensions() -> Iterator[str]:
- """Yield extension names from the bot.exts subpackage."""
-
- def on_error(name: str) -> NoReturn:
- raise ImportError(name=name) # pragma: no cover
-
- for module in pkgutil.walk_packages(exts.__path__, f"{exts.__name__}.", onerror=on_error):
- if unqualify(module.name).startswith("_"):
- # Ignore module/package names starting with an underscore.
- continue
-
- if module.ispkg:
- imported = importlib.import_module(module.name)
- if not inspect.isfunction(getattr(imported, "setup", None)):
- # If it lacks a setup function, it's not an extension.
- continue
-
- yield module.name
-
-
-async def invoke_help_command(ctx: Context) -> None:
- """Invoke the help command or default help command if help extensions is not loaded."""
- if "bot.exts.core.help" in ctx.bot.extensions:
- help_command = ctx.bot.get_command("help")
- await ctx.invoke(help_command, ctx.command.qualified_name)
- return
- await ctx.send_help(ctx.command)
-
-EXTENSIONS = frozenset(walk_extensions())