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

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

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

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

  • <tfoot id='EChgr'></tfoot>
      <bdo id='EChgr'></bdo><ul id='EChgr'></ul>
      1. 在 discord.py 中播放音軌隊(duì)列

        Playing a queue of audio tracks in discord.py(在 discord.py 中播放音軌隊(duì)列)

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

            <tfoot id='hnomj'></tfoot>

              <bdo id='hnomj'></bdo><ul id='hnomj'></ul>
                <tbody id='hnomj'></tbody>
              • <legend id='hnomj'><style id='hnomj'><dir id='hnomj'><q id='hnomj'></q></dir></style></legend>
                • <small id='hnomj'></small><noframes id='hnomj'>

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

                  問題描述

                  所以我在 discord.py 上制作了這個(gè)音樂不和諧機(jī)器人.這個(gè)機(jī)器人只是從我電腦上的本地 mp3 文件中播放一個(gè)播放列表.所以我有一個(gè)播放隊(duì)列的函數(shù),它是這樣的:

                  So I am making this music discord bot on discord.py. This bot just plays a playlist from local mp3 files on my computer. So I have a function that plays the queue and it goes like this:

                  def play_song(ctx, voice):
                      if len(queue) == 0:
                          print('All the songs have been played')
                          create_queue()
                          return
                  
                      song_ = queue[0][len('songs/'):-16]
                      voice.play(discord.FFmpegPCMAudio(queue[0]), after=lambda e: play_song(ctx, voice))
                      print(f'Now playing {song_}')
                      del queue[0]
                  

                  我想將此函數(shù)轉(zhuǎn)換為異步函數(shù),因?yàn)槲蚁M軌蛟诖撕瘮?shù)內(nèi)部的 discord.py 中發(fā)送消息并執(zhí)行其他操作.我面臨的問題是這一行的結(jié)果:

                  And I want to convert this function to an async function because I want to be able to send messages and do other things in discord.py inside this function. The problem I'm facing is a result of this line:

                  voice.play(discord.FFmpegPCMAudio(queue[0]), after=lambda e: play_song(ctx, voice))
                  

                  如果我讓這個(gè)函數(shù)成為一個(gè)異步函數(shù),那么我將不得不添加一個(gè) await 語句,如果我這樣做,它將是這樣的:

                  If I make this function an async function than I'll have to put an await statement, and If I do that it will be like this:

                  voice.play(discord.FFmpegPCMAudio(queue[0]), after=lambda e: await play_song(ctx, voice))
                  

                  問題在于它給了我錯(cuò)誤:在異步函數(shù)之外等待"所以我也嘗試使用 asyncio.run(),然后在第一首歌之后它給了我一個(gè)巨大的錯(cuò)誤滾動(dòng),接下來我該怎么辦?

                  The problem with that is that it's giving me the error: "await outside of async function" So I also tried using asyncio.run(), and then after the first song it's giving me a huge scroll of errors, What do I do next?

                  推薦答案

                  我找到了自己問題的答案.答案是使用 asyncio.Event()我是這樣做的:

                  I have found an answer to my own question. The answer is to use asyncio.Event() I did it like this:

                  async def play_song(ctx, voice):
                      global stop_playing, pos_in_q, time_from_song
                      event = asyncio.Event()
                      event.set()
                      while True:
                          await event.wait()
                          event.clear()
                          if len(queue) == pos_in_q - 1:
                              await ctx.send('Party is over! use the `.arse-play` to play again.')
                              print('Party is over!')
                              create_queue()
                              break
                          if stop_playing is True:
                              stop_playing = False
                              break
                  
                          song_ = queue[pos_in_q][len('songs/'):]
                          voice.play(discord.FFmpegPCMAudio(queue[pos_in_q]), after=lambda e: event.set())
                          print(f'Now playing {song_}')
                          time_from_song = time.time()
                          pos_in_q += 1
                  

                  這篇關(guān)于在 discord.py 中播放音軌隊(duì)列的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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)更改角色顏色)
                  <legend id='rKImy'><style id='rKImy'><dir id='rKImy'><q id='rKImy'></q></dir></style></legend>
                      <bdo id='rKImy'></bdo><ul id='rKImy'></ul>
                      <tfoot id='rKImy'></tfoot>
                        <i id='rKImy'><tr id='rKImy'><dt id='rKImy'><q id='rKImy'><span id='rKImy'><b id='rKImy'><form id='rKImy'><ins id='rKImy'></ins><ul id='rKImy'></ul><sub id='rKImy'></sub></form><legend id='rKImy'></legend><bdo id='rKImy'><pre id='rKImy'><center id='rKImy'></center></pre></bdo></b><th id='rKImy'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='rKImy'><tfoot id='rKImy'></tfoot><dl id='rKImy'><fieldset id='rKImy'></fieldset></dl></div>

                      • <small id='rKImy'></small><noframes id='rKImy'>

                              <tbody id='rKImy'></tbody>

                            主站蜘蛛池模板: 亚洲一区 | 91精品中文字幕一区二区三区 | 午夜视频网站 | 狠狠做六月爱婷婷综合aⅴ 国产精品视频网 | 国产精品一区久久久 | 国产福利在线播放 | 亚洲精品一区在线观看 | 国产精品久久久久久中文字 | 久操亚洲 | 久久99国产精一区二区三区 | 中文字幕精品一区二区三区精品 | 在线中文字幕视频 | 欧美精品在线一区 | 男女在线免费观看 | 狠狠综合久久av一区二区小说 | 久久1区 | 成人在线观看免费观看 | 中文字幕国产视频 | 麻豆久久久9性大片 | 妖精视频一区二区三区 | 99视频在线| 成人免费视屏 | 四虎影视1304t | 精品欧美一区二区三区久久久 | 日本免费小视频 | 欧美日韩一区二区三区在线观看 | 欧美一区二区 | 亚洲一区在线日韩在线深爱 | 日本三级全黄三级三级三级口周 | 国产伦一区二区三区四区 | 黄频免费 | 久久久999精品 | 国户精品久久久久久久久久久不卡 | 久久男人 | 视频在线观看一区二区 | 国产精品99久久久精品免费观看 | 懂色av一区二区三区在线播放 | 一级美国黄色片 | 国产成人精品网站 | 国产精品久久久久久 | 一级片免费视频 |