Error in slash commands parameters when naming them UpperCamelCase or camelCase
Summary
When you put in a capital letter in one of the options for a .slash_command function, it doesn't run
Reproduction Steps
take the following:
async def hello(
ctx,
gamecode: Option(str, "Code to the game")
):
it runs fine
if you do this:
async def hello(
ctx,
GameCode: Option(str, "Code to the game")
):
it will not run. Here is the error
c:/Users/kingo/Documents/GitHub/MurderMoostery/SRC/Test.py
Ignoring exception in on_connect
Traceback (most recent call last):
File "C:\Users\kingo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py",
line 351, in _run_event
await coro(*args, **kwargs)
File "C:\Users\kingo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\bot.py", line 370, in on_connect
await self.register_commands()
File "C:\Users\kingo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\bot.py", line 196, in register_commands
cmds = await self.http.bulk_upsert_guild_commands(self.user.id, guild_id,
File "C:\Users\kingo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\http.py", line 335, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 0.options.0.name: Command name is invalid```
### Minimal Reproducible Code
```python
import discord
from discord.app import Option
bot = discord.Bot()
@bot.slash_command(description="Join game")
async def hello(
ctx,
Gamecode: Option(str, "Code to the game"),
):
await ctx.respond(f"Code: {GameCode}")
bot.run("token")
Expected Results
for it to run correctly with the rightly formatted capitalizations
Actual Results
it didn't run at all
Intents
none
System Information
I installed from GitHub with slashcommands branch, so it doesn't work and gives me an error when I run that. But I am using python 3.9.7 and using the latest version of the slash commands branch (just got today)
Checklist
- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.
Additional Context
No response
This is a discord limitation, you can't have capital letters in the option names :/
oh I see. Can you keep this issue open and/or add it to the FAQ? since I saw a lot of people having the same issue in the discord chat but they didn't figure it out.
@CodeWithSwastik then how about the option names be converted to lowercase before being sent to discord?
@CodeWithSwastik then how about the option names be converted to lowercase before being sent to discord?
That would cause even more confusion among users.
And we don't know when Discord changes it so we don't handle stuff that are subject to change anytime.
@nerdguyahmad That would cause even more confusion among users.
I disagree. Prevention of error and informing users who are confused by the lowercase that its a discord limitation seems like the better option. I think its more confusing to get an error that says the command name is invalid when its the option thats the problem.
I think we should convert it to lowercase and note in the documentation that it gets changed.
But @LilJess13, My second point was that it is subject to change anytime. Just like embed limitations that change often. e.g description changed from 2048 char limit to 4096.
Besides, That error shows that it's caused by Discord and not library.
Interesting point, but how about this:
If the error occurs then its caught by the library itself and sent into the logging module to get logged. If the error doesn't occur, then everything's fine
Interesting point, but how about this: If the error occurs then its caught by the library itself and sent into the
loggingmodule to get logged. If the error doesn't occur, then everything's fine
There're number of reasons HTTPException can occur. Same for Invalid command name error. And making an entirely different exception class for this is too much. Hence, I think it would be better if we leave it as is.
@nerdguyahmad That would cause even more confusion among users.
I disagree. Prevention of error and informing users who are confused by the lowercase that its a discord limitation seems like the better option.
I think its more confusing to get an error that says the command name is invalid when its the option thats the problem.
I agree. This is why I want the issue opened even though it's been solved. (I'm assuming) Many people (including myself) have been tripped up by this. So this will definitely help, or saying something when ran that says "no caps in command name!"
I'm thinking that there should be a seperate section in FAQ's, "Interactions & Application Commands" with frequently asked questions, like this one.
Closing as this is a Discord limitation and it's been almost 7 months.