我如何制作多个帮助命令,例如help <fun>,help <music>等

时间:2019-01-17 23:33:51

标签: python python-3.x discord discord.py

所以我有一个help命令,我也有一个help_fun命令。

我想做的是,当使用者说d-help时,机器人应显示help命令输出,但是当使用者说d-help fun时机器人应显示{{ 1}}命令输出。

当对方说help_fun时,它仍然显示d-help fun

help

3 个答案:

答案 0 :(得分:1)

您可以使用Group将命令组织成子命令

setFormula

然后您可以调用setFormulaR1C1

答案 1 :(得分:0)

从两个帮助命令中删除@client.command(),并在检测到d-helpd-help fun关键字时将它们作为普通的异步函数调用。
这样,您可以无限扩展您的帮助命令,并拥有任意数量的

client.remove_command('help')
@client.event
async def on_message(message):
  if message.content.startswith("d-help fun"):
    await help_fun(message.channel)
  elif message.content.startswith("d-help"):
    await help(message.channel)


async def help(channel):
  embed = discord.Embed(
      title = ' Thanks for using my bot',url="http://wq.lt/UwBrZ",
      description = "➺ This bot is currently in beta. More commands will be added soon.",
      colour = 0x0af78a
  )

  embed.set_author(name='Help',icon_url='https://cdn2.iconfinder.com/data/icons/app-types-in-grey/512/info_512pxGREY.png')
  embed.set_footer(text="Say d-help fun | admin | server | music, for the commands")
  embed.set_image(url='')
  embed.set_thumbnail(url='https://i.imgur.com/9Y04G7u.png')

  embed.add_field(name= "Music", value="4 Music commands", inline=True)
  embed.add_field(name= "Server", value="5 Server commands", inline=True)
  embed.add_field(name= "Admin", value="5 Admin commands", inline=True)
  embed.add_field(name= "Fun", value="20 Fun commands", inline=True)
  await client.send_message(channel,embed=embed)

async def help_fun(channel):
  embed = discord.Embed(
      title =None,#' Thanks for using my bot',url="http://wq.lt/UwBrZ",
      description = "➺ This bot is currently in beta. More commands will be added soon.",
      colour = 0x0af78a
  )

  embed.set_author(name='Fun commands',icon_url='https://i.imgur.com/9Y04G7u.png')
  embed.set_footer(text="Bot still in beta and more commands are being added")
  embed.set_image(url='')
  embed.add_field(name= "═─────────────────═", value='d-say <text>\nd-type <text>\nd-tts <text>\nd-timer <Number>\nd-embed <text>\nd-embed2 <text>\nembed3 <text>\nd-joke\nd-invite\nd-8ball\nd-flip <word>\nd-color <hex>\nd-ping\nd-dice\nd-fancytext <text>\nd-shorten <link>\nd-unshorten\nd-uni <:emoji:>\nd-define <word>\nd-chatters', inline=False)
  await client.send_message(channel,embed=embed)

答案 2 :(得分:0)

我添加了useEffect(() => { console.log(selected) }, [selected]) useEffect(() => { console.log(pageTitle) }, [pageTitle]) 来检查"server": { "builder": "@angular-devkit/build-angular:server", "options": { "outputPath": "dist/market-web/server", "main": "server.ts", "tsConfig": "tsconfig.server.json", "externalDependencies": [ "@firebase/app", "@firebase/firestore" ] }, ..... 附带的字符串,如果没有,则将name:str=None等同于d-help,显示原始name页。在这里,您可以添加另一个None来添加新命令的帮助页面。

help