#๐ Why is there a help command eventho I never declared it?
49 messages ยท Page 1 of 1 (latest)
@jaunty kettle
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.
This is my file structure
It's one of the built-ins. Same as list, str, int, tuple, open.
You can find all of them documented here: https://docs.python.org/3/library/functions.html
Oh
I ment a help command
In my discord bot
I never made this command
That's different. Sorry I missed your post tag ๐
Well, what bot code are you using? Perhaps it's written somewhere in there?
Isn't that via doc string or is that something different?
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
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
Same misconception I had, they have a .help command in their bot and wonder why.
I don't understand. What does the help function have to do here?
oh
I don't know how python -> discord works so I have no idea how the commands are formatted or where it's coming from
Discord.py bots are created with a help command by default which you can hook into or disable
How do I do that?
Depends entirely on the package they're using. Python is just the language the bot code is written in, but the library (either discord.py or nextcord or whatever) makes API calls out to Discord as needed to make those commands run.
I'm assuming the Discord bot dev framework you're using is discord.py
Ye, it is! I sent the code above.
Anyway it's a keyword argument in the bot constructor
Although "can be dynamically set at runtime"
https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/bot.py#L203
There it is. Spot in the code where it's added by default.
discord/ext/commands/bot.py line 203
self.help_command = DefaultHelpCommand()```
So you can give the bot a different help_command, providing some subclass of the HelpCommand class, to override this behavior.
If you're going that route you should read https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#ext-commands-help-command
Are there other routes?
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
Oh yea
That's what I was gonna do but then I noticed that there's already a help, or a 'usuer manual' command.
To make it look nicer
Because this isn't too user friendly, if you ask me
You can customize appearances even if you subclass from HelpCommand
Is subclass the same as child class?
Where a new class inherits stuff from another class
It's just the DefaultHelpCommand which displays things this way
Ye
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.