#I want to make a "Enter Code" thing in pycord

1 messages · Page 1 of 1 (latest)

rigid ridge
versed dock
#

okay?

clear oak
#

use modals

#

or bot.wait_for

rigid ridge
#

this is my code

#

async def callback(self, interaction : discord.Interaction):
if EnterCode.value == "1200":
await interaction.response.send_message("You're unlocked.", ephemeral=True)
else:
await interaction.response.send_message("The code is wrong.", ephemeral=True)

versed dock
#

Get started on your own and come back when you have a specific issue, asking to make an entire feature won't do anything

rigid ridge
#

my code is:

    async def callback(self, interaction : discord.Interaction):
        if EnterCode.value == "1200":
            await interaction.response.send_message("You're unlocked.", ephemeral=True)
        else:  
            await interaction.response.send_message("The code is wrong.", ephemeral=True)
versed dock
#

What is EnterCode?

rigid ridge
#

EnterCode is the modal

versed dock
#

But you never call the modal

#

or make an instance of the class

rigid ridge
#

i already added the modal

clear oak
#

can you even access the input text like that?

versed dock
#

not the class itself

rigid ridge
#
class EnterCode(discord.ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self.add_item(discord.ui.InputText(label="Enter Code"))
versed dock
rigid ridge
#

lol

celest stratusBOT
#

Here's the modal dialogs example.

versed dock
#

oh

clear oak
#

pff

#

lol

versed dock
#

look at the example and read the docs

#

you're obviously just guessing, which won't get you anywhere

rigid ridge
#

but theres such no description how to make a "Enter Code" field

#

in a modal

versed dock
#

Obviously not

#

there isn't going to be a specific example on every single thing

#

use the example and make your own implementation

rigid ridge
#

yeah, can you just get my code maybe fixed? would help alot

versed dock
#

No lol

#

we don't spoonfeed here

rigid ridge
versed dock
#

Read #help-rules

rigid ridge
#

ok cool

#

i just need it to be fixed sad

versed dock
#

Then fix it NPCMechanicShrug

clear oak
#

not that difficult

versed dock
#

It's pretty simple if you know basic OOP in Python

rigid ridge
#

i am basic python writer tbh

#

can you tell me how to get the value of the modal

#

(of the input)

clear oak
#

just see how the example accesses the input value, and do the same

versed dock
#

The example and docs tell you everything you need to know

#

If you don't understand them, you don't know Python well enough to be using pycord yet

clear oak
rigid ridge
#

i know how to use pycord, my bot is working perfect but this one error triggers me

versed dock
#

Then the example should be perfectly understandable for you

rigid ridge
#

is it like:

if modalname.value == "this":
  await any_action
else:
  await any_other_action
versed dock
#

Nope

rigid ridge
#

but modalname.value is the value i entered on the modal

versed dock
#

Read the example and understand it

#

It shows exactly how you should do it

rigid ridge
#

i read it twice

rigid ridge
#

still dont understand

rigid ridge
#

i read it twice

#

i dont understand

versed dock
#

Then you need to learn more Python

#

?tag lp

strong ridgeBOT
#
versed dock
#

?tag learnpython

strong ridgeBOT
#

To be clear:

When we tell you to learn Python before asking questions here, it is not meant in a derogatory way, we are not calling your dumb or incompetent. We are simply stating the fact that usage of PyCord requires a fair bit of knowledge with using OOP, Async/Await etc. in Python. If you are not comfortable with these concepts, chances are you will not understand the answers given to you in this channel.

We understand that everyone learns at a different pace, and your current knowledge with Python may have been enough so far. When we say "you need to learn Python", it is most likely a sign that we have given you an explanation that you could not understand and there is no way for us continue to help you without spoonfeeding.

rigid ridge
#

?tag modal

strong ridgeBOT
rigid ridge
#

but what is like my example "modal.value" in python

#

so i can only fix that one

#

it will just help alooottt

versed dock
#

There is nothing like "modal.value"

#

You need to use the callback of the modal subclass

rigid ridge
#

Yes, just the callback

#

How do i get the value and check it if it's exactly a specific value i want

versed dock
#

that you supposedly read twice

rigid ridge
#

like if its "1" it gives me a role and if its anything other than not

#

like a code bruh

clear oak
#

if you need a more technical explanation, the input texts are stored in a list which can be accessed at modal.children (where modal is the instance and not the class)
the value of the input text can be accessed using input_text.value

versed dock
#

For the last time, we won't give you finished code

#

and that line is "a code"

rigid ridge
#

but this line doesnt help me as much

versed dock
#

It tells you how to get the value of the input. What more do you need?

rigid ridge
#

ohh

#

ok

#

sorry

#

but its yellow lined

versed dock
#

???

#

you didn't define anything called value

rigid ridge
#

yes i did

versed dock
#

Where?

rigid ridge
#

value=self.children[0].value

versed dock
#

Why on earth are you putting that in the add_item?

slate sluice
rigid ridge
#

oh shit lmfao

versed dock
#

Either way, it's pretty clear that you don't have enough competence with OOP in Python to be using this, so I'm out. If someone else wants to help they can, but I'd rather not support this.

rigid ridge
#

ok tysm i did it

#

you guys awesome

#

sorry for my dumbness xd

clear oak
#

.closing

woven ravenBOT
#

Done with your help thread?

Please close your own help thread by using </close:1009144375709814897> with @celest stratus.

rigid ridge
#

ok bye

#

ty