I am trying to play audio files from my local storage in a voice channel on Discord. The bot successfully joins the voice channel, but it fails to play the audio. Here’s my current implementation:
if message.content.startswith('$PlaySound'):
room_name = message.content.split(' ')[1]
voice_channel = get(message.guild.channels, name=room_name)
connected_channel = await voice_channel.connect()
connected_channel.play(discord.FFmpegPCMAudio(executable='C:/ffmpeg/bin/ffplay.exe', source='C:/ffmpeg/Sound.mp3'))
When I execute this code, I receive the following error:
Traceback (most recent call last):
File "F:/MyBot/venv/lib/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "F:/MyBot/main.py", line 41, in on_message
connected_channel.play(discord.FFmpegPCMAudio(executable='C:/ffmpeg/bin/ffplay.exe', source='C:/ffmpeg/Sound.mp3'))
AttributeError: module 'discord' has no attribute 'FFmpegPCMAudio'
Can anyone help me resolve this issue?