Pool¶
- class pomice.pool.Node(*, pool: Type[NodePool], bot: Bot, host: str, port: int, password: str, identifier: str, secure: bool = False, heartbeat: int = 120, resume_key: str | None = None, resume_timeout: int = 60, loop: AbstractEventLoop | None = None, session: ClientSession | None = None, spotify_client_id: str | None = None, spotify_client_secret: str | None = None, apple_music: bool = False, fallback: bool = False, logger: Logger | None = None)[source]¶
Bases:
objectThe base class for a node. This node object represents a Lavalink node. To enable Spotify searching, pass in a proper Spotify Client ID and Spotify Client Secret To enable Apple music, set the “apple_music” parameter to “True”
- available¶
- property bot: Client¶
Property which returns the discord.py client linked to this node
- 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.
- async connect(*, reconnect: bool = False) Node[source]¶
Initiates a connection with a Lavalink node and adds it to the node pool.
- async disconnect() None[source]¶
Disconnects a connected Lavalink node and removes it from the node pool. This also destroys any players connected to the node.
- get_player(guild_id: int) Player | None[source]¶
Takes a guild ID as a parameter. Returns a pomice Player object or None.
- async get_recommendations(*, track: Track, ctx: Context | None = None) List[Track] | Playlist | None[source]¶
Gets recommendations from either YouTube or Spotify. The track that is passed in must be either from YouTube or Spotify or else this will not work. 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: 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, 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 is_connected: bool¶
Property which returns whether this node is connected or not
- property latency: float¶
Property which returns the latency of the node
- property ping: float¶
Alias for Node.latency, returns the latency of the node
- property player_count: int¶
Property which returns how many players are connected to this node
- property players: Dict[int, Player]¶
Property which returns a dict containing the guild ID and the player object.
- async search_spotify_recommendations(query: str, *, ctx: Context | None = None, filters: List[Filter] | None = None) List[Track] | Playlist | None[source]¶
Searches for recommendations on Spotify and returns a list of tracks based on the query. You must have Spotify enabled for this to work. You can pass in a discord.py Context object to get a Context object on all tracks that get recommended.
- class pomice.pool.NodePool[source]¶
Bases:
objectThe base class for the node pool. This holds all the nodes that are to be used by the bot.
- async classmethod create_node(*, bot: Bot, host: str, port: int, password: str, identifier: str, secure: bool = False, heartbeat: int = 120, resume_key: str | None = None, resume_timeout: int = 60, loop: AbstractEventLoop | None = None, spotify_client_id: str | None = None, spotify_client_secret: str | None = None, session: ClientSession | None = None, apple_music: bool = False, fallback: bool = False, logger: Logger | None = None) Node[source]¶
Creates a Node object to be then added into the node pool. For Spotify searching capabilites, pass in valid Spotify API credentials.
- classmethod get_best_node(*, algorithm: NodeAlgorithm) Node[source]¶
Fetches the best node based on an NodeAlgorithm. This option is preferred if you want to choose the best node from a multi-node setup using either the node’s latency or the node’s voice region.
Use NodeAlgorithm.by_ping if you want to get the best node based on the node’s latency.
Use NodeAlgorithm.by_players if you want to get the best node based on how players it has. This method will return a node with the least amount of players
- classmethod get_node(*, identifier: str | None = None) Node[source]¶
Fetches a node from the node pool using it’s identifier. If no identifier is provided, it will choose a node at random.
- property node_count: int¶