@client.command()
async def submitcluetest(ctx):
await ctx.send(f"{ctx.author.mention}Check your dms!")
await ctx.author.send('Submit your answer here, all lowercase. Do not reveal this to anyone else if you got it right, everyone who solves it gets a special role :smirk:')
message = await client.wait_for('message')
if message.content == 'twopeople':
await ctx.send('correct answer')
else
await ctx.send('try again')
This is my code right now. The problem is that once someone starts the command and tries to input their answer, someone else could type something and interrupt them. I would like message.content
only be detected by the user. I tried using message.author.content
or author.message.content
but that still wouldn't work.
I hope the below code helps to fix your problem
@client.command()
async def submitcluetest(ctx):
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
await ctx.send(f"{ctx.author.mention}Check your dms!")
await ctx.author.send('Submit your answer here, all lowercase. Do not reveal this to anyone else if you got it right, everyone who solves it gets a special role :smirk:')
try:
message = await client.wait_for('message', timeout=120, check=check)
except asyncio.TimeoutError:
await ctx.send("You didn't entered in time.Please answer at next time!")
return
else:
if message.content == 'twopeople':
await ctx.send('correct answer')
else
await ctx.send('try again')
Use a lambda expression for the check. message = await self.client.wait_for('message', check=lambda m: m.author == ctx.author)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.