#๐Ÿ”’ Why is there a help command eventho I never declared it?

49 messages ยท Page 1 of 1 (latest)

jaunty kettle
#

I think a help command is set to be by default when you make a cog. How can I ammend it?

whole zodiacBOT
#

@jaunty kettle

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

jaunty kettle
#

This is my file structure

steady dagger
#

It's one of the built-ins. Same as list, str, int, tuple, open.

jaunty kettle
#

I ment a help command

#

In my discord bot

#

I never made this command

steady dagger
#

That's different. Sorry I missed your post tag ๐Ÿ™‚
Well, what bot code are you using? Perhaps it's written somewhere in there?

ornate holly
#

Isn't that via doc string or is that something different?

jaunty kettle
# steady dagger That's different. Sorry I missed your post tag ๐Ÿ™‚ Well, what bot code are you us...

import discord
import asyncio
from shlex import split
import random as rand
from time import sleep
from discord.ext import commands
from time import ctime
import os

bot = commands.Bot(command_prefix = ".", intents=discord.Intents.all())

@bot.event
async def on_ready():
    print(f"{ctime()} {bot.user} is running!")
    channel = bot.get_channel(1400546643970883735)
    await channel.send(f"`{ctime()}` {bot.user} is running ")


async def cog():
    for file in os.listdir('! discord\\cogs'):
        if "pycache" in file:
            print(f"Pycache ignored")
        else:
            await bot.load_extension(f"cogs.{file[:-3]}")
            print(f"loaded {file}")
asyncio.run(cog())


bot.run("") # env here

this is mybot.py which is basically main.py

ornate holly
#

I'm pretty sure help() gives you the doc string of a function if you have one and is built-in

#

Could be wrong though

steady dagger
jaunty kettle
#

I don't understand. What does the help function have to do here?

ornate holly
#

I don't know how python -> discord works so I have no idea how the commands are formatted or where it's coming from

buoyant flower
steady dagger
buoyant flower
#

I'm assuming the Discord bot dev framework you're using is discord.py

jaunty kettle
buoyant flower
#

Anyway it's a keyword argument in the bot constructor

#

Although "can be dynamically set at runtime"

steady dagger
whole zodiacBOT
#

discord/ext/commands/bot.py line 203

self.help_command = DefaultHelpCommand()```
steady dagger
#

So you can give the bot a different help_command, providing some subclass of the HelpCommand class, to override this behavior.

jaunty kettle
#

That's nice. Thanks for the help!

#

I'll give both of them a read

buoyant flower
buoyant flower
#

You could roll your own user manual command like any other command

#

But why would you when you can implement a subclass with standard behavior

jaunty kettle
#

Oh yea
That's what I was gonna do but then I noticed that there's already a help, or a 'usuer manual' command.

jaunty kettle
buoyant flower
#

You can customize appearances even if you subclass from HelpCommand

jaunty kettle
#

Where a new class inherits stuff from another class

buoyant flower
jaunty kettle
#

Okay

#

Thanks

#

!close

whole zodiacBOT
#
Python help channel closed with !close

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.