So I am making this music discord bot on discord.py. This bot just plays a playlist from local mp3 files on my computer. So I have a function that plays the queue and it goes like this:
def play_song(ctx, voice):
if len(queue) == 0:
print('All the songs have been played')
create_queue()
return
song_ = queue[0][len('songs/'):-16]
voice.play(discord.FFmpegPCMAudio(queue[0]), after=lambda e: play_song(ctx, voice))
print(f'Now playing {song_}')
del queue[0]
And I want to convert this function to an async function because I want to be able to send messages and do other things in discord.py inside this function. The problem I'm facing is a result of this line:
voice.play(discord.FFmpegPCMAudio(queue[0]), after=lambda e: play_song(ctx, voice))
If I make this function an async function than I'll have to put an await statement, and If I do that it will be like this:
voice.play(discord.FFmpegPCMAudio(queue[0]), after=lambda e: await play_song(ctx, voice))
The problem with that is that it's giving me the error:
"await outside of async function"
So I also tried using asyncio.run()
, and then after the first song it's giving me a huge scroll of errors, What do I do next?