Skip to content

Commit 492a3ec

Browse files
committed
Some extra docs and license info.
1 parent 577c2d2 commit 492a3ec

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

twitchio/ext/commands/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
"""
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2017-2021 TwitchIO
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a
7+
copy of this software and associated documentation files (the "Software"),
8+
to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
and/or sell copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22+
DEALINGS IN THE SOFTWARE.
23+
"""
24+
125
from .bot import Bot
226
from .core import *
327
from .errors import *

twitchio/ext/commands/bot.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,13 @@ def load_module(self, name: str):
284284
self._modules[name] = module
285285

286286
def unload_module(self, name: str):
287+
"""Method which unloads a module and it's cogs.
288+
289+
Parameters
290+
----------
291+
name: str
292+
The name of the module to unload in dot.path format.
293+
"""
287294
if name not in self._modules:
288295
raise ValueError(f"Module <{name}> is not loaded")
289296

@@ -308,6 +315,18 @@ def unload_module(self, name: str):
308315
del sys.modules[m]
309316

310317
def reload_module(self, name: str):
318+
"""Method which reloads a module and it's cogs.
319+
320+
Parameters
321+
----------
322+
name: str
323+
The name of the module to unload in dot.path format.
324+
325+
326+
.. note::
327+
328+
This is roughly equivalent to `bot.unload_module(...)` then `bot.load_module(...)`.
329+
"""
311330
if name not in self._modules:
312331
raise ValueError(f"Module <{name}> is not loaded")
313332

@@ -327,7 +346,19 @@ def reload_module(self, name: str):
327346
module.prepare(self)
328347
raise
329348

330-
def add_cog(self, cog):
349+
def add_cog(self, cog: Cog):
350+
"""Method which adds a cog to the bot.
351+
352+
Parameters
353+
----------
354+
cog: :class:`Cog`
355+
The cog instance to add to the bot.
356+
357+
358+
.. warning::
359+
360+
This must be an instance of :class:`Cog`.
361+
"""
331362
if not isinstance(cog, Cog):
332363
raise InvalidCog('Cogs must derive from "commands.Cog".')
333364

@@ -338,6 +369,13 @@ def add_cog(self, cog):
338369
self._cogs[cog.name] = cog
339370

340371
def remove_cog(self, cog_name: str):
372+
"""Method which removes a cog from the bot.
373+
374+
Parameters
375+
----------
376+
cog_name: str
377+
The name of the cog to remove.
378+
"""
341379
if cog_name not in self._cogs:
342380
raise InvalidCog(f"Cog '{cog_name}' not found")
343381

@@ -397,10 +435,12 @@ async def global_after_invoke(self, ctx):
397435

398436
@property
399437
def commands(self):
438+
"""The currently loaded commands."""
400439
return self._commands
401440

402441
@property
403442
def cogs(self):
443+
"""The currently loaded cogs."""
404444
return self._cogs
405445

406446
async def event_command_error(self, context, error):

twitchio/ext/commands/errors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525

2626
class TwitchCommandError(Exception):
27+
"""Base TwitchIO Command Error. All command errors derive from this error."""
28+
2729
pass
2830

2931

0 commit comments

Comments
 (0)