def execute(cmd, message: discord.Message, *args, **kwargs):
""" Execute a command specified by name, alias or command object.
This is really only useful as a shortcut for other commands.
:param cmd: either plugins.Command or str
:param message: required message object in order to execute a command
:param args, kwargs: any arguments passed into the command.
:raises: NameError when command does not exist.
"""
# Get the command object if the given command represents a name
if type(cmd) is not Command:
cmd = get_command(cmd, config.server_case_sensitive_commands(message.server))
try:
await cmd.function(message, *args, **kwargs)
except AttributeError:
raise NameError("{} is not a command".format(cmd))
评论列表
文章目录