Python Discord.py bot中断mp3
由于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
@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()