mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 01:42:30 -05:00
* add commands, cog converter
* properly use type_checking
* make core commands use command converter
* update commands to use cogconverter
* fix undefined variable name, style
* Update redbot/core/commands/converter.py
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
* Update redbot/core/commands/converter.py
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
* Update redbot/core/core_commands.py
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
* Update redbot/core/core_commands.py
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
* Update redbot/core/core_commands.py
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
* Update redbot/core/core_commands.py
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
* Update redbot/core/core_commands.py
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
* update cog argument names
* update documentation arg names
* update more docs
* This new Sphinx is annoying about this...
* I'm questioning my skills
* Fix name error in `[p]embedset showsettings` when command is not given
* Do not use the new cog converter in `[p]command enablecog`
This is needed so that a cog that isn't loaded but was disabled
can be enabled back.
(cherry picked from commit e5b236fb1c)
Co-authored-by: PhenoM4n4n <61065078+phenom4n4n@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
Co-authored-by: PhenoM4n4n <61065078+phenom4n4n@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
@@ -42,6 +42,8 @@ __all__ = [
|
||||
"get_timedelta_converter",
|
||||
"parse_timedelta",
|
||||
"Literal",
|
||||
"CommandConverter",
|
||||
"CogConverter",
|
||||
]
|
||||
|
||||
_ = Translator("commands.converter", __file__)
|
||||
@@ -416,3 +418,29 @@ if not TYPE_CHECKING:
|
||||
return cls(k)
|
||||
else:
|
||||
return cls((k,))
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
CommandConverter = dpy_commands.Command
|
||||
CogConverter = dpy_commands.Cog
|
||||
else:
|
||||
|
||||
class CommandConverter(dpy_commands.Converter):
|
||||
"""Converts a command name to the matching `redbot.core.commands.Command` object."""
|
||||
|
||||
async def convert(self, ctx: "Context", argument: str):
|
||||
arg = argument.strip()
|
||||
command = ctx.bot.get_command(arg)
|
||||
if not command:
|
||||
raise BadArgument(_('Command "{arg}" not found.').format(arg=arg))
|
||||
return command
|
||||
|
||||
class CogConverter(dpy_commands.Converter):
|
||||
"""Converts a cog name to the matching `redbot.core.commands.Cog` object."""
|
||||
|
||||
async def convert(self, ctx: "Context", argument: str):
|
||||
arg = argument.strip()
|
||||
cog = ctx.bot.get_cog(arg)
|
||||
if not cog:
|
||||
raise BadArgument(_('Cog "{arg}" not found.').format(arg=arg))
|
||||
return cog
|
||||
|
||||
Reference in New Issue
Block a user