<tfoot id='ZAGxu'></tfoot>

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

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

        • <bdo id='ZAGxu'></bdo><ul id='ZAGxu'></ul>
      2. <legend id='ZAGxu'><style id='ZAGxu'><dir id='ZAGxu'><q id='ZAGxu'></q></dir></style></legend>

      3. 需要帮助 Discord 机器人队列

        时间:2023-09-29
      4. <i id='aRJBa'><tr id='aRJBa'><dt id='aRJBa'><q id='aRJBa'><span id='aRJBa'><b id='aRJBa'><form id='aRJBa'><ins id='aRJBa'></ins><ul id='aRJBa'></ul><sub id='aRJBa'></sub></form><legend id='aRJBa'></legend><bdo id='aRJBa'><pre id='aRJBa'><center id='aRJBa'></center></pre></bdo></b><th id='aRJBa'></th></span></q></dt></tr></i><div id='aRJBa'><tfoot id='aRJBa'></tfoot><dl id='aRJBa'><fieldset id='aRJBa'></fieldset></dl></div>

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

            <tbody id='aRJBa'></tbody>

          <tfoot id='aRJBa'></tfoot>
            • <bdo id='aRJBa'></bdo><ul id='aRJBa'></ul>
                <legend id='aRJBa'><style id='aRJBa'><dir id='aRJBa'><q id='aRJBa'></q></dir></style></legend>

                  本文介绍了需要帮助 Discord 机器人队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我一直在尝试为不和谐机器人创建队列,而我的 >q 命令基本上可以作为 joinplay queue 同时进行.问题是它只能同时排队 2 首歌曲,所以我需要帮助让它排队多首歌曲

                  i've been tryin to make a queue for discord bot and my >q command basicaly work as join play queue at the same time. The problem is it only queues 2 songs at the same time so I need help making it queue multi songs

                  queues = {}
                  #check queue
                  def check_queue(ctx, id):
                    if queues[id] !=[]:
                      voice = ctx.guild.voice_client
                      voice.play(queues[id].pop(0))
                  #command
                  @client.command(pass_context = True)
                  async def q(ctx, url):
                    if (ctx.author.voice):
                      channel = ctx.message.author.voice.channel
                      voice = get(client.voice_clients, guild=ctx.guild)
                      if voice and voice.is_connected():
                        await voice.move_to(channel)
                      else:
                        voice = await channel.connect()
                    else:
                      await ctx.send('You are not in a voice channel')      
                    YDL_OPTIONS = {'format': 'bestaudio', 'noplaylist': 'True'}
                    FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
                    voice = get(client.voice_clients, guild=ctx.guild)
                    with YoutubeDL(YDL_OPTIONS) as ydl:
                        info = ydl.extract_info(url, download=False)
                    URL = info['url']
                    source = (FFmpegPCMAudio(URL, **FFMPEG_OPTIONS))
                    if voice.is_playing():
                      guild_id = ctx.message.guild.id
                      if guild_id in queues:
                        queues[guild_id].append(source)
                      else:
                        queues[guild_id]=[source]
                      await ctx.send('Deemo: Song added to queue')
                    else:
                        ctx.voice_client.stop()
                        voice.play(FFmpegPCMAudio(URL, **FFMPEG_OPTIONS), after=lambda x=0: check_queue(ctx, ctx.message.guild.id))
                        voice.is_playing()
                        await ctx.send('Playing: '+ info.get('title'))
                  

                  推荐答案

                  经过一番研究和搜索,我想出了一个简单的方法来让队列循环 2+ 首歌曲,添加 after=lambda x=0:check_queue(ctx, ctx.message.guild.id)check_queue 里面稍微改一下,就变成这样了

                  after I do some study and search I figure out an easy way to make the queue loop 2+ songs, add after=lambda x=0: check_queue(ctx, ctx.message.guild.id) inside check_queue and change a little and it will look like this

                  def check_queue(ctx, id):
                    if queues[id] !=[]:
                      voice = ctx.guild.voice_client
                      source = queues[id].pop(0)
                      voice.play(source, after=lambda x=0: check_queue(ctx, ctx.message.guild.id))
                  

                  这篇关于需要帮助 Discord 机器人队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:同步异步队列 下一篇:使用 Celery 创建动态队列

                  相关文章

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

                  2. <tfoot id='AE9kn'></tfoot>
                    1. <legend id='AE9kn'><style id='AE9kn'><dir id='AE9kn'><q id='AE9kn'></q></dir></style></legend>

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