Player¶
- class pomice.player.Filters[source]¶
Bases:
objectHelper class for filters
- edit_filter(*, filter_tag: str, to_apply: Filter) None[source]¶
Edits a filter in the list of filters applied using its filter tag and replaces it with the new filter.
- property empty: bool¶
Property which checks if the filter list is empty
- has_filter(*, filter_tag: str) bool[source]¶
Checks if a filter exists in the list of filters using its filter tag
- has_filter_type(*, filter_type: Filter) bool[source]¶
Checks if any filters applied match the specified filter type.
- property has_global: bool¶
Property which checks if any applied filters are global
- property has_preload: bool¶
Property which checks if any applied filters were preloaded
- class pomice.player.Player(client: Client, channel: VoiceChannel, *, node: Node | None = None)[source]¶
Bases:
VoiceProtocolThe base player class for Pomice. In order to initiate a player, you must pass it in as a cls when you connect to a channel. i.e:
`py await ctx.author.voice.channel.connect(cls=pomice.Player) `- async add_filter(_filter: Filter, fast_apply: bool = False) Filters[source]¶
Adds a filter to the player. Takes a pomice.Filter object. This will only work if you are using a version of Lavalink that supports filters. If you would like for the filter to apply instantly, set the fast_apply arg to True.
(You must have a song playing in order for fast_apply to work.)
- property adjusted_length: float¶
Property which returns the player’s track length in milliseconds adjusted for rate
- property adjusted_position: float¶
Property which returns the player’s position in a track in milliseconds adjusted for rate
- property bot: Client¶
Property which returns the bot associated with this player instance
- async build_track(identifier: str, ctx: Context | None = None) Track[source]¶
Builds a track using a valid track identifier
You can also pass in a discord.py Context object to get a Context object on the track it builds.
- channel: VoiceChannel¶
- client: Client¶
- async connect(*, timeout: float, reconnect: bool, self_deaf: bool = False, self_mute: bool = False) None[source]¶
-
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 callsconnect(). Ifconnect()fails at some point thendisconnect()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()andon_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.
- timeout:
- async edit_filter(*, filter_tag: str, edited_filter: Filter, fast_apply: bool = False) Filters[source]¶
Edits a filter from the player using its filter tag and a new filter of the same type. The filter to be replaced must have the same tag as the one you are replacing it with. This will only work if you are using a version of Lavalink that supports filters.
If you would like for the filter to apply instantly, set the fast_apply arg to True.
(You must have a song playing in order for fast_apply to work.)
- async get_recommendations(*, track: Track, ctx: Context | None = None) List[Track] | Playlist | None[source]¶
Gets recommendations from either YouTube or Spotify. You can pass in a discord.py Context object to get a Context object on all tracks that get recommended.
- async get_tracks(query: str, *, ctx: commands.Context | None = None, search_type: SearchType | None = SearchType.ytsearch, filters: List[Filter] | None = None) List[Track] | Playlist | None[source]¶
Fetches tracks from the node’s REST api to parse into Lavalink.
If you passed in Spotify API credentials when you created the node, you can also pass in a Spotify URL of a playlist, album or track and it will be parsed accordingly.
You can pass in a discord.py Context object to get a Context object on any track you search.
You may also pass in a List of filters to be applied to your track once it plays.
- property guild: Guild¶
Property which returns the guild associated with the player
- property is_connected: bool¶
Property which returns whether or not the player is connected
- property is_dead: bool¶
Returns a bool representing whether the player is dead or not. A player is considered dead if it has been destroyed and removed from stored players.
- property is_paused: bool¶
Property which returns whether or not the player has a track which is paused or not.
- property is_playing: bool¶
Property which returns whether or not the player is actively playing a track.
- async on_voice_server_update(data: VoiceServerUpdate) None[source]¶
-
An abstract method that is called when initially connecting to voice. This corresponds to
VOICE_SERVER_UPDATE.Parameters¶
- async on_voice_state_update(data: GuildVoiceState) None[source]¶
-
An abstract method that is called when the client’s voice state has changed. This corresponds to
VOICE_STATE_UPDATE.Warning
This method is not the same as the event. See:
on_voice_state_update()Parameters¶
- data:
dict The raw :ddocs:`voice state payload <resources/voice#voice-state-object>`.
- data:
- async play(track: Track, *, start: int = 0, end: int = 0, ignore_if_playing: bool = False) Track[source]¶
Plays a track. If a Spotify track is passed in, it will be handled accordingly.
- property position: float¶
Property which returns the player’s position in a track in milliseconds
- property rate: float¶
Property which returns the player’s current rate
- async remove_filter(filter_tag: str, fast_apply: bool = False) Filters[source]¶
Removes a filter from the player. Takes a filter tag. This will only work if you are using a version of Lavalink that supports filters. If you would like for the filter to apply instantly, set the fast_apply arg to True.
(You must have a song playing in order for fast_apply to work.)
- async reset_filters(*, fast_apply: bool = False) None[source]¶
- Resets all currently applied filters to their default parameters.
You must have filters applied in order for this to work. If you would like the filters to be removed instantly, set the fast_apply arg to True.
(You must have a song playing in order for fast_apply to work.)
- async seek(position: float) float[source]¶
Seeks to a position in the currently playing track milliseconds
- async set_volume(volume: int) int[source]¶
Sets the volume of the player as an integer. Lavalink accepts values from 0 to 500.
- property volume: int¶
Property which returns the players current volume