Skip to content

~.player

Player

QueuedAudio dataclass

QueuedAudio(source: AudioSource, origin: AudioBeginOrigin)

Audio metadata in player queue.

source instance-attribute

source: AudioSource

The audio source to play from.

origin instance-attribute

The beginning origin of this audio.

AudioPlaybackState

Bases: IntEnum

The current state of the player's playback.

BUFFERING class-attribute instance-attribute

BUFFERING = 0

The player is loading the current audio.

IDLE class-attribute instance-attribute

IDLE = 1

The player is not currently playing any audio.

PAUSED class-attribute instance-attribute

PAUSED = 2

The player is currently paused.

PLAYING class-attribute instance-attribute

PLAYING = 3

The player is currently playing audio.

STOPPING class-attribute instance-attribute

STOPPING = 4

The player is stopping.

AudioPlayer

AudioPlayer(connection: VoiceConnection)

Responsible for all audio.

Create a new audio player.

PARAMETER DESCRIPTION
connection

The active voice connection.

TYPE: VoiceConnection

connection property

connection: VoiceConnection

The active connection that is responsible for this player.

current property

current: AudioSource | None

The currently playing audio, if present.

elapsed property

elapsed: float

The amount of seconds of the current audio that has been elapsed.

history property

history: list[AudioSource]

Get all audio previously played.

is_playing property

is_playing: bool

If the player has audio currently playing.

progress property

progress: float

Percentage of the current audio that has been completed (0.0-1.0).

queue property

queue: list[AudioSource]

Get all audio currently in queue.

remaining property

remaining: float

The amount of seconds remaining for the current audio.

state property

The current state of this player.

volume property

volume: float | str | None

If set, the player's default volume.

add_queue async

add_queue(
    source: AudioSource, *, autoplay: bool = True
) -> Result

Add an audio source to the queue.

PARAMETER DESCRIPTION
source

The source of the audio to add.

TYPE: AudioSource

autoplay

If the player should play this source if there's no audio currently loaded.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.

RAISES DESCRIPTION
TypeError
  • If the provided source doesn't inherit AudioSource.
  • If autoplay is not bool.

add_queue_bulk async

add_queue_bulk(
    sources: Iterable[AudioSource], *, autoplay: bool = True
) -> Result

Add a list of audio sources to the queue.

PARAMETER DESCRIPTION
sources

The sources of audio to add.

TYPE: Iterable[AudioSource]

autoplay

If the player should play the first source if there's no audio currently loaded.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.

RAISES DESCRIPTION
TypeError
  • If sources is not Iterable or its contents do not inherit AudioSource.
  • If autoplay is not bool.
ValueError

If sources is not at least 1 in length.

clear_history async

clear_history() -> Result

Clear all audio from history.

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.

clear_queue async

clear_queue() -> Result

Clear all audio from the queue.

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.

next async

next() -> Result

Play the next audio in queue.

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.

pause async

pause() -> Result

Pause the current audio.

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.

play async

play(source: AudioSource) -> Result

Play audio from a source.

PARAMETER DESCRIPTION
source

The source of the audio to play

TYPE: AudioSource

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.

RAISES DESCRIPTION
TypeError

If the provided source doesn't inherit AudioSource.

previous async

previous() -> Result

Play the latest previously played audio.

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.

remove_queue async

remove_queue(source: AudioSource) -> Result

Remove an audio source from the queue.

PARAMETER DESCRIPTION
source

The source of the audio to remove.

TYPE: AudioSource

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.

RAISES DESCRIPTION
TypeError

If the provided source doesn't inherit AudioSource.

resume async

resume() -> Result

Resume the current audio.

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.

set_priority

set_priority(priority: bool) -> None

Set if this player should play with priority voice enabled.

PARAMETER DESCRIPTION
priority

If the player should playback this audio with a prioritized speaking status.

TYPE: bool

RAISES DESCRIPTION
TypeError

If priority isn't bool.

set_volume

set_volume(volume: float | str | None = None) -> None

Set the default volume of this player. Can be None, any scaled value (1.0, 2.0, 0.5, etc.) or dB-based (-3dB, 0.5dB, etc.).

PARAMETER DESCRIPTION
volume

The volume to set as a default for this player - None uses connection/client configuration.

TYPE: float | str | None DEFAULT: None

RAISES DESCRIPTION
TypeError

If volume is provided and it's not float, int, or str.

shuffle async

shuffle() -> Result

Shuffle all audio currently in queue.

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.

stop async

stop() -> Result

Stop the current audio.

RETURNS DESCRIPTION
Result

If the operation was successful, with reason provided if otherwise.