Reputation: 90
I am trying to build a discord bot using slash commands. I am running into this error:
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In name: String value did not match validation regex.
Code:
import discord
from discord.ext import commands
from discord_slash import SlashCommand
client = commands.Bot(
command_prefix='/',
help_command=None,
intent=discord.Intents.all()
)
slash = SlashCommand(
client,
sync_commands=True)
guild_ids = [
0123456789
]
@client.event
async def on_ready():
print("*throws banana*")
@slash.slash(
name='Throw Banana',
description='Throw a banana at an unsuspecting humanoid...',
guild_ids=guild_ids)
async def throw_banana(ctx):
await ctx.send(f'*throws banana at {ctx.author}')
client.run(
'token'
)
Token and guild_ids are changed for example.
Upvotes: 1
Views: 3130
Reputation: 90
The issue here is that I incorrectly assumed 'name' and the function name itself could be different. They must be the same.
@slash.slash(
name='throw_banana',
description='Throw a banana at an unsuspecting humanoid...',
guild_ids=guild_ids)
async def throw_banana(ctx):
await ctx.send(f'*throws banana at {ctx.author}')
Upvotes: 1