Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Discord.py bot中断mp3_Python_Discord_Bots - Fatal编程技术网

Python Discord.py bot中断mp3

Python Discord.py bot中断mp3,python,discord,bots,Python,Discord,Bots,由于mp3文件过长,机器人停止运行,试图将比特率更改为低。这是代码 @client.command(pass_context=True) async def bock(ctx): await ctx.message.delete() author = ctx.message.author channel = author.voice.channel voice = get(client.voice_clients, guild=ctx.guild) if

由于mp3文件过长,机器人停止运行,试图将比特率更改为低。这是代码

@client.command(pass_context=True)
async def bock(ctx):
    await ctx.message.delete()
    author = ctx.message.author
    channel = 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()
        voice.play(discord.FFmpegPCMAudio(executable=FFMexec, source="bock.mp3"))#, options = "-analyzeduration 1000000000 -i"
        while voice.is_playing():
            time.sleep(0.5)
        await voice.disconnect()
        
现在它开始工作了,谢谢你的回答

async def bock(ctx):
    await ctx.message.delete()
    author = ctx.message.author
    channel = 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()
        voice.play(discord.FFmpegPCMAudio(executable=FFMexec, source="bock.mp3"))#, options = "-analyzeduration 1000000000 -i"
        while voice.is_playing():
            await asyncio.sleep(5) # bot was frozen to death before
        await voice.disconnect()