API Reference#
Pool#
- class slate.Pool#
- nodes: dict[str, slate.node.Node[BotT, PlayerT]] = {}#
- classmethod await create_node(*, bot: BotT, session: Optional[ClientSession] = None, provider: Provider, identifier: str, host: str, port: str, password: str, secure: bool = False, resume_key: Optional[str] = None, rest_url: Optional[str] = None, ws_url: Optional[str] = None, json_dumps: Optional[Callable[[...], str]] = None, json_loads: Optional[Callable[[...], dict[str, Any]]] = None, spotify_client_id: Optional[str] = None, spotify_client_secret: Optional[str] = None) Node[BotT, PlayerT]#
Node#
- class slate.Node#
Node’s handle interactions between your bot and a provider server such as obsidian or lavalink. This includes connecting to the websocket, searching for tracks, and managing player state.
- __init__(*, bot: BotT, session: Optional[ClientSession] = None, provider: Provider, identifier: str, host: str, port: str, password: str, secure: bool = False, resume_key: Optional[str] = None, rest_url: Optional[str] = None, ws_url: Optional[str] = None, json_dumps: Optional[Callable[[...], str]] = None, json_loads: Optional[Callable[[...], dict[str, Any]]] = None, spotify_client_id: Optional[str] = None, spotify_client_secret: Optional[str] = None) None#
- Parameters
bot – The bot instance that this node belongs to.
session – The aiohttp client session to use for websocket/rest communication. Optional, if
None(default), a new one will be created.provider – An enum denoting which external application this node is connecting to, such as
slate.Provider.OBSIDIAN.identifier – A unique identifier for this node.
host – The hostname of the provider server.
port – The port of the provider server.
password – The password for the provider server.
secure – Whether to use secure connections for websocket/rest communication. Optional, defaults to
False.resume_key – A resuming key which is passed to the provider server when connecting. Optional, defaults to
None.rest_url – The URL to the provider server’s REST API. Optional, if
None(default), the URL will be constructed from the provided host and port.ws_url – The URL to the provider server’s websocket. Optional, if
None(default), the URL will be constructed from the provided host and port.json_dumps – A callable which will be used to serialize JSON data. Optional, if
None(default),json.dumps()will be used.json_loads – A callable which will be used to deserialize JSON data. Optional, if
None(default),json.loads()will be used.spotify_client_id – The client ID from a Spotify API application. Optional, if
None(default), Spotify integration will be disabled.spotify_client_secret – The client secret from a Spotify API application. Optional, if
None(default), Spotify integration will be disabled.
- property bot: slate.types.BotT#
The bot instance that this node belongs to.
- await disconnect(*, force: bool = False) None#
Disconnects this node from its provider server.
- Parameters
force (bool) – Whether to force disconnect players with
Player.disconnect(). Defaults toFalse.
- await search(search: str, /, *, source: Source = Source.NONE, **extras: Any) Search#
Requests search results from this node’s provider server, or other services like spotify.
- Parameters
search – The search query.
source – The source to request results from. Defaults to
Source.NONE.
- Raises
NoResultsFound – If no results were found.
SearchFailed – If the search failed.
HTTPError – If the HTTP request failed.
Player#
- class slate.Player#
- __init__(client: ~slate.types.BotT = <MISSING>, channel: discord.channel.VoiceChannel | discord.channel.StageChannel = <MISSING>, /, *, node: ~typing.Optional[~slate.node.Node[~slate.types.BotT, ~slate.types.PlayerT]] = None) None#
- Parameters
node – The node this player should be attached to, if
Nonethe player will be attached to the first node found from the pool.
Warning
To connect to a voice channel you must construct an instance of this class, setting the
nodeargument (and extras, if subclassing) but not theclientorchannelarguments. You can then pass it to theclsargument ofdiscord.abc.Connectable.connect().
- property bot: slate.types.BotT#
The bot this player is attached to.
- property voice_channel: discord.channel.VoiceChannel | discord.channel.StageChannel#
The voice channel this player is connected to.
- property node: slate.node.Node[slate.types.BotT, slate.types.PlayerT]#
The node this player is attached to.
- property current_track_id: str | None#
The ID of the current track. This is
Noneif no track is playing.
- property current: slate.objects.track.Track | None#
The current track. This is
Noneif no track is playing.
- property filter: slate.objects.filters.filter.Filter | None#
The players current filter, if set.
- property listeners: list[discord.member.Member]#
A list of members in the players voice channel.
Notes
This only returns non-bot members who are not deafened.
- await connect(*, timeout: Optional[float] = None, reconnect: Optional[bool] = None, self_mute: bool = False, self_deaf: bool = True) None#
Connects the player to its voice channel.
- await disconnect(*, force: bool = False) None#
Disconnects the player from its voice channel and removed it from the node.
- await play(track: Track, /, *, start_time: Optional[int] = None, end_time: Optional[int] = None, no_replace: bool = False) None#
Plays the given track.
Queue#
- class slate.Queue#
-
- property loop_mode: slate.objects.enums.QueueLoopMode#
- set_loop_mode(mode: QueueLoopMode, /) None#
- await get_wait() Item#
Objects#
Track#
Collection#
Search#
- class slate.Search#
- __init__(*, source: Source, type: str, result: spotipy.objects.album.Album | spotipy.objects.playlist.Playlist | spotipy.objects.artist.Artist | spotipy.objects.track.Track | list[slate.objects.track.Track] | slate.objects.collection.Collection, tracks: list[slate.objects.track.Track]) None#
- property source: slate.objects.enums.Source#
- property result: spotipy.objects.album.Album | spotipy.objects.playlist.Playlist | spotipy.objects.artist.Artist | spotipy.objects.track.Track | list[slate.objects.track.Track] | slate.objects.collection.Collection#
- property tracks: list[slate.objects.track.Track]#
Events#
TrackStart#
TrackEnd#
TrackStuck#
TrackException#
WebsocketOpen#
WebsocketClosed#
Filters#
ChannelMix#
- class slate.ChannelMix#
- __init__(*, left_to_left: float = 1.0, left_to_right: float = 0.0, right_to_left: float = 0.0, right_to_right: float = 1.0) None#
- classmethod mono() Self#
- classmethod only_left() Self#
- classmethod full_left() Self#
- classmethod only_right() Self#
- classmethod full_right() Self#
- classmethod switch() Self#
Distortion#
Equalizer#
Karaoke#
LowPass#
Rotation#
Timescale#
Tremolo#
Vibrato#
Volume#
Filter#
- class slate.Filter#
- __init__(filter: Optional[Filter] = None, channel_mix: Optional[ChannelMix] = None, distortion: Optional[Distortion] = None, equalizer: Optional[Equalizer] = None, karaoke: Optional[Karaoke] = None, low_pass: Optional[LowPass] = None, rotation: Optional[Rotation] = None, timescale: Optional[Timescale] = None, tremolo: Optional[Tremolo] = None, vibrato: Optional[Vibrato] = None, volume: Optional[Volume] = None) None#
Enums#
Provider#
QueueLoopMode#
Source#
- class slate.Source#
An enumeration.
- BANDCAMP = 'bandcamp'#
- YARN = 'getyarn.io'#
- HTTP = 'http'#
- LOCAL = 'local'#
- NICO = 'niconico'#
- SOUNDCLOUD = 'soundcloud'#
- TWITCH = 'twitch'#
- VIMEO = 'vimeo'#
- YOUTUBE = 'youtube'#
- YOUTUBE_MUSIC = 'youtube_music'#
- SPOTIFY = 'spotify'#
- UNKNOWN = 'unknown'#
- NONE = ''#
Exceptions#
SlateError#
NodeAlreadyExists#
NodeNotFound#
NoNodesConnected#
NodeConnectionError#
InvalidNodePassword#
NodeNotConnected#
HTTPError#
NoResultsFound#
SearchFailed#
Utils#
SPOTIFY_URL_REGEX#
- slate.SPOTIFY_URL_REGEX#
A regex that matches spotify URLs for tracks, albums, playlists, and artists.
MISSING#
- slate.MISSING#
A sentinel value that is used to indicate a missing value with distinction from None.