简体   繁体   中英

How to get a new input in discord.py

This is a snippet of my code. I want to break the loop if a user messages on discord "??." I know the problem is that its not taking a new input and basing the command of the first send I dont know how to fix it in discord.py however. Any suggestions would be appreciated.

      for i in range(1000):
        await message.channel.send(message.content.replace("!spam",""))
        if client.wait_for("message") == "??":
          print("stopped")
          break
        else:
          continue

  

The client.wait_for method is a coroutine so you need to await it. It also returns a discord.Message instance, not a string.

for i in range(1000):
    await message.channel.send(message.content.replace("!spam", ""))
    msg = await client.wait_for("message")
    if msg.content == "??":
        break

You might wanna add a check to the wait_for method

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM