Discord.py: Command raised an exception: TypeError: __init__() missing 1 required keyword-only argument: ‘args’

  background-music, bots, discord.py, python

I tried to make this discord bot that plays music like a normal music bot,i used ffmpeg to download the song but when it needs to play it i get this error:
Command raised an exception: TypeError: __init__() missing 1 required keyword-only argument: 'args',I don’t even know if it is an error to my code or when i type $play link in discord something is wrong with the way i am typing in it because of my code.
Here is my code


async def play(ctx,url):
    song_there = os.path.isfile("song.mp3")
    try:
        if song_there:
            os.remove("song.mp3")
    except PermissionError:
        await ctx.send("asteapta sa se termine")
        return

    VoiceChannel = discord.utils.get(ctx.guild.voice_channels, name="General")
    await VoiceChannel.connect()
    voice = discord.utils.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:
        ydl.download([url])
    for file in os.listdir("./"):
        if file.endswith(".mp3"):

            os.rename(file, "song.mp3")
    voice.play(discord.FFmpegAudio("song.mp3"))
    
        


@client.command()
async def leave(ctx):
    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
    if voice.is_connected():
        await voice.disconnect()
    else:
        await ctx.send("Botul nu este conectat la nici un canal")

@client.command()

async def pause(ctx):
    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
    if voice.is_playing():
        voice.pause()
    else:
        await ctx.send("Nu este nici o melodie pusa")

@client.command()

async def resume(ctx):
    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
    if voice.is_paused():
        voice.resume()
    else:
        await ctx.send("Botul nu e pe pauza")

@client.command

async def stop(ctx):
    voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
    voice.stop()

if __name__ == "__main__":

    client.run("xxxx")

Source: Python Questions

LEAVE A COMMENT