Nextcord 斜杠命令 | nextcord.errors.HTTPException: 400 错误请求(错误代码:50035):无效的表单主体
Nextcord Slash Command | nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
我正在将我的机器人从 discord.py
迁移到 nextcord
,并将我的帮助命令更改为斜线命令,但它一直向我显示此错误:
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
说是网页超过2000个字符导致的错误
完整错误:
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
代码
@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)
信息
JSON 错误代码(我从 here 得到的):50035
IDE: Replit
模块:nextcord
如何解决这个错误?
说明
来自 discord 开发文档:
CHAT_INPUT command names and command option names must match the following regex ^[\w-]{1,32}$
正则表达式基本上转换为:
If there is a lowercase variant of any letters used, you must use those
在这种情况下,您的选项名称 'Command'
有一个大写字母 'C',这是不允许的。
注意:名称的长度也必须小于或等于32。
参考
我正在将我的机器人从 discord.py
迁移到 nextcord
,并将我的帮助命令更改为斜线命令,但它一直向我显示此错误:
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
说是网页超过2000个字符导致的错误
完整错误:
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
代码
@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)
信息
JSON 错误代码(我从 here 得到的):50035
IDE: Replit
模块:nextcord
如何解决这个错误?
说明
来自 discord 开发文档:
CHAT_INPUT command names and command option names must match the following regex
^[\w-]{1,32}$
正则表达式基本上转换为:
If there is a lowercase variant of any letters used, you must use those
在这种情况下,您的选项名称 'Command'
有一个大写字母 'C',这是不允许的。
注意:名称的长度也必须小于或等于32。