aboutsummaryrefslogtreecommitdiffstats
path: root/botcore/_bot.py
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-03-24 07:44:50 +0000
committerGravatar Chris Lovering <[email protected]>2022-03-24 08:25:27 +0000
commitb8a245061689c45ebee05f27481837576a079e54 (patch)
tree3fdc5c02c810cdb421b20ef5dda66114cb9091c1 /botcore/_bot.py
parentRemove unneeded kwargs in BotBase (diff)
Provide a bot.all_extensions instance attribute
This allows commands like extensions and source to see all of the available commands, rather than just the currently loaded commands.
Diffstat (limited to 'botcore/_bot.py')
-rw-r--r--botcore/_bot.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/botcore/_bot.py b/botcore/_bot.py
index f334631c..d740fe03 100644
--- a/botcore/_bot.py
+++ b/botcore/_bot.py
@@ -75,6 +75,8 @@ class BotBase(commands.Bot):
self.stats: Optional[AsyncStatsClient] = None
+ self.all_extensions: Optional[frozenset[str]] = None
+
def _connect_statsd(
self,
statsd_url: str,
@@ -104,8 +106,10 @@ class BotBase(commands.Bot):
self.closing_tasks: list[asyncio.Task] = []
async def load_extensions(self, module: types.ModuleType) -> None:
- """Load all the extensions within the given module."""
- for extension in walk_extensions(module):
+ """Load all the extensions within the given module and save them to ``self.all_extensions``."""
+ self.all_extensions = walk_extensions(module)
+
+ for extension in self.all_extensions:
await self.load_extension(extension)
def _add_root_aliases(self, command: commands.Command) -> None: