def add_phrase(self, phrase):
if(not isinstance(phrase, Phrase)):
raise TypeError("{} not instance of Phrase.".format(phrase))
## Manually build command to be added
command = commands.Command(
phrase.name,
self._create_phrase_callback(phrase.message, phrase.is_music),
**phrase.kwargs,
**self.command_kwargs
)
## _phrase_callback doesn't have an instance linked to it,
## (not technically a method of Phrases?) so manually insert the correct instance anyway.
## This also fixes the broken category label in the help page.
command.instance = self
self.bot.add_command(command)
## Build a dynamic callback to invoke the bot's say method
评论列表
文章目录