久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='ug943'></bdo><ul id='ug943'></ul>
    <legend id='ug943'><style id='ug943'><dir id='ug943'><q id='ug943'></q></dir></style></legend>
    1. <i id='ug943'><tr id='ug943'><dt id='ug943'><q id='ug943'><span id='ug943'><b id='ug943'><form id='ug943'><ins id='ug943'></ins><ul id='ug943'></ul><sub id='ug943'></sub></form><legend id='ug943'></legend><bdo id='ug943'><pre id='ug943'><center id='ug943'></center></pre></bdo></b><th id='ug943'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ug943'><tfoot id='ug943'></tfoot><dl id='ug943'><fieldset id='ug943'></fieldset></dl></div>

      <small id='ug943'></small><noframes id='ug943'>

      <tfoot id='ug943'></tfoot>
      1. discord.py 如何使用 wait_for 等待作者消息?

        discord.py how to wait for author message using wait_for?(discord.py 如何使用 wait_for 等待作者消息?)
          • <small id='JAI8V'></small><noframes id='JAI8V'>

            <legend id='JAI8V'><style id='JAI8V'><dir id='JAI8V'><q id='JAI8V'></q></dir></style></legend>

              <bdo id='JAI8V'></bdo><ul id='JAI8V'></ul>
            • <tfoot id='JAI8V'></tfoot>
            • <i id='JAI8V'><tr id='JAI8V'><dt id='JAI8V'><q id='JAI8V'><span id='JAI8V'><b id='JAI8V'><form id='JAI8V'><ins id='JAI8V'></ins><ul id='JAI8V'></ul><sub id='JAI8V'></sub></form><legend id='JAI8V'></legend><bdo id='JAI8V'><pre id='JAI8V'><center id='JAI8V'></center></pre></bdo></b><th id='JAI8V'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JAI8V'><tfoot id='JAI8V'></tfoot><dl id='JAI8V'><fieldset id='JAI8V'></fieldset></dl></div>

                  <tbody id='JAI8V'></tbody>

                  本文介紹了discord.py 如何使用 wait_for 等待作者消息?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在發出等待用戶回復機器人的命令,但我希望機器人只接受作者的回復.

                  I am making a command which waits for a user to reply to the bot, but I would like the bot to only accept the author's reply.

                  @client.command(name='numgame',
                              brief='Guess a number between 1 and 100',
                              pass_context=True)
                  async def numgame(context):
                  number = random.randint(1,100)
                  guess = 4
                  while guess != 0:
                      await context.send('Pick a number between 1 and 100')
                      msg = await client.wait_for('message', check=check, timeout=30)
                      attempt = int(msg.content)
                      if attempt > number:
                          await context.send(str(guess) + ' guesses left...')
                          await asyncio.sleep(1)
                          await context.send('Try going lower')
                          await asyncio.sleep(1)
                          guess -= 1
                      elif attempt < number:
                          await context.send(str(guess) + ' guesses left...')
                          await asyncio.sleep(1)
                          await context.send('Try going higher')
                          await asyncio.sleep(1)
                          guess -=1
                      elif attempt == number:
                          await context.send('You guessed it! Good job!')
                          break
                  

                  我的問題是任何人都可以響應選擇一個數字",而我只希望啟動命令的人能夠響應.

                  My issue is that anyone can respond to "Pick a number," whereas I would only like the person who started the command to be able to respond.

                  我不太確定該嘗試什么,但我認為這可能與爭論有關.不過,我不知道從哪里開始,所以一個解決方案將不勝感激!非常感謝.

                  I am not too sure what to try, but I think it may have something to do with arguments. I have no idea where to begin, though, so a solution would be appreciated! Thanks a ton.

                  推薦答案

                  你需要重寫你的 check 讓它知道作者是誰.一種方法是使用閉包.假設您有一張現有的支票

                  You need rewrite your check so that it knows who the author is. One way of doing this is to use a closure. Let's say you have an existing check

                  def check(message):
                      return message.content == "Hello"
                  

                  您可以將其替換為生成等效檢查函數的函數,并將您要檢查的作者注入其中

                  You can replace this with a function that generates equivalent check functions with the author you want to check for injected into them

                  def check(author):
                      def inner_check(message):
                          return message.author == author and message.content == "Hello"
                      return inner_check
                  

                  然后,您可以通過使用適當的參數調用外部檢查,將內部檢查傳遞給 wait_for:

                  Then you would pass the inner check to wait_for by calling the outer check with the appropriate argument:

                  msg = await client.wait_for('message', check=check(context.author), timeout=30)
                  

                  為了您的檢查,這將是

                  def check(author):
                      def inner_check(message): 
                          if message.author != author:
                              return False
                          try: 
                              int(message.content) 
                              return True 
                          except ValueError: 
                              return False
                      return inner_check
                  

                  這篇關于discord.py 如何使用 wait_for 等待作者消息?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                  Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                  How to refresh sys.path?(如何刷新 sys.path?)
                  Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)
                    <legend id='pX1XY'><style id='pX1XY'><dir id='pX1XY'><q id='pX1XY'></q></dir></style></legend>

                      <tfoot id='pX1XY'></tfoot>

                          <tbody id='pX1XY'></tbody>
                        <i id='pX1XY'><tr id='pX1XY'><dt id='pX1XY'><q id='pX1XY'><span id='pX1XY'><b id='pX1XY'><form id='pX1XY'><ins id='pX1XY'></ins><ul id='pX1XY'></ul><sub id='pX1XY'></sub></form><legend id='pX1XY'></legend><bdo id='pX1XY'><pre id='pX1XY'><center id='pX1XY'></center></pre></bdo></b><th id='pX1XY'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='pX1XY'><tfoot id='pX1XY'></tfoot><dl id='pX1XY'><fieldset id='pX1XY'></fieldset></dl></div>

                          • <bdo id='pX1XY'></bdo><ul id='pX1XY'></ul>
                          • <small id='pX1XY'></small><noframes id='pX1XY'>

                          • 主站蜘蛛池模板: 国产日韩一区二区三免费 | 伊人精品视频 | 麻豆精品国产91久久久久久 | 成人羞羞国产免费视频 | 欧美精品a∨在线观看不卡 欧美日韩中文字幕在线播放 | 亚洲444eee在线观看 | 羞羞午夜 | 亚洲毛片在线观看 | 午夜视频在线 | 国产一区二区三区四区 | 国产精品国产三级国产aⅴ无密码 | 一级片av | 日本精品一区二区三区在线观看视频 | 亚洲91av | 欧美精品一区二区三区在线 | 久久久九九九九 | 涩爱av一区二区三区 | 精品国产一区二区三区久久影院 | 成人免费在线视频 | 欧美日韩一区二区三区四区 | 欧美成人精品一区二区男人看 | 欧美一区二区三区视频 | 成年人黄色免费视频 | 99精品欧美一区二区蜜桃免费 | 男女国产网站 | 伊人伊人伊人 | 国产精品久久久久久久免费大片 | 国产不卡在线观看 | 欧美亚洲视频在线观看 | 天天操天天射天天舔 | 色悠悠久 | 国产精品久久久久久久久久久新郎 | 成人夜晚看av | 丁香五月缴情综合网 | 激情一区二区三区 | 91在线视频国产 | 中文字幕乱码一区二区三区 | 99精品一区二区 | 亚洲精品乱码久久久久久黑人 | 亚洲天堂色 | 日韩在线免费视频 |