aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-06-05 22:55:57 -0400
committerRapptz <[email protected]>2017-06-05 22:55:57 -0400
commit83dc93559ce9b4c01e213a3ee3b55381df1b087f (patch)
tree8aa092dcb32689ae269ff1824c276ade260098c5
parentFix AuditLogDiff.__iter__ to return an actual iterable. (diff)
downloaddiscord.py-83dc93559ce9b4c01e213a3ee3b55381df1b087f.tar.xz
discord.py-83dc93559ce9b4c01e213a3ee3b55381df1b087f.zip
[commands] Add docstrings for extension loading.
-rw-r--r--discord/ext/commands/bot.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py
index 01ea05dc..dc4aa21e 100644
--- a/discord/ext/commands/bot.py
+++ b/discord/ext/commands/bot.py
@@ -582,6 +582,30 @@ class BotBase(GroupMixin):
# extensions
def load_extension(self, name):
+ """Loads an extension.
+
+ An extension is a python module that contains commands, cogs, or
+ listeners.
+
+ An extension must have a global function, ``setup`` defined as
+ the entry point on what to do when the extension is loaded. This entry
+ point must have a single argument, the ``bot``.
+
+ Parameters
+ ------------
+ name: str
+ The extension name to load. It must be dot separated like
+ regular Python imports if accessing a sub-module. e.g.
+ ``foo.test`` if you want to import ``foo/test.py``.
+
+ Raises
+ --------
+ ClientException
+ The extension does not have a setup function.
+ ImportError
+ The extension could not be imported.
+ """
+
if name in self.extensions:
return
@@ -595,6 +619,24 @@ class BotBase(GroupMixin):
self.extensions[name] = lib
def unload_extension(self, name):
+ """Unloads an extension.
+
+ When the extension is unloaded, all commands, listeners, and cogs are
+ removed from the bot and the module is un-imported.
+
+ The extension can provide an optional global function, ``teardown``,
+ to do miscellaneous clean-up if necessary. This function takes a single
+ parameter, the ``bot``, similar to ``setup`` from
+ :func:`~.Bot.load_extension`.
+
+ Parameters
+ ------------
+ name: str
+ The extension name to unload. It must be dot separated like
+ regular Python imports if accessing a sub-module. e.g.
+ ``foo.test`` if you want to import ``foo/test.py``.
+ """
+
lib = self.extensions.get(name)
if lib is None:
return