如何循环播放整个歌曲队列而不是一首歌曲?

所以我需要知道如何使loop命令循环所有已添加的歌曲,而不仅仅是当前歌曲。

我曾尝试循环SongQueue类,但我觉得做错了

class SongQueue(asyncio.Queue):
    def __getitem__(self,item):
        if isinstance(item,slice):
            return list(itertools.islice(self._queue,item.start,item.stop,item.step))
        else:
            return self._queue[item]

    def __iter__(self):
        return self._queue.__iter__()

    def __len__(self):
        return self.qsize()

    def clear(self):
        self._queue.clear()

    def shuffle(self):
        random.shuffle(self._queue)

    def remove(self,index: int):
        del self._queue[index]

#--Now for the loop command:--
    @commands.command(name='loop')
    async def _loop(self,ctx: commands.Context):
        """Loops the currently playing song.
        Invoke this command again to unloop the song.
        """

        if not ctx.voice_state.is_playing:
            return await ctx.send('Nothing being played at the moment.')

        # Inverse boolean value to loop and unloop.
        ctx.voice_state.loop = not ctx.voice_state.loop
        await ctx.message.add_reaction('✅')

此处提供完整的开源代码:https://gist.github.com/vbe0201/ade9b80f2d3b64643d854938d40a0a2d#file-music_bot_example-py-L1。我仍在尝试学习python,所以我认为这很简单。

lh2009168 回答:如何循环播放整个歌曲队列而不是一首歌曲?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3129996.html

大家都在问