def _help(self, msg):
if not self.categories:
await self.build_help()
try:
search = msg.clean_content.split(" ")[1].lower()
except IndexError:
cates = "\n".join(sorted([capwords(x, "_") for x in self.categories.keys()]))
await respond(msg, f"**ANALYSIS: Command categories:**```\n{cates}\n```")
return
if search in [x.lower() for x in self.commands.keys()]:
cmd = self.commands[search]
name = cmd.name
syn = cmd.syntax
if not syn:
syn = "N/A"
doc = cmd.__doc__
perms = cmd.perms
cate = capwords(cmd.category, "_")
aliases = f"(Aliases: {', '.join(cmd.aliases)})" if cmd.aliases else ""
if not {x for x, y in msg.author.guild_permissions if y} >= perms:
raise UserPermissionError
text = f"**ANALYSIS: Command {name}:**```\n{name} (Category {cate}) {aliases}\n\n{doc}\n\n" \
f"Syntax: {syn}\n```"
await respond(msg, text)
elif search in self.categories.keys():
name = capwords(search, "_")
userperms = {x for x, y in msg.author.guild_permissions if y}
cmds = {x.name for x in self.categories[search].values() if userperms >= x.perms}
cmds = sorted(list(cmds))
if cmds:
text = "\n".join(cmds)
await respond(msg, f"**ANALYSIS: Category {name}:**```\n{text}\n```")
else:
await respond(msg, "**WARNING: You do not have permission for any command in this category.**")
else:
await respond(msg, f"**WARNING: No such category or command {search}**")
评论列表
文章目录