#I want to make a "Enter Code" thing in pycord
1 messages · Page 1 of 1 (latest)
okay?
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)
Get started on your own and come back when you have a specific issue, asking to make an entire feature won't do anything
yeah i want to do it in modals
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)
What is EnterCode?
EnterCode is the modal
i already added the modal
can you even access the input text like that?
I know, but you need an instance of the class
not the class itself
class EnterCode(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.InputText(label="Enter Code"))
Not at all lol
i don't know, but it just doesn't work
lol
Here's the modal dialogs example.
oh
look at the example and read the docs
you're obviously just guessing, which won't get you anywhere
Obviously not
there isn't going to be a specific example on every single thing
use the example and make your own implementation
yeah, can you just get my code maybe fixed? would help alot

Read #help-rules
Then fix it 
not that difficult
It's pretty simple if you know basic OOP in Python
i am basic python writer tbh
can you tell me how to get the value of the modal
(of the input)
just see how the example accesses the input value, and do the same
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
if you need even more hints, it is on this line- ||https://github.com/Pycord-Development/pycord/blob/master/examples/modal_dialogs.py#L35||
i know how to use pycord, my bot is working perfect but this one error triggers me
Then the example should be perfectly understandable for you
is it like:
if modalname.value == "this":
await any_action
else:
await any_other_action
Nope
but modalname.value is the value i entered on the modal
i read it twice
did you even see this
still dont understand
Official Beginner's Guide: https://wiki.python.org/moin/BeginnersGuide
Official Tutorial: https://docs.python.org/3/tutorial/
Shortcuts:
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
https://wiki.python.org/moin/BeginnersGuide/Programmers
Learn Python:
https://automatetheboringstuff.com/ (for complete beginners to programming)
https://learnxinyminutes.com/docs/python3/ (for people who know programming already)
https://docs.python.org/3/tutorial/ (official tutorial)
http://python.swaroopch.com/ (useful book)
http://www.codeabbey.com/ (exercises for beginners)
?tag learnpython
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.
?tag modal
The library has helpers to help create component-based UIs. Shortcut decorators: Objects: Attributes children, disable_on_timeout, message, timeout. Methods cls View.from_message, def add_item, def...
but what is like my example "modal.value" in python
so i can only fix that one
it will just help alooottt
There is nothing like "modal.value"
You need to use the callback of the modal subclass
Yes, just the callback
How do i get the value and check it if it's exactly a specific value i want
It is literally on this line
that you supposedly read twice
like if its "1" it gives me a role and if its anything other than not
like a code bruh
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
but this line doesnt help me as much
It tells you how to get the value of the input. What more do you need?
yes i did
Where?
value=self.children[0].value
Why on earth are you putting that in the add_item?
Theres nothing called value in the inputs to that function
oh shit lmfao
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.
.closing
Done with your help thread?
Please close your own help thread by using </close:1009144375709814897> with @celest stratus.
