mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-16 10:49:24 +00:00
[commands] Add BotBase.get_cog_commands to get all a cog's commands.
Self-explanatory. This should help create help commands for a cog more easily.
This commit is contained in:
parent
fe588a4d52
commit
54fdafb792
@ -484,6 +484,31 @@ class BotBase(GroupMixin):
|
|||||||
"""
|
"""
|
||||||
return self.cogs.get(name)
|
return self.cogs.get(name)
|
||||||
|
|
||||||
|
def get_cog_commands(self, name):
|
||||||
|
"""Gets a unique set of the cog's registered commands
|
||||||
|
without aliases.
|
||||||
|
|
||||||
|
If the cog is not found, an empty set is returned.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
------------
|
||||||
|
name: str
|
||||||
|
The name of the cog whose commands you are requesting.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
---------
|
||||||
|
Set[:class:`Command`]
|
||||||
|
A unique set of commands without aliases that belong
|
||||||
|
to the cog.
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
cog = self.cogs[name]
|
||||||
|
except KeyError:
|
||||||
|
return set()
|
||||||
|
|
||||||
|
return {c for c in self.all_commands.values() if c.instance is cog}
|
||||||
|
|
||||||
def remove_cog(self, name):
|
def remove_cog(self, name):
|
||||||
"""Removes a cog from the bot.
|
"""Removes a cog from the bot.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user