#🔒 How to set a command name for hybrid command?

55 messages · Page 1 of 1 (latest)

last topazBOT
#

@tranquil silo

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

tranquil silo
#

I have these errors
discord.app_commands.errors.CommandSyncFailure: Failed to upload commands to Discord (HTTP status 400, error code 50035)
In command 'заказ' defined in function 'order'
In parameter 'Цель'
name: Command name is invalid
In parameter 'Тип'
name: Command name is invalid
But I dont know how to set name to parameter. Help please

#
import discord
from discord import ext
from discord.ext import commands
from discord import app_commands

TOKEN =
bot = commands.Bot(command_prefix="/", intents=discord.Intents.all())


@bot.hybrid_command(name="заказ")
async def order(ctx, Цель, количество, Тип):
    embed = discord.Embed(colour=discord.Colour.green(), title="Новый заказ от" + str(ctx.author),
                          description="Цель:" + str(Цель) + " \n Нужное количество работников: " + str(количество))
    if Тип == "Билдер":
        channel = bot.get_channel(1218449220487352421)
        await channel.send(embed=embed)
        await ctx.send("Заказ успешно сформирован")

    if Тип == "Скриптер":
        channel = bot.get_channel(1218449286388387881)
        await channel.send(embed=embed)
        await ctx.send("Заказ успешно сформирован")

    if Тип == "Моделер":
        channel = bot.get_channel(1218449340050309120)
        await channel.send(embed=embed)
        await ctx.send("Заказ успешно сформирован")


@order.autocomplete("Тип")
async def fruits_autocomplete(
    interaction: discord.Interaction,
    current: str,
) -> list[app_commands.Choice[str]]:
    types = ['Билдер', 'Скриптер', 'Моделер']
    return [
        app_commands.Choice(name=Type, value=Type)
        for Type in types if current.lower() in Type.lower()
    ]

@bot.event
async def on_ready():
    await bot.tree.sync()


bot.run(token=TOKEN)
spring kiln
#

@tranquil silo, your issue is, discord slash commands do not support non ascii characters in the commands or parameter names.

In your case, the command name 'заказ' and the parameters 'Цель', 'количество', and 'Тип' are all non ascii.

So you would need to turn them into ascii characters, which should fix your issue!

#
import discord
from discord import ext
from discord.ext import commands
from discord import app_commands

TOKEN =
bot = commands.Bot(command_prefix="/", intents=discord.Intents.all())

@bot.hybrid_command(name="order")
async def order(ctx, target, quantity, type):
    embed = discord.Embed(colour=discord.Colour.green(), title="New order from " + str(ctx.author),
                          description="Target: " + str(target) + " \n Required number of workers: " + str(quantity))
    if type == "builder":
        channel = bot.get_channel(1218449220487352421)
        await channel.send(embed=embed)
        await ctx.send("Order successfully formed")

    if type == "scripter":
        channel = bot.get_channel(1218449286388387881)
        await channel.send(embed=embed)
        await ctx.send("Order successfully formed")

    if type == "modeler":
        channel = bot.get_channel(1218449340050309120)
        await channel.send(embed=embed)
        await ctx.send("Order successfully formed")

@order.autocomplete("type")
async def fruits_autocomplete(
    interaction: discord.Interaction,
    current: str,
) -> list[app_commands.Choice[str]]:
    types = ['builder', 'scripter', 'modeler']
    return [
        app_commands.Choice(name=Type, value=Type)
        for Type in types if current.lower() in Type.lower()
    ]

@bot.event
async def on_ready():
    await bot.tree.sync()

bot.run(token=TOKEN)```



Something like this should work!
spring kiln
# tranquil silo Oh

If you have any more issues let me know, also for bot.run you could just do bot.run(TOKEN) instead of bot.run(token=TOKEN)

tranquil silo
spring kiln
#

Hm...

#

Im pretty sure discord doesn't allow non ascii, unless they are doing it in a weird way..

#

let me think

#

I guess you can, how are you typing in these russian letters?

spring kiln
#

I figured, but, discord seems to not like how you type them in

tranquil silo
#

I can enter commands in Russian, but I can’t set a parameter in Russian

spring kiln
#

let me try to do parameter

#

@tranquil silo

tranquil silo
#

?

spring kiln
#

turn Тип to type

#

instead of Тип

#

wait

#

I know why

tranquil silo
#

Here's the code that works. But it's in English. It doesn't suit me

spring kiln
#

okay so in discord.py, you can have capital letters, in Тип the T is capitalized.

#

so you would do tип not Тип

#

or however you do it in russian.

tranquil silo
#
import discord
from discord import ext
from discord.ext import commands
from discord import app_commands

TOKEN =
bot = commands.Bot(command_prefix="/", intents=discord.Intents.all())


@bot.hybrid_command(name="заказ"
                    )
async def order(ctx, target, neededfrelancers, ordertype):
    embed = discord.Embed(colour=discord.Colour.green(), title="Новый заказ от" + str(ctx.author),
                          description="Цель:" + str(target) + " \n Нужное количество работников: " + str(neededfrelancers))
    if ordertype == "Билдер":
        channel = bot.get_channel(1218449220487352421)
        await channel.send(embed=embed)
        await ctx.send("Заказ успешно сформирован")

    if ordertype == "Скриптер":
        channel = bot.get_channel(1218449286388387881)
        await channel.send(embed=embed)
        await ctx.send("Заказ успешно сформирован")

    if ordertype == "Моделер":
        channel = bot.get_channel(1218449340050309120)
        await channel.send(embed=embed)
        await ctx.send("Заказ успешно сформирован")

@order.autocomplete("ordertype")
async def fruits_autocomplete(
    interaction: discord.Interaction,
    current: str,
) -> list[app_commands.Choice[str]]:
    types = ['Билдер', 'Скриптер', 'Моделер']
    return [
        app_commands.Choice(name=Type, value=Type)
        for Type in types if current.lower() in Type.lower()
    ]

@bot.event
async def on_ready():
    await bot.tree.sync()


bot.run(token=TOKEN)
#

How you can see all params in eng but I need in Russian

spring kiln
#

No no

#

listen

#

ОК, в discord.py нельзя использовать заглавные буквы, в Типе буква T пишется с заглавной буквы.

#

If that even makes sense 😭

#

Итак, что вы делаете, вы принимаете Т за т

tranquil silo
#

You can type in eng. I understand it

spring kiln
#

oh okay. Sorry lol

#

I try to make it easier on you, sorry if I offended you by using a translator.

#

but yeah, all parameters need to be lowercase. That is the reason why it didn't work.

tranquil silo
#

Yea! Its works! But i need to use _ to make a space

spring kiln
#

what do you mean you need to use _?

tranquil silo
spring kiln
#

well of course

#

or you can use -

tranquil silo
#

I cant type "тип работы" instead of this i should use - or _

spring kiln
#

yeah

#

personally I use -

#

it looks better, but you can choose either

tranquil silo
#

I cant pass it?

spring kiln
#

Nope, you can't have spaces sadly

tranquil silo
#

Oh... Well, thanks for help!

spring kiln
#

no problem!

tranquil silo
#

!close

last topazBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.