user15626878
user15626878

Reputation:

Im trying to make a simple Discord.Py bot that is able to play music but keep getting the same error

My current code to play music is as follows:

@bot.command()
async def play(ctx):
    if not ctx.voice_client:  # checks to make sure bot is not already in voice channel
        audio_source = 'my_music.mp3'
        voice_channel = ctx.message.author.voice.channel
        ffmpeg = r'C:\Users\dmolp\PycharmProjects\DiscordBot\ffmpeg\ffmpeg\bin'
        await voice_channel.connect()
        voice_client = ctx.voice_client
        voice_client.play(discord.FFmpegPCMAudio(executable=ffmpeg, source=audio_source))

The issue is whenever I run it and use the !play command the bot joins the voice channel just fine, but it does not play music and I get this error,

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: PermissionError: [WinError 5] Access is denied

I'm completely stumped on this one and any help is appreciated!

Upvotes: 1

Views: 547

Answers (1)

Atharva Gulve
Atharva Gulve

Reputation: 34

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: PermissionError: [WinError 5] Access is denied

This error is thrown because your app is unable to Access. Check the documentation [Exceptions in module] for the solution. Solutions:

  1. Try running Discord.py as an administrator (press win+x >> click Command prompt [admin] >> run discord.py)

Upvotes: 1

Related Questions