devoxin/Lavalink.py

Help with Music Bot Code

ephiiPen opened this issue · 2 comments

@commands.command()
async def play(self, ctx, url):
song_there = os.path.isfile("song.mp3")
try:
if song_there:
os.remove("song.mp3")
except PermissionError:
await ctx.send("Wait for the current playing music to end or use the 'stop' command")

    voiceChannel = discord.utils.get(ctx.guild.voice_channels)
    await voiceChannel.connect()
    voice = discord.utils.get(self.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:
        ydl.download([url])
    for file in os.listdir("./"):
        if file.endswith(".mp3"):
            os.rename(file, "song.mp3")
    voice.play(discord.FFmpegPCMAudio('song.mp3'))
    
    
   **This is my current code I'm using to play music through my bot, but after some searching over the internet, I am unsure of how to have the bot queue music, because whenever I try to queue two songs, it'll say in the terminal that the bot is already connected to the voice channel. I couldn't get any other help so maybe I'd be able to get some here.. Thanks!**

You're looking in the wrong place. This is the issue tracker for Lavalink.py, a wrapper for Lavalink. You're using ytdl/ffmpeg which is a completely different system entirely. You'd have better luck asking in https://discord.gg/dpy

Wrong place to ask for help and not even related to Lavalink.py.
Ask for help in discord.gg/dpy or discord.gg/python