use discord ext commands for slash comands and use load_dotenv. also the recording does not work, maybe this helps:
VoiceProtocol

class discord.VoiceProtocol(client, channel)
Methods

cleanup
connect
disconnect
on_voice_server_update

    on_voice_state_update

    A class that represents the Discord voice protocol.

    This is an abstract class. The library provides a concrete implementation under VoiceClient.

    This class allows you to implement a protocol to allow for an external method of sending voice, such as Lavalink or a native library implementation.

    These classes are passed to abc.Connectable.connect.

    Parameters

            client (Client) – The client (or its subclasses) that started the connection request.

            channel (abc.Connectable) – The voice channel that is being connected to.

    await on_voice_state_update(data, /)

        This function is a coroutine.

        An abstract method that is called when the client’s voice state has changed. This corresponds to VOICE_STATE_UPDATE.

        This method is not the same as the event. See: on_voice_state_update()

        Parameters

            data (dict) – The raw voice state payload.

    await on_voice_server_update(data, /)

        This function is a coroutine.

        An abstract method that is called when initially connecting to voice. This corresponds to VOICE_SERVER_UPDATE.

        Parameters

            data (dict) – The raw voice server update payload.

    await connect(*, timeout, reconnect, self_deaf=False, self_mute=False)

        This function is a coroutine.

        An abstract method called when the client initiates the connection request.

        When a connection is requested initially, the library calls the constructor under __init__ and then calls connect(). If connect() fails at some point then disconnect() is called.

        Within this method, to start the voice connection flow it is recommended to use Guild.change_voice_state() to start the flow. After which, on_voice_server_update() and on_voice_state_update() will be called. The order that these two are called is unspecified.

        Parameters

                timeout (float) – The timeout for the connection.

                reconnect (bool) – Whether reconnection is expected.

                self_mute (bool) –

                Indicates if the client should be self-muted.

                New in version 2.0.

                self_deaf (bool) –

                Indicates if the client should be self-deafened.

                New in version 2.0.

    await disconnect(*, force)

        This function is a coroutine.

        An abstract method called when the client terminates the connection.

        See cleanup().

        Parameters

            force (bool) – Whether the disconnection was forced.

    cleanup()

        This method must be called to ensure proper clean-up during a disconnect.

        It is advisable to call this from within disconnect() when you are completely done with the voice protocol instance.

        This method removes it from the internal state cache that keeps track of currently alive voice clients. Failure to clean-up will cause subsequent connections to report that it’s still connected.

AudioSource

class discord.AudioSource
Methods

cleanup
is_opus

    read

    Represents an audio stream.

    The audio stream can be Opus encoded or not, however if the audio stream is not Opus encoded then the audio format must be 16-bit 48KHz stereo PCM.

The audio source reads are done in a separate thread.

read()

    Reads 20ms worth of audio.

    Subclasses must implement this.

    If the audio is complete, then returning an empty bytes-like object to signal this is the way to do so.

    If is_opus() method returns True, then it must return 20ms worth of Opus encoded audio. Otherwise, it must be 20ms worth of 16-bit 48KHz stereo PCM, which is about 3,840 bytes per frame (20ms worth of audio).

    Returns

        A bytes like object that represents the PCM or Opus data.
    Return type

        bytes

is_opus()

    Checks if the audio source is already encoded in Opus.

cleanup()

    Called when clean-up is needed to be done.

    Useful for clearing buffer data or processes after it is done playing audio.