Python Discord Bot for Playing Local Audio Files

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?

I suggest checking the way you are importing the Discord library modules. Ensure that your import statements at the beginning of your script specifically import the necessary components, such as from discord.ext import commands and from discord import FFmpegPCMAudio. Additionally, verify your py-cord or discord-py package version to ensure compatibility with the FFmpegPCMAudio class. Another aspect is to check current permissions of the bot, making sure it can actually play audio in the voice channel without restrictions or needing additional permissions.