'Nextcord Slash Command | nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body

I was migrating my bot from discord.py to nextcord and I changed my help command to a slash command, but it kept showing me this error:

nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body

It said that the error was caused by exceeding 2000 characters in the web.

Full Error:

Ignoring exception in on_connect
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 415, in _run_event
    await coro(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 1894, in on_connect
    await self.rollout_application_commands()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 1931, in rollout_application_commands
    await self.register_new_application_commands(data=global_payload)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/client.py", line 1855, in register_new_application_commands
    await self._connection.register_new_application_commands(data=data, guild_id=None)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/state.py", line 736, in register_new_application_commands
    await self.register_application_command(app_cmd, guild_id)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/state.py", line 754, in register_application_command
    raw_response = await self.http.upsert_global_command(self.application_id, payload)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/nextcord/http.py", line 337, in request
    raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body

Code

@client.slash_command(name="help",description="Help Command!")
async def help(ctx: nextcord.Interaction, *, command: str = nextcord.SlashOption(name="Command",description="The command you want to get help on.")):
    embedh = nextcord.Embed(title="Help",description="Help Menu is here!",color=nextcord.Color.green())
    embedh.set_footer(text=f'Requested by {ctx.author}',icon_url=ctx.author.avatar.url)
    embedh.add_field(name="General", value="`dm` `say` `poll`")
    embedh.add_field(name="Fun",value="`avatar` `giveaway` `8ball`",inline=False)
    embedh.add_field(name="Events",value="`guessthenumber`", inline=False)
    embedh.add_field(name="Image",value="`wanted`")
    embedh.add_field(name="Moderation",value="`ban` `unban` `kick` `mute` `warn` `purge` `wakeup` `makerole` `slowmode` `role` `lock` `unlock` `nickname`",inline=False)
    embedh.add_field(name="Utility", value="`ping` `help` `prefix` `setprefix` `serverinfo` `feedback` `credits` `support` `website` `guild`")
    await ctx.response.send(embed=embedh)

Information

JSON Error Code (I got it from here): 50035

IDE: Replit

Module: nextcord

How do I resolve this error?



Solution 1:[1]

Explanation

From the discord dev docs:

CHAT_INPUT command names and command option names must match the following regex ^[\w-]{1,32}$

The regex essentially translates to:

If there is a lowercase variant of any letters used, you must use those

In this case, your option name, 'Command' has an uppercase 'C', which is disallowed.

Note: The length of the name must also be lower or equal to 32.

Reference

Application command naming

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TheFungusAmongUs