#Subcommands for choices (if choices ==) please help
1 messages · Page 1 of 1 (latest)
An example using subcommand groups and subcommands.
Already was there
I have a specific case
I need to know what I have to fix here
Please.
If you can't see how you're wrong by comparing yuour code and the examples..
Yea thats not how indentation works. just copy the examples and compare
Indentation..?
You mean
Ugh, sorry I just woke up
I was trying to do this the whole day yesterday
I need to take the first part as a blank
As a parent root command
Basically
@bot.slash_command()
async def misccrate(inter):
pass```
Yeah, that part good
Yeah
@tier.sub_command()
async def tier(inter: #paste my code here)
if choices == '1'
I feel like I have a mistake here
Inter is not going to be accessed, right?
It's not a subcommand of tier, but of misccreate
Then what do I need to add?
Not add, but change
I'm listening.
@<parent command name>.sub_command()
Ohh
Your parent command is misccrate
Okay okay
Here:
@misccrate.sub_command()
async def tier(inter:#paste my code here)
if choices == '1':
@tier.sub_command()
async def cosmetics(inter: disnake.AppCmdInter, choices: str=commands.Param(name='cosmetics', choices=[#insert]
if choices =#etc.
@drowsy falcon
Is this right?
Why is it indented in the command itself.
Have you taken a look at the examples linked earlier?
My question is is how to set it all properly
Why is there a subcommand of tier
Look at the examples, there pretty good
Hm
Oh okay
It's all supposed to be of 1 parent eh?
@drowsy falcon
I have a question here
if it's supposed to be like that or not
I need cosmetics choice to show up
It's like you're just ignoring literally everything you're being told
I'm not
Okay, tell me what I am missing
I may be stupid.
An example using subcommand groups and subcommands.
Find the differences and fix your code so that it matches
Why is the cosmetics nested within tier
then how do I make it so that
on choice of 'Tier 1' e.g. I will get a list of the cosmetics inside of the tier 1
@bot.slash_command()
async def parent(inter):
print("This code is ran every time any subcommand is invoked")
@parent.sub_command()
async def foo(inter, option: str):
await inter.response.send_message(f"foo: {option}")
@parent.sub_command()
async def bar(inter, option: int):
await inter.response.send_message(f"bar: {option}")
This just gives me 2 commands
Then cosmetics is supposed to be the option choices of your tier subcommand
@drowsy falconcosmetics not accessed
Ughghghghghhg
What is supposed to connect it to what?
it's the entire reason why I don't have cosmetics after tier
How many more times do you need to be told not to indent your sub command inside the parent command?
I say, at-least 2 more
bitch
What are you calling a bitch? Your ignoring the help people are trying to provide and then wondering why its not working. This shouldn't be this much of an issue
What is the expected behaviour? Do you want cosmetics to be called after the tier is called? What is the use case for the nesting in your eyes
Then please understand that I have only 2 weeks of learning and I need a detailed help
It's simple for you as well, don't nest it within the parent command. It could be as simple as copying the examples and renaming them
Like, just untab the cosmetics command and itll work
Don't nest is that you mean I need to remove misccrate in @misccrate.sub_command()?
You see how these are all at the same indent level. Compare that to yours, which arent at the same level
(Level being the @ bits)
It almost seems like they're trying to have a subcommand depending on which choice is selected.
If so, that's just not how it works.
Whenever I choose the tier ('Tier 1' e.g.)
I want to see the next choices of that 'Tier 1'
wdym 'next choices'. Like whats tier one?
tier one
must
contain
ONE CONTENT.
chill bro
And the others other content.
/misccrate [Tier] (here we choose tier 1) [cosmetics] (here we have a list of cosmetics in tier 1)
Yeah, that sounds like autocomplete
An example showcasing the two ways of adding autocompletion to slash command options.
And
okay, how do I make that kind of autocomplete
-d ApplicationCommandInteraction.filled_options
property filled_options```
The options of the command (or sub-command) being invoked
Look at the example above
the example above I copied it
it doesn't have the shit I need
Well duh. It's an example.
I need someone to type this all out
Trying for two days
HAH
I don't see the result.
You've been trying autocomplete for two days?
First I tried doing that through subcommands.
Now it turned out that I need autocomplete.
I wasted 5 hours on subcommands yesterday.
NOTHING IN RESULT.
Uh huh, so your giving up?
Can you at-least try?
You think spending 2 days on something like this is funny enough?
I TRIED.
WDYM.
Am I doing something the internet has never done before????!?!?!?!?
Okay, so send the autocomplete you tried please
Explain what you tried, what you wanted it to do and what it ended up doing
Hey @harsh epoch!
It looks like you're trying to paste code into this channel.
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
P.s. I've spent months on projects I don't actually use, so yes. While I do get it, I also won't be writing it entirely for you
I'm trying to make this all
into my thing
async def autocomplete_langs(inter, string: str) -> List[str]:
string = string.lower()
return [lang for lang in LANGUAGES if string in lang.lower()]
@bot.slash_command()
async def languages_1(
inter: disnake.CommandInteraction,
language: str = commands.Param(autocomplete=autocomplete_langs),
):
@bot.slash_command()
async def languages_2(inter: disnake.CommandInteraction, language: str):
...
@languages_2.autocomplete("language")
async def language_autocomp(inter: disnake.CommandInteraction, string: str):
string = string.lower()
return [lang for lang in LANGUAGES if string in lang.lower()]
back to what we had
An example showcasing the two ways of adding autocompletion to slash command options.
@rough tendoncan you please at least help me and write this all down?
I'm trying my best not to be aggressive right now.
I really need this.
I see.
Hmmm
yes
So firstly, I think we work on fixing your command so its not indented in the other
Like in this, literally undeinten everything for the cosmetics sub command so the @'s line up with the others
Or given you don't need a subcommand, we can delete it for now
Can you put it in https://paste.disnake.dev for me so I can copy it and change it for you?
A simple paste service run entirely on Cloudflare's edge.
Inserted
what's next
save it and share the link.
You'd better not be 🤨
Why did you create a cosmetics subcommand
I thought cosmetics are supposed to be option choices for a tier subcommand
So lets consider this code:
@bot.slash_command()
async def misccrate(inter):
pass
@tier.sub_command()
async def tier(inter: disnake.AppCmdInter, choices: str=commands.Param(name='crate', choices=['Tier 1', 'Tier 2', 'Tier 3'])):
if option == 'Anders Army':
embed = disnake.Embed(title='Anders Army', description='Tier: GENERAL', url='', color=0x008000)
embed.set_image(url='https://static.wikia.nocookie.net/arms-of-solitaire/images/8/83/Anders_Army.png/revision/latest?cb=20230408150639')
embed.set_footer(text='Official YLWB Bot.')
await inter.response.send_message(embed=embed)
This is the code we are going to use going forward
Lets define another option option
@tier.sub_command()
async def tier(inter: disnake.AppCmdInter, choices: str=commands.Param(name='crate', choices=['Tier 1', 'Tier 2', 'Tier 3']), option: str):
...
@tier.autocomplete("option")
async def autocomp(inter: disnake.CommandInteraction, string: str, choices: str):
if choices == "Tier 1":
return [choices for tier one]
return [...]
Now I dont actually know if this is how cross param auto complte works in disnake. Its how it works in NC so you will need to test it and see if you can get the params passed this way
I'll look into it now, but for the meantime thats my guess
you can user inter.filled_options
Ooo, okay. Use that ^
I know nextcord lets you ask for other arguments from the parent command in autocomplete but unsure of disnake off the top of my head
You can do that in disnake, too. But they must be kwargs, IIRC
Im sure teacup can 'try it and see' for us ; )
From the yesterday's context this isn't actually doing what he wants
Otherwise, you can use filled_options and do like choice = inter.filled_options.get('choices') or whatever the first arg is called.
Please do expand if you have more context
Okay so look.
I'm making this wikibot for a community.
And the command is related to the crates containing cosmetics.
Tier 1 must contain Anders Army for example.
My understanding is they want to have choices returned based on a previous 'tier' argument
And I need to choose the tier of the crate first, let's write it down:
/misccrate [Tier 1]
In tier 1 we have Anders Army, Sir Shauter, etc.
But we want to test this on Anders Army.
/misccrate [Tier 1] [Anders Army] (the result is supposed to be our embed)
They want a command where you have two selectable "parameters" to fill, where the second one's options are dictated by the first one
It's not doable with two static option choice parameters, thus Sharp suggested making the first parameter into separate subcommands, where each subcommand would provide the "second" option independently of other subcommands
The other way would be to use autocomplete but seeing how they struggled with basic bits we put that off the reach
Yea, we are suggesting autocomplete using the first option
@bot.slash_command()
async def misccrate(inter):
pass
@tier.sub_command()
async def tier(inter: disnake.AppCmdInter, choices: str=commands.Param(name='crate', choices=['Tier 1', 'Tier 2', 'Tier 3'])):
if option == 'Anders Army':
embed = disnake.Embed(title='Anders Army', description='Tier: GENERAL', url='', color=0x008000)
embed.set_image(url='https://static.wikia.nocookie.net/arms-of-solitaire/images/8/83/Anders_Army.png/revision/latest?cb=20230408150639')
embed.set_footer(text='Official YLWB Bot.')
await inter.response.send_message(embed=embed)
@tier.sub_command()
async def tier(inter: disnake.AppCmdInter, choices: str=commands.Param(name='crate', choices=['Tier 1', 'Tier 2', 'Tier 3']), option: str):
...
@tier.autocomplete("option")
async def autocomp(inter: disnake.CommandInteraction, string: str, choices: str):
if choices == "Tier 1":
return [choices for 'Tier 1']
return [...]
I don't know why it shows so many errors
tier and option are not defined
Well that's becuase you're trying to set tier as a subcommand of tier, and you didn't define option anywhere.
where should I define option so it doesn't break everything
set tier as a subcommand of tier.
Hm.
An example showcasing the two ways of adding autocompletion to slash command options.
Can you help please?
What has he been doing the whole time
The @hollow flame example shows something that is a complete opposite of my request.
Well it's not going to tell you how to fix the errors you're having.
But you CAN use it to understand how to implement the feature you're after, then replicate it using your own arguments and commands
Can you please help and fix the code?
Please.
^ that's how you fix it. Don't do what you're doing
@rough tendon how do I properly explain my request to ChatGPT?
I'll be honest here, I'd recommend learning some more Python. Disnake is not exactly beginner friendly and you should be able to understand the help we are providing. This indicates to me at-least you are reliant on sources such as ChatGPT which are going to be widley incorrect and while might give you the general gist, you still need to understand enough to fix it yourself, which I feel you don't have as your asking us to simply write it for you as the help we are providing is being misunderstood.
I'm happy to provide some resources for learning more Python, specifically related to the things applicable here but I feel like further help from at-least myself is simply going to miss the mark as your relying on outside resources without an understanding yourself and its leading to a communication differences between us (le helpers) and yourself.
Don't get me wrong, we all do want to help. Like, we really do. But theres a point where learning a bit more about the language your trying to write will also be beneficial to you
Please write a slash command for discord bot using disnake library. The first option must be called tier. In option tier we will have 3 choices: Tier 1, Tier 2, Tier 3. All of them must contain their own content for the second option called cosmetics.
For example, if we choose Tier 1, in the second option we will have choices "Anders Army" and "Sir Shauter".
If we choose Tier 2, in the second option we will have choices "Perestroyka" and "Paris Night".
If we choose Tier 3, in the second option we will have choices "Tankist Hat" and "Sky Baron".
When we choose the second option, I want to get a text and image in the embed with the title and description.
I think this should do
ChatGPT also likely wont have the data required to help you here. This implementation is too new for it to likely have been trained on it
(To be real)
@frozen ravine
@bot.slash_command()
async def tier(inter):
tier_choices = ['Tier 1', 'Tier 2', 'Tier 3']
cosmetics_mapping = {
'Tier 1': ['And Army', 'Sir Shauter'],
'Tier 2': ['Perestroyka', 'Paris Night'],
'Tier 3': ['Tankist Hat', 'Sky Baron']
}
tier_option = disnake.OptionChoice(name='tier', description='Tier', choices=tier_choices, required=True)
cosmetics_option = disnake.OptionChoice(name='cosmetics', description='Cosmetics', choices=[])
inter_option(tier_option)
inter.add_option(cosmetics_option)
selected_tier = inter.get_option('tier')
selected_cosmetics = inter.get_option('cosmetics')
if selected_tier in tier_choices and selected_cosmetics in cosmetics_mapping[selected_tier]:
embed_title = selected_cosmetics
embed_description = f": {selected_tier}"
embed = disnake.Embed(title=embed_title, description=embed_description, color=0x008000)
embed.set_footer(text='Official YLWB Bot.')
# Set the image based on the selected options
if selected_cosmetics == 'Anders Army':
embed.set_image(url='https://static.wikia.nocookie.net/arms-of-solitaire/images/883/Anders_Army.png/revision/latest?cb=20230408150639')
elif selected_cosmetics == 'Sir Shauter':
embed.set_image(url='[URL_TO_SIR_SHAUTER_IMAGE]')
elif selected_cosmetics == 'Perestroyka':
embed.set_image(url='[URL_TO_PERESTROYKA_IMAGE]')
elif selected_cosmetics == 'Paris Night':
embed.set_image='[URL_TO_PARIS_NIGHT_IMAGE]')
elif selected_cosmetics == 'Tankist Hat':
embed.set_image(url='[URL_TO_TANKIST_HAT_IMAGE]')
elif selected_cosmetics == 'Sky Baron':
embed.set_image(url='[URL_TO_SKY_BARON_IMAGE]')
await inter.response.send_message(embed=embed)
else:
await inter.response.send_message("Invalid options selected.")```
AI generated
No.

Have fun 👍
Wait, I'm not good at explaining.
I need to tell it that.
There must be choices in like brackets
whenever you do the slash commands you have options
it lacks them
@drowsy falcon BRO NOT EVEN CHATGPT CAN SOLVE IT PROPERLY
AM I REALLY DOING SOMETHING IMPOSSIBLE
no, you're not.
.
You're extremely prone to ignoring what we say 
IT CAN'T
FUCK THIS
I GIVE UP
@regal crypt
If AI can't, no one can
especially me
You're overestimating the "AI"
and yet it's really just that easy
I mean this is truly a difficult task of describing to a computer what you want it to do for you
okay, write the code then please.
Because I can't and I am asking for help.
that's not how this works
Pay 
we're here to help you figure out how to do it, not to write your code for you
skill issue?
Helping issue?
Don't blame us for your problems
The only choice for me is to ask someone for it.
If I am left with nothing but to think with "the patience".
I have no qualms writing some code for someone who can't figure it out but is willing to learn. I do not get that notion from you whatsoever
Whatever then.
Like 5 people dedicated their time to helping you, to no avail
and yet you still haven't even tried to make a command with three subcommands like I suggested five times already
Ethan did something at the very least.
this is not an us issue whatsoever
If you really had the patience you'd start with studying python fundamentals
And then, there are no guides on what I need specifically.
because you don't need them
I actually feel like that someone did it and doesn't want to share the "formula".
it's a simple as combining two basic things
My brother in Christ, I searched up that on youtube.
I scrolled down a million times.
really not getting through, am I
I tried searching up on stacks overflow.
What do I have to combine, tell me?
This and that?
hmm, let me go back to what I sent yesterday
voila, #help-other message:
as in, main command
misccratewith subcommandscrate1,crate2andcrate3; with one parameter with choices each
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Here I am sitting and trying to do something out of spite.
that still isn't how you do subcommands
you don't define a command inside another command
An example using subcommand groups and subcommands.
bruh............................
that is by far the easiest way of achieving close to what you want
you'd make three commands, /crates tier1, /crates tier2 and /crates tier3
now, you should already know how to add a param with options to each of those
and you're done
You won't get anywhere with such approach
Saying you're tired won't get someone else to do it for you
At least not here
What is supposed to happen at that point?
No, just tell me
that was a genuine question as you can do multiple things and they can't read your mind
okay this works
question
how do I make option have
autocomplete
aka list
you had that figured out yesterday, no?
option_name: str = commands.Param(choices=...)
show your code rq
I added the option_name str = commands.Param(choices=...)
Option in our case
is 'cosmetic'
Choices is a list
choices should be a list
choices=list[
Next I forgot what comes after list
that's not how you make lists
Simplest I would make is list1 = ['foo', 'bar']
Marked the thread as solved. If your question has not been answered, please open a new thread in #1019642966526140566.