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

      1. <small id='wGDmu'></small><noframes id='wGDmu'>

        <tfoot id='wGDmu'></tfoot>
        • <bdo id='wGDmu'></bdo><ul id='wGDmu'></ul>

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

        需要多個(gè) wait_for_messages discord.py

        multiple wait_for_messages wanted discord.py(需要多個(gè) wait_for_messages discord.py)

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

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

                  <bdo id='xqJeK'></bdo><ul id='xqJeK'></ul>

                  本文介紹了需要多個(gè) wait_for_messages discord.py的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  基本上我正在做一個(gè)測驗(yàn),我希望能夠搜索答案并確定哪條消息只包含藝術(shù)家,哪條消息只包含歌曲名稱,以及哪條消息同時(shí)顯示它們.我已經(jīng)制作了 3 個(gè)檢查函數(shù)來顯示這一點(diǎn),但是我希望所有 3 個(gè) wait_for_message 語句并排運(yùn)行.關(guān)于如何解決這個(gè)問題的任何想法?

                  Basically I am making a quiz and I want to be able to search through the answers and determine which message only has the artist in, which message only has the song name in, and which message says them both. I've made 3 check functions to show this however I want all 3 wait_for_message statements to run side by side. Any ideas on how this could be remedied?

                  await client.say("What is the song name and artist?")
                  def check1(msg):
                      return name in msg.content.upper() and artist not in msg.content.upper()
                  def check2(msg):
                      return artist in msg.content.upper() and name not in msg.content.upper()
                  def check3(msg):
                      return name in msg.content.upper() and artist in msg.content.upper()
                  msg1 = await client.wait_for_message(timeout=10, check=check1)
                  msg2 = await client.wait_for_message(timeout=10, check=check2)
                  msg3 = await client.wait_for_message(timeout=20, check=check3)
                  if msg3 is not None:
                     await client.say("@{} got both of them right! It was indeed {} by {}".format(msg3.author, toString(name), 
                                                                                                       toString(artist)))
                  elif msg1 is not None and msg2 is not None:
                          await client.say("@{} got the song name and @{} got the artist name! It was indeed {} by {}".format(msg1.author, 
                                                                                             msg2.author, toString(name), toString(artist)))
                  elif msg1 is not None and msg2 is None:
                          await client.say("@{} got the song name but no one got the artist! It was {} by {}".format(msg1.author,
                                                                                                         toString(name), toString(artist)))
                  elif msg1 is None and msg2 is not None:
                          await client.say("@{} got the artist name but no one got the song name! It was {} by {}".format(msg2.author,
                                                                                                         toString(name), toString(artist)))
                  elif msg1 is None and msg2 is None and msg3 is None:
                          await client.say("No one got it! It was {} by {}! Better luck next time".format(toString(name), toString(artist)))
                  

                  推薦答案

                  你要找的代碼是asyncio.gather.這讓您可以同時(shí)運(yùn)行多個(gè)協(xié)程并等待所有方法返回.

                  The code you are looking for is asyncio.gather. This lets you run multiple coroutines at the same time and wait until all methods are returned.

                  gather 的返回列表是按照輸入的順序,而不是按照任務(wù)完成的順序.

                  The return list from gather is in the order of the inputs, not in the order of task completion.

                  ret = await asyncio.gather(
                      client.wait_for_message(timeout=10, check=check1),
                      client.wait_for_message(timeout=10, check=check2),
                      client.wait_for_message(timeout=10, check=check3)
                  )
                  
                  msg1, msg2, msg3 = *ret
                  # msg1 has the name
                  # msg2 has the artist
                  # msg3 has both
                  

                  由于 discord.py 的重寫版本有 client.wait_for 拋出錯(cuò)誤而不是返回 None,你可以這樣做.

                  Since the rewrite version of discord.py has client.wait_for throw an error instead of returning None, you can instead do this.

                  ret = await asyncio.gather(
                      client.wait_for("message", timeout=10, check=check1),
                      client.wait_for("message", timeout=10, check=check2),
                      client.wait_for("message", timeout=10, check=check3),
                      return_exceptions = True
                  )
                  
                  # Test for errors
                  ret = [r if not isinstance(r, Exception) else None for r in ret]
                  msg1, msg2, msg3 = *ret
                  

                  這篇關(guān)于需要多個(gè) wait_for_messages discord.py的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個(gè)在 Python 中提供角色的不和諧機(jī)器人?)
                  Discord bot isn#39;t responding to commands(Discord 機(jī)器人沒有響應(yīng)命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關(guān)于我嗎?Discord 機(jī)器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機(jī)器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動(dòng)更改角色顏色)
                  <i id='KaysP'><tr id='KaysP'><dt id='KaysP'><q id='KaysP'><span id='KaysP'><b id='KaysP'><form id='KaysP'><ins id='KaysP'></ins><ul id='KaysP'></ul><sub id='KaysP'></sub></form><legend id='KaysP'></legend><bdo id='KaysP'><pre id='KaysP'><center id='KaysP'></center></pre></bdo></b><th id='KaysP'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='KaysP'><tfoot id='KaysP'></tfoot><dl id='KaysP'><fieldset id='KaysP'></fieldset></dl></div>
                      <tbody id='KaysP'></tbody>

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

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

                      <tfoot id='KaysP'></tfoot>

                            <bdo id='KaysP'></bdo><ul id='KaysP'></ul>
                            主站蜘蛛池模板: 国产一区二区三区www | 欧美精品日韩 | 欧美不卡一区 | 成人一区二区三区 | 亚洲欧美久久 | 日本成人福利视频 | 成年人免费看的视频 | 91啪影院| 国产精品欧美精品日韩精品 | 日韩精品一区二 | 欧美色偷拍 | 久久国产精品一区二区三区 | 亚洲色欲色欲www | 在线国产小视频 | 国产精品亚洲成在人线 | 天啪| 日本不卡一区 | 岛国av免费在线观看 | 天天干天天谢 | 草久视频| 在线观看免费国产 | 国产精品久久久久久久久久不蜜臀 | 亚州春色| 美女一级毛片 | 国产wwwcom| 国产91久久精品一区二区 | 亚洲人人 | 四色永久| 亚洲精品乱码久久久久久按摩观 | 国产欧美精品一区二区色综合 | 91影视| 日韩中文字幕网 | 精品久久国产 | 日韩精品视频在线 | 91网站在线播放 | www性色 | 日韩国产中文字幕 | 成人在线黄色 | 夜夜精品浪潮av一区二区三区 | 一区二区三区四区av | 国产精品成人国产乱一区 |