user10873241
user10873241

Reputation:

How can i make multiple help commands like help <fun>, help <music> etc

So I've got a help command and I've also made a help_fun command.

What I'm trying to do is that when the person says d-help, the bot should show the help command output but when the person says d-help fun it should show the help_fun command output.

When the person says d-help fun it still shows thehelp instead

import discord
from discord.ext import commands
client = commands.Bot(command_prefix='d-')
client.remove_command('help')
@client.event
async def on_ready():
    print('Ready')

@client.command(pass_context=True,aliases=['HELP','Help','Dartex help','hp','hlp'])
async def help():
    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='d-play <YT link>\nd-stop\nd-pause\nd-resume', inline=False)
    #embed.add_field(name= "-Fun", 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)
    #embed.add_field(name= "-Admin", value="d-ban\nd-banned\nd-clear <Number>\nd-kick <@user>\nd-create_dgc", inline=True)
    #embed.add_field(name= "-Server", value="d-serverinfo\nd-serverlist\nd-roles\nd-emotes\nd-userinfo <@user>", inline=True)
    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.say(embed=embed)
@client.command(pass_context=True,aliases=['help fun','Help Fun','Help fun'])
async def help_fun():
    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.set_thumbnail(url='https://i.imgur.com/9Y04G7u.png')
    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.say(embed=embed)

Upvotes: 0

Views: 943

Answers (3)

SkullBlazer
SkullBlazer

Reputation: 11

I added a name:str=None which checks for a string provided with the d-help, and if there isn't, it equates name to None, which displays the original help page. Here, you can add another elif for adding a help page for a new command.

import discord
from discord.ext import commands
client = commands.Bot(command_prefix='d-')
client.remove_command('help')

@client.event
async def on_ready():
    print('Ready')

@client.command(pass_context=True,aliases=['HELP','Help','Dartex help','hp','hlp'])
async def help(ctx, name:str = None):
    if name is None:
        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)
    elif name.lower() == "fun":
        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)

Upvotes: 0

Patrick Haugh
Patrick Haugh

Reputation: 61042

You can use a Group to organize commands into subcommands

bot = Bot('.')

bot.remove_command('help')

@bot.group(invoke_without_command=True)  # Change this to false to always run main command
async def help():
    pass

@help.command()
async def music():
    await bot.say("Music is music")

@help.command()
async def fun():
    await bot.say("Fun is strictly prohibited")

Then you can invoke .help fun, etc

Upvotes: 2

Tristo
Tristo

Reputation: 2398

Remove the @client.command() from both of your help commands and call them as normal async functions when you detect d-help or d-help fun keywords.
This way you can indefinitely expand your help commands and have as many as you'd like

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)

Upvotes: 0

Related Questions