1
votes

I'm making my own discord bot. The bot sends a message once a user sends -find I want the bot to wait for the user to respond to it. The bot waits, but it doesn't recognize the messages.

@commands.command()
async def find(self, ctx):
    members = [self.xxx, self.xxx, self.xxx]
    member = random.choice(members)
    image = member[0]
    await ctx.send(f'{image}')
    def check(m):
        m.author == ctx.author and m.channel == ctx.channel 
    try:
        await self.client.wait_for('message', timeout=8.0, check=check)
        await ctx.send('yay!')
    except: 
        await ctx.send('booo you suck')
        try:     @commands.command()
     async def find(self, ctx):
        members = [self.xxx, self.xxx, self.xxx]

        member = random.choice(members)
        image = member[0]

        await ctx.send(f'{image}')

        def check(m):
            m.author == ctx.author and m.channel == ctx.channel 

            await self.client.wait_for('message', timeout=8.0, check=check)
            await ctx.send('yay!')
        except: 
            await ctx.send('booo you suck')

There were no errors. I removed the try, except to see if there were any errors, but the only error that shows is timeout.

1

1 Answers

0
votes

That is because you are not returning anything in the check function so it will never evalutate to True as by default functions returns None which can be used as False

 @commands.command()
 async def find(self, ctx):
    members = [self.xxx, self.xxx, self.xxx]

    member = random.choice(members)
    image = member[0]

    await ctx.send(f'{image}')

    def check(m):
        return m.author.id == ctx.author.id and m.channel.id == ctx.channel.id

    try:
        await self.client.wait_for('message', timeout=8.0, check=check)
        await ctx.send('yay!')
    except: 
        await ctx.send('booo you suck')