This code serve the purpose to check if the user’s input premium code in the premium code array. Though, the type of modal textinput is <class ‘discord.ui.text_input.TextInput’>, while i need it to be in str for it to work. And yes, i tried str(), it still doesn’t work. How do i compare values ignoring its type or how do i change discord.ui.text_input.TextInput type to string? Any help?
class Mymodal(ui.Modal, title="Be an elite user"):
code = ui.TextInput(label="Enter code", placeholder="Include capitals and dashes.", style=discord.TextStyle.short)
async def on_submit(self, interaction: discord.Interaction):
refresh()
print(type(self.code))
if self.code in client.monthly_codes:
if interaction.user.id in client.monthly_user or interaction.user.id in client.yearly_user:
if interaction.user.id in client.yearly_user:
premium_status = "Yearly"
else:
premium_status = "Monthly"
I tried:
if str(self.code) in client.monthly_codes:
expecting:
for it to works:
result:
it doesn’t
Paul Bao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.