Вот код, подскажите как сделать чтобы музыка играла бесконечно, пока я ее сам не остановлю.
Напишите что добавить пожалуйста, буду благодарен
@client.command(pass_context=True, aliases=['u', 'ur'])
async def url(ctx, url: str):
song_there = os.path.isfile("song.mp3")
try:
if song_there:
os.remove("song.mp3")
print("Removed old song file")
await ctx.send("Бот загружает музыку...")
except PermissionError:
print("Trying to delete song file, but it's being played")
await ctx.send("ERROR: Music playing")
return
await ctx.send("Почти готово...")
voice = get(client.voice_clients, guild=ctx.guild)
ydl_opts = {
'format' : 'bestaudio/best',
'postprocessors' : [{
'key' : 'FFmpegExtractAudio',
'preferredcodec' : 'mp3',
'preferredquality' : '192'
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
print("Downloading audio now\n")
ydl.download([url])
for file in os.listdir("./"):
if file.endswith(".mp3"):
name = file
print(f"Renamed File: {file}\n")
os.rename(file, "song.mp3")
voice.play(discord.FFmpegPCMAudio("song.mp3"), after=lambda e: print("Song done!"))
await ctx.send("Готово!")
voice.source = discord.PCMVolumeTransformer(voice.source)
voice.source.volume = 0.09
nname = name.rsplit("-", 2)
await ctx.send(f"**Играет трек**: {nname[0]}")
print("playing\n")