I am programming a Discord bot and it should have a birthday feature. I have some problem with the if statement and I just can’t figure out what could be wrong there. Can I even check the user input like that?
await ctx.send("What is your birthday? Please use MM/DD format.")
msg = await self.bot.wait_for('message')
try:
date = msg.content.split('/')
if date[0] > 12 or date[0] < 1:
return await ctx.send(f"Aborting... Invalid date.")
except:
pass
>Solution :
you need to convert date[0] to be an int:
await ctx.send("What is your birthday? Please use MM/DD format.")
msg = await self.bot.wait_for('message')
try:
date = msg.content.split('/')
if int(date[0]) > 12 or int(date[0]) < 1:
return await ctx.send(f"Aborting... Invalid date.")
except:
pass