"Task exception was never retrieved" 错误 discord.py

"Task exception was never retrieved" error In discord.py

我是 python 的初学者,我正在尝试在 discord.py 中制作一个机器人,它有一个命令,让运行命令的人解释如何使用某些东西。但是我收到一条错误消息,提示“从未检索到任务异常”。包括完整的错误,我不明白。 代码:(我的名字或令牌之类的东西被替换了)

import discord
import os
from discord import ext
from discord.ext import commands
from discord import guild
from discord.ext.commands.core import dm_only
from discord_slash import SlashCommand, SlashContext
from discord_slash.model import OptionData
from discord_slash.utils.manage_commands import create_choice, create_option
import time

client = commands.Bot(command_prefix='d!')
slash = SlashCommand(client, sync_commands=True)

@client.event
async def on_ready():
    print('Ready')

@slash.slash(
    name='HowUse',
    description='Tell people how to use thing.',
    guild_ids=[removed],
    options=[
        create_option(
            name='What',
            description='What we are using.',
            required=True,
            option_type=3 
            ),
        create_option(
            name='How',
            description='How to use it',
            required=True,
            option_type=3 
            )
        ]
)
async def _hello(ctx:SlashContext, What:str, How:str):
    await ctx.send('How to use {}:'.format(What))
    time.sleep(0.5)
    ('{}'.format(How))
@client.event
async def on_ready():
    await client.change_presence(activity=discord.Game('HAIL THE BEANS'))
    print('Connected to bot: {}'.format(client.user.name))
    print('Bot ID: {}'.format(client.user.id))

client.run(token removed)

完整错误:

Task exception was never retrieved
future: <Task finished name='Task-1' coro=<SlashCommand.sync_all_commands() done, defined at C:\Users\removed\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_slash\client.py:416> exception=HTTPException('400 Bad Request (error code: 50035): Invalid Form Body\nIn 0.options.0.name: Command name is invalid\nIn 0.options.1.name: Command name is invalid')>
Traceback (most recent call last):
  File "C:\Users\removed\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_slash\client.py", line 492, in sync_all_commands
    raise ex
  File "C:\Users\removed\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_slash\client.py", line 472, in sync_all_commands
    existing_cmds = await self.req.put_slash_commands(
  File "C:\Users\removed\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 0.options.0.name: Command name is invalid
In 0.options.1.name: Command name is invalid

我该如何解决这个问题?我是否必须导入其他东西,或者我只是把代码都弄错了?

@client.event
async def on_ready():
   print('Ready')

@slash.slash(
    name='howuse',
    description='Tell people how to use thing.',
    guild_ids=[removed],
    options=[
        create_option(
            name='What',
            description='What we are using.',
            required=True,
            option_type=3 
            ),
        create_option(
            name='How',
            description='How to use it',
            required=True,
            option_type=3 
            )
        ]
)
async def _hello(ctx:SlashContext, What:str, How:str):
    await ctx.send('How to use {}:'.format(What))
    time.sleep(0.5)
    ('{}'.format(How))
@client.event
async def on_ready():
    await client.change_presence(activity=discord.Game('HAIL THE BEANS'))
    print('Connected to bot: {}'.format(client.user.name))
    print('Bot ID: {}'.format(client.user.id))

client.run(token removed)

我认为这会有所帮助 它给出的错误是您的命令名称“HowUse”包含无效字符,这意味着服务器名称中不允许使用大写字母“H”和大写字母“U”,因此请尝试使用“howuse”而不是“HowUse”

如果有效,请标记为正确