The problem I'm currently facing is dealing with command names in nextcord. (Or so it seems) The error code shows as following:
Ignoring exception in on_guild_available
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\nextcord\client.py", line 497, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\nextcord\client.py", line 2567, in on_guild_available
await self.sync_application_commands(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\nextcord\client.py", line 2350, in sync_application_commands
await self._connection.sync_application_commands(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\nextcord\state.py", line 802, in sync_application_commands
await self.register_new_application_commands(data=data, guild_id=guild_id)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\nextcord\state.py", line 1003, in register_new_application_commands
await self.register_application_command(app_cmd, guild_id)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\nextcord\state.py", line 1038, in register_application_command
raise e
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\nextcord\state.py", line 1030, in register_application_command
raw_response = await self.http.upsert_guild_command(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\nextcord\http.py", line 399, in request
raise HTTPException(response, data)
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In options.0.options.1.name: Command name is invalid
This error usually happens when you incorrectly put a bad character in the ^[\w-]{1,32}$
regex (Please note that I do not know what regex is or how to correctly read it so I'm just going off of what someone said in this post). So everything should work.
Code that flags the issue:
# modlink (link/unlink/purgeall)
@client.slash_command(guild_ids=serverids,description="Link/Unlink mods ids from the reports section. (Manager Only)")
async def mod(interaction: Interaction):
pass
@mod.subcommand(description="Links/Adds their mod in-game id's to their discord UserID. (Manager Only)")
async def add(interaction: Interaction, target: nextcord.User, ingameID: str):
if check_manager(interaction.user.id) == True:
print("test")
else:
await interaction.response.send_message(f"{interaction.user.mention}",embed=prefabembeds.NoManagerPerms)
print(f"~$- log: (failed) modlink add (target: [{target}, {target.id}], ingameID: {ingameID}), user: [{interaction.user.id}, {interaction.user}]")
Help would be appreciated. (Even if I missed the tiniest spelling mistake)
I've tried renaming the command through the argument inside of "@client.slash_command()" and "mod.subcommand()", and also just renaming it by the function "async def mod(..." and "async def add(..."
Command arguments need to be lowercase as well.
At this point in the code:
async def add(interaction: Interaction, target: nextcord.User, ingameID: str):
^^^^^^^^
The command argument name has to also follow the regex pattern ^[\w-]{1,32}$
, not just the command name typed by the user.