0

I'm trying to make flymsg = await client.wait_for_message(timeout=10, check=flycheck) to check if m.content contains one of the cities in city. I've tried m.content == city but I know that will probably check for all of them. If it doesn't contain one of the cities, I want it to ignore and timeout.

Also, I didn't want to start another question about the same piece of code, but I'm also trying to get m.content to check for lowercase words, i tried fly.message.content.lower() == 'ciyhere' but didn't seem to work.

 if message.content.lower().startswith('!fly'):
        city = [ 'Atlanta', 'Chicago', 'Chicago', 'Dallas', 'Los Angeles', 'Las Vegas', 'Miami', 'New York' ]
        citymsg = await client.send_message(message.channel, 'Welcome to Papi Airlines{} ✈️ Please choose a city to fly to ️**\nAtlanta\nChicago\nDallas\nLos Angeles\nLas Vegas\nMiami\nNew York**'.format(message.author.mention))
        def flycheck(m):
            return m.content
        flymsg = await client.wait_for_message(timeout=10, check=flycheck)
        if flymsg is None:    
            await client.send_message(message.channel, "{} you didn't choose a city in time".format(message.author.mention))
        else:
            if get_city(message.author) == 'Atlanta' and  str(flymsg.content) == 'Atlanta' :
                await client.delete_message(citymsg)
                await client.send_message(message.channel, "{} you're already in Atlanta".format(message.author.mention))
            else:
                if get_city(message.author) != 'Atlanta' and str(flymsg.content) == 'Atlanta':
                    await client.delete_message(citymsg)
                    await client.send_message(message.channel, "{} buys a one way ticket to Atlanta for $650".format(message.author.mention))
                    reset_city(message.author,"")
                    add_city(message.author, "Atlanta")
                    remove_dollars(message.author, 650)
                else:
                    if get_city(message.author) == 'Boston' and  str(flymsg.content) == 'Boston' :
                        await client.delete_message(citymsg)
                        await client.send_message(message.channel, "{} you're already in Boston".format(message.author.mention))
                    else:
                        if get_city(message.author) != 'Boston' and str(flymsg.content) == 'Boston':
                            await client.delete_message(citymsg)
                            await client.send_message(message.channel, "{} buys a one way ticket to Boston for $650".format(message.author.mention))
                            reset_city(message.author,"")
                            add_city(message.author, "Boston")
                            remove_dollars(message.author, 650)
etc
etc
etc
  • 1
    `return any(c in message.content.lower() for c in city)` – Patrick Haugh Feb 23 '19 at 19:10
  • Thanks for the input Patrick. I think there's something different in my code that's not making it work. It's not throwing any exceptions but now it's not capturing the message content. –  Feb 25 '19 at 00:22
  • @PatrickHaugh sorry i changed lower() to title() and changed flymsg.content to flymsg.content.title() and its working flawlessly now. –  Feb 25 '19 at 03:54

0 Answers0