lucandris
lucandris

Reputation: 46

Specific response per command

I'm making my help commands. I've already set up the "+help". When I was testing the "+help beg" command the output would be from the "+help" and not "+help beg". How could I make the bot respond with the "+help" output when there is only one word?

For context: I'm using cogs, the "+help" is my main.py & and the specific helps are in cogs, I made "+help beg" two words using aliases.

Upvotes: 0

Views: 49

Answers (2)

levi
levi

Reputation: 5

You can group your commands.
@commands.group(invoke_without_command=True) invoke_without_command means the first main command's output will not be shown.

This is an example:

    @commands.group(invoke_without_command=True)
    async def help(self, ctx):
       await ctx.send('This is the help message.')
    
    @help.command()
    async def beg(self, ctx):
       await ctx.send('This is help beg message.')

    @help.command()
    async def cat(self, ctx):
       await ctx.send('This is help cat message.')

With this code if you do +help beg you will get 'This is help beg message'. You can group as many as you like. You can read about it here.

Upvotes: 0

Cohen
Cohen

Reputation: 2415

An easy way of doing this would be taking the optional category and a parameter to pass with the help command. This would work by including an optional input after the help command, it would look like +help beg or +help [category], depending on how many you wish to make

If the optional parameter wasn’t passed, it would send just the help command with no category. When the user includes a provided category, it would send help with that category.

Here is an example

@commands.command()
async def help(self, ctx, category=None):
   if category == None:
       await ctx.channel.send('this is a help command')
       return
   if category == "beg":
       await ctx.channel.send('this is a beg and this is how to use it....')
       return
    if category == "bal":
       await ctx.channel.send('this is your bal..')
       return
    else:
       await ctx.channel.send('Please provide a valid category')
       return

Upvotes: 1

Related Questions