I'm trying to program a discord bot with discord.py, the main goal right now is to have my bot join a voice channel and play an audio file that's on my laptop.
@client.command()
async def sing(ctx):
user = ctx.author.voice
if user != None:
channel_chat = ctx.author.voice.channel
await channel_chat.connect()
player = discord.FFmpegPCMAudio(executable="C:/Path_Program/ffmpeg.exe", source=r"C:UsersialwaDesktopMiscMusicelda's Lullaby Ancient Tune Hyrule Warriors Age of Calamity Soundtrack.mp3")
player.start()
else:
await ctx.send("Beep beep! (Be in a voice channel please!)")
This is the block of code that's suppose to play a file, the bot joins the channel just fine but fails to play audio. I do have ffmpeg-python installed and already tried installing ffmpeg but both or one at a time brings the same error.
The error itself in full is here
Ignoring exception in command sing:
Traceback (most recent call last):
File "C:UsersialwaPycharmProjectsTYvenvlibsite-packagesdiscordextcommandscore.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:UsersialwaPycharmProjectsTYmain.py", line 29, in sing
player.start()
AttributeError: 'FFmpegPCMAudio' object has no attribute 'start'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:UsersialwaPycharmProjectsTYvenvlibsite-packagesdiscordextcommandsot.py", line 902, in invoke
await ctx.command.invoke(ctx)
File "C:UsersialwaPycharmProjectsTYvenvlibsite-packagesdiscordextcommandscore.py", line 864, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:UsersialwaPycharmProjectsTYvenvlibsite-packagesdiscordextcommandscore.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'FFmpegPCMAudio' object has no attribute 'start'
If anyone can help me understand what to do to fix this problem it would be appreciated!
question from:
https://stackoverflow.com/questions/65941297/attributeerror-ffmpegpcmaudio-object-has-no-attribute-start 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…