Created
October 17, 2020 21:19
-
-
Save 15696/d384e1a1c00a33e4d1d47ff692059baa to your computer and use it in GitHub Desktop.
a simple example of: commands.Bot.wait_for
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bot_msg = await ctx.send("what is 2 + 3?") | |
def check(message): | |
return message.channel == bot_msg.channel | |
try: | |
msg = bot.wait_for("message", check = check, timeout = 60) # timeout is 60 by default | |
except asyncio.exceptions.TimeoutError: | |
# user didnt reply in 60 seconds | |
else: | |
# user DID reply | |
if msg.content == "5": | |
await ctx.send("yes") | |
else: | |
await ctx.send("incorrect") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment