'"Task exception was never retrieved" error In discord.py
I am a beginner in python and am trying to make a bot in discord.py that has a command that has whoever runs the command explain how to use something. But I get an error that says "Task exception was never retrieved." Included is the full error, which I don't understand. The code: (things like my name or the token were replaced)
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)
Full error:
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
How do I fix this? Do I have to import something else or am I just doing the code all wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
