Getting Started:
You can view documentation on the core library here:
You can view documentation on the extension here:
Obsidian.py Documentation¶
Node¶
Node¶
- class obsidian.Node(*args, **kwargs)¶
Represents a connection to Obsidian that manages requests and websockets.
- Parameters
bot (
discord.Client) – The client or bot that this node belongs to.host (str) – The IP of the host that Obsidian is running on.
port (str) – The port of the host that Obsidian is running on.
password (Optional[str]) – The password needed to connect to Obsidian.
identifier (Optional[str]) – The name to use to refer to this node. Defaults to ‘MAIN’
region (Optional[
discord.VoiceRegion]) – The voice region this node will be in.
- property bot: Union[discord.client.Client, discord.shard.AutoShardedClient, discord.ext.commands.bot.Bot, discord.ext.commands.bot.AutoShardedBot]¶
The
discord.Clientthat this node corresponds to.- Type
- async connect(*, session: Optional[aiohttp.client.ClientSession] = None, loop: Optional[asyncio.events.AbstractEventLoop] = None) None¶
Establishes a websocket connection for this node.
- Parameters
session (Optional[
aiohttp.ClientSession]) – The session to use when connecting.loop (Optional[
asyncio.AbstractEventLoop]) – The event loop to use when connecting.
- async decode_track(id: str, /, *, cls: type = <class 'obsidian.track.Track'>, **kwargs) Optional[obsidian.track.Track]¶
This function is a coroutine.
Decodes a track given it’s Base 64 ID.
- Parameters
- Returns
The decoded track, if any.
- Return type
Optional[
Track]
See also
- async decode_tracks(ids: str, /, *, cls: type = <class 'obsidian.track.Track'>, **kwargs) Optional[List[obsidian.track.Track]]¶
This function is a coroutine.
Decodes multiple tracks, given their Base 64 ID’s.
- Parameters
- Returns
A list of constructed tracks, if any.
- Return type
Optional[List[
Track]]
See also
- async destroy(*, force: bool = False) None¶
Disconnects, deletes, and destroys this node.
- Parameters
force (bool, default: False) – Whether or not to force disconnection.
- destroy_player(guild: Union[discord.guild.Guild, discord.object.Object, int]) None¶
Destroys and deletes a player.
- Parameters
guild (Union[
discord.Guild,discord.Object, int]) – The player’s corresponding guild.
- async disconnect(*, force: bool = False) None¶
Disconnects the current websocket connection for this node.
- Parameters
force (bool, default: False) – Whether or not to force disconnection.
- get_player(guild: Union[discord.guild.Guild, discord.object.Object, int], cls: type = <class 'obsidian.player.Player'>, must_exist: bool = False, *args, **kwargs) Optional[obsidian.player.Player]¶
Gets an existing
Player, or if not found, creates it.- Parameters
guild (Union[
discord.Guild,discord.Object, int]) – The guild that this player corresponds to.cls (type, default:
Player) – The class to cast the player to.must_exist (bool, default: False) – Whether or not to return None if the player doesn’t already exist.
args – Extra arguments to pass into the class constructor.
kwargs – Extra keyword arguments to pass into the class constructor.
- Returns
The player found, or if it didn’t exist, created.
- Return type
- property region: Optional[discord.enums.VoiceRegion]¶
The voice region for this node, specified in the constructor.
- Type
- async search_track(*args, **kwargs)¶
Searches for one single track given a query or URL.
Warning
If the track is a direct URL, the source kwarg will be ignored.
- Parameters
query (str) – The search query or URL.
source (Optional[
Source]) – The source that the track should come from.cls (type, default:
Track) – The class to cast the track to.suppress (bool, default: False) – Whether or not to suppress
NoSearchMatchesFound
- Returns
The track or playlist that was found, if any.
- Return type
- async search_tracks(*args, **kwargs)¶
Searches for multiple tracks given a query or URL.
Warning
If the track is a direct URL, the source kwarg will be ignored.
Warning
If a playlist is found, the return type will not be a list, rather just the playlist itself.
- Parameters
query (str) – The search query or URL.
source (Optional[
Source]) – The source that the tracks should come from.cls (type, default:
Track) – The class to cast the tracks to.suppress (bool, default: False) – Whether or not to suppress
NoSearchMatchesFoundlimit (Optional[int]) – The maximum amount of tracks to return.
- Returns
A list of tracks found, or a playlist.
- Return type
- class obsidian.BaseNode(bot: Union[discord.client.Client, discord.shard.AutoShardedClient, discord.ext.commands.bot.Bot, discord.ext.commands.bot.AutoShardedBot], host: str = '127.0.0.1', port: Union[str, int] = '3030', password: Optional[str] = None, identifier: Optional[str] = None, region: Optional[discord.enums.VoiceRegion] = None, *, session: Optional[aiohttp.client.ClientSession] = 'None', loop: Optional[asyncio.events.AbstractEventLoop] = 'None', heartbeat: Optional[float] = 'None', secure: Optional[bool] = 'None', **kwargs)¶
- class obsidian.BaseNode(bot: Union[discord.client.Client, discord.shard.AutoShardedClient, discord.ext.commands.bot.Bot, discord.ext.commands.bot.AutoShardedBot], host: str = '127.0.0.1', port: Union[str, int] = '3030', password: Optional[str] = None, identifier: Optional[str] = None, region: Optional[discord.enums.VoiceRegion] = None, *, session: Optional[aiohttp.client.ClientSession] = 'None', loop: Optional[asyncio.events.AbstractEventLoop] = 'None', heartbeat: Optional[float] = 'None', secure: Optional[bool] = 'None', spotify: Optional[obsidian.spotify.SpotifyClient] = 'None', **kwargs)
- class obsidian.BaseNode(bot: Union[discord.client.Client, discord.shard.AutoShardedClient, discord.ext.commands.bot.Bot, discord.ext.commands.bot.AutoShardedBot], host: str = '127.0.0.1', port: Union[str, int] = '3030', password: Optional[str] = None, identifier: Optional[str] = None, region: Optional[discord.enums.VoiceRegion] = None, *, session: Optional[aiohttp.client.ClientSession] = 'None', loop: Optional[asyncio.events.AbstractEventLoop] = 'None', heartbeat: Optional[float] = 'None', secure: Optional[bool] = 'None', spotify_client_id: Optional[str] = 'None', spotify_client_secret: Optional[str] = 'None', **kwargs)
Represents the base class for all nodes.
You should use
Nodeinstead.- Parameters
bot (
discord.Client) – The client or bot that this node belongs to.host (str) – The IP of the host that Obsidian is running on.
port (str) – The port of the host that Obsidian is running on.
password (Optional[str]) – The password needed to connect to Obsidian.
identifier (Optional[str]) – The name to use to refer to this node. Defaults to ‘MAIN’
region (Optional[
discord.VoiceRegion]) – The voice region this node will be in.
See also
- property bot: Union[discord.client.Client, discord.shard.AutoShardedClient, discord.ext.commands.bot.Bot, discord.ext.commands.bot.AutoShardedBot]¶
The
discord.Clientthat this node corresponds to.- Type
- async connect(*, session: Optional[aiohttp.client.ClientSession] = None, loop: Optional[asyncio.events.AbstractEventLoop] = None) None¶
Establishes a websocket connection for this node.
- Parameters
session (Optional[
aiohttp.ClientSession]) – The session to use when connecting.loop (Optional[
asyncio.AbstractEventLoop]) – The event loop to use when connecting.
- async decode_track(id: str, /, *, cls: type = <class 'obsidian.track.Track'>, **kwargs) Optional[obsidian.track.Track]¶
This function is a coroutine.
Decodes a track given it’s Base 64 ID.
- Parameters
- Returns
The decoded track, if any.
- Return type
Optional[
Track]
See also
- async decode_tracks(ids: str, /, *, cls: type = <class 'obsidian.track.Track'>, **kwargs) Optional[List[obsidian.track.Track]]¶
This function is a coroutine.
Decodes multiple tracks, given their Base 64 ID’s.
- Parameters
- Returns
A list of constructed tracks, if any.
- Return type
Optional[List[
Track]]
See also
- async destroy(*, force: bool = False) None¶
Disconnects, deletes, and destroys this node.
- Parameters
force (bool, default: False) – Whether or not to force disconnection.
- destroy_player(guild: Union[discord.guild.Guild, discord.object.Object, int]) None¶
Destroys and deletes a player.
- Parameters
guild (Union[
discord.Guild,discord.Object, int]) – The player’s corresponding guild.
- async disconnect(*, force: bool = False) None¶
Disconnects the current websocket connection for this node.
- Parameters
force (bool, default: False) – Whether or not to force disconnection.
- get_player(guild: Union[discord.guild.Guild, discord.object.Object, int], cls: type = <class 'obsidian.player.Player'>, must_exist: bool = False, *args, **kwargs) Optional[obsidian.player.Player]¶
Gets an existing
Player, or if not found, creates it.- Parameters
guild (Union[
discord.Guild,discord.Object, int]) – The guild that this player corresponds to.cls (type, default:
Player) – The class to cast the player to.must_exist (bool, default: False) – Whether or not to return None if the player doesn’t already exist.
args – Extra arguments to pass into the class constructor.
kwargs – Extra keyword arguments to pass into the class constructor.
- Returns
The player found, or if it didn’t exist, created.
- Return type
- property region: Optional[discord.enums.VoiceRegion]¶
The voice region for this node, specified in the constructor.
- Type
- async search_track(query: str, *, source: Optional[obsidian.enums.Source] = 'None', cls: type = 'Track', suppress: bool = 'False', **kwargs) Optional[Union[obsidian.track.Track, obsidian.track.Playlist]]¶
Searches for one single track given a query or URL.
Warning
If the track is a direct URL, the source kwarg will be ignored.
- Parameters
query (str) – The search query or URL.
source (Optional[
Source]) – The source that the track should come from.cls (type, default:
Track) – The class to cast the track to.suppress (bool, default: False) – Whether or not to suppress
NoSearchMatchesFound
- Returns
The track or playlist that was found, if any.
- Return type
- async search_tracks(query: str, *, source: Optional[obsidian.enums.Source] = 'None', cls: type = 'Track', suppress: bool = 'True', limit: Optional[int] = 'None', **kwargs) Optional[Union[List[obsidian.track.Track], obsidian.track.Playlist]]¶
Searches for multiple tracks given a query or URL.
Warning
If the track is a direct URL, the source kwarg will be ignored.
Warning
If a playlist is found, the return type will not be a list, rather just the playlist itself.
- Parameters
query (str) – The search query or URL.
source (Optional[
Source]) – The source that the tracks should come from.cls (type, default:
Track) – The class to cast the tracks to.suppress (bool, default: False) – Whether or not to suppress
NoSearchMatchesFoundlimit (Optional[int]) – The maximum amount of tracks to return.
- Returns
A list of tracks found, or a playlist.
- Return type
Players¶
Player¶
- class obsidian.Player(*args, **kwargs)¶
Represents a guild’s music player.
This class is recommended to be subclassed for custom behaviors. This class also inherits from
NodeListenerMixin.- Parameters
node (
BaseNode) – The node constructing this player.bot (
discord.Client) – The bot of the corresponding node.guild (Union[
discord.Guild,discord.Object]) – The guild that this player corresponds to.
- async add_filter(*filters: obsidian.filters.BaseFilter) None¶
Appends a new filter, or filters, to the current filter sink.
- Parameters
filters (
BaseFilter) – The filter(s) to add.
- async add_filters(*filters: obsidian.filters.BaseFilter) None¶
Appends a new filter, or filters, to the current filter sink.
- Parameters
filters (
BaseFilter) – The filter(s) to add.
- property bot: Union[discord.client.Client, discord.shard.AutoShardedClient, discord.ext.commands.bot.Bot, discord.ext.commands.bot.AutoShardedBot]¶
discord.ClientThe bot that this player uses.
- property channel: discord.channel.VoiceChannel¶
The voice channel that this player is connected to.
- Type
- async connect(channel: discord.channel.VoiceChannel, *, cls: type = <class 'obsidian.player.Protocol'>, timeout: Optional[float] = None, reconnect: Optional[bool] = None, self_deaf: bool = False) obsidian.player.Protocol¶
Connects to a
discord.VoiceChannel.- Parameters
channel (
discord.VoiceChannel) – The channel to connect to.cls (type, default:
Protocol) – The connection protocol class to use.timeout (float, optional) – The timeout to use when connecting.
reconnect (bool, optional) – Whether or not to reconnect.
self_deaf (bool, default: False) – Whether or not to self-deafen upon connecting.
- Returns
The connection protocol created.
- Return type
- property current_track_id: Optional[str]¶
The raw base 64 ID of the current track playing.
- Type
Optional[str]
- async destroy(*, force: bool = False) None¶
Destroys, disconnects, and deletes this player.
- Parameters
force (bool, default: False) – Whether or not to force disconnection.
- async disconnect(*, force: bool = False) None¶
Disconnects from the current voice connection.
- Parameters
force (bool, default: False) – Whether or not to force disconnection.
- property eq: Optional[obsidian.filters.Equalizer]¶
The current equalizer of the music audio.
- Type
Optional[
Equalizer]
- property equalizer: Optional[obsidian.filters.Equalizer]¶
The current equalizer of the music audio.
- Type
Optional[
Equalizer]
- property filters: obsidian.filters.FilterSink¶
The
FilterSinkof filters this player is using.- Type
- property guild: Union[discord.guild.Guild, discord.object.Object]¶
The guild that corresponds to this player.
- Type
Union[
discord.Guild,discord.Object]
- property listeners: List[discord.member.Member]¶
Returns a list of
discord.Memberin the voice channel that are undeafened.- Type
List[
discord.Member]
- async move(channel: discord.channel.VoiceChannel) None¶
Moves the connection to another voice channel.
- Parameters
channel (
discord.VoiceChannel) – The channel to move to.
- async overwrite_filters(filters: obsidian.filters.FilterSink) None¶
Completely overwrites the current filter sink into a new one.
- Parameters
filters (
FilterSink) – The new filter sink to use.
See also
Player.add_filter()Appends a new filter to the current filter sink.
- async play(track: Union[obsidian.track.Track, obsidian.track.Playlist], *, start_time: int = 0, end_time: int = 0, no_replace: bool = False) None¶
Plays a track using this player.
If you provide a playlist, the player will play the Playlist.selected_track.
- Parameters
track (
Track) – The track to play.start_time (int, default: 0) – The start time offset of the track, in milliseconds.
end_time (int, default: 0) – When to end the track, in milliseconds.
no_replace (bool, default: False) – If set to True, this will do nothing if a track is already playing. If set to False, this will overwrite the current playing track.
- property playing: bool¶
Whether or not this player is playing music.
- property position: float¶
The position, in milliseconds, of the current track playing.
For example, this can return 62000 if the track is 62 seconds in.
- Type
- async remove_filter(*filters) None¶
Removes a filter from the current filter sink.
- Parameters
filters (
BaseFilter) – The filter(s) to remove.
- async remove_filters(*filters) None¶
Removes a filter from the current filter sink.
- Parameters
filters (
BaseFilter) – The filter(s) to remove.
- async seek(position: float) None¶
Sets the current time position, in milliseconds, of the current playing track.
- Parameters
position (float) – The new time position, in milliseconds.
- async set_eq(equalizer: obsidian.filters.Equalizer) None¶
Overwrites and changes the current audio equalizer.
- Parameters
equalizer (
Equalizer) – The new equalizer to use.
- async set_equalizer(equalizer: obsidian.filters.Equalizer) None¶
Overwrites and changes the current audio equalizer.
- Parameters
equalizer (
Equalizer) – The new equalizer to use.
- async set_filter(filters: obsidian.filters.FilterSink) None¶
Completely overwrites the current filter sink into a new one.
- Parameters
filters (
FilterSink) – The new filter sink to use.
See also
Player.add_filter()Appends a new filter to the current filter sink.
- async set_filters(filters: obsidian.filters.FilterSink) None¶
Completely overwrites the current filter sink into a new one.
- Parameters
filters (
FilterSink) – The new filter sink to use.
See also
Player.add_filter()Appends a new filter to the current filter sink.
- async set_position(position: float) None¶
Sets the current time position, in milliseconds, of the current playing track.
- Parameters
position (float) – The new time position, in milliseconds.
- async set_vol(volume: int = 100) None¶
Sets the player volume in percent.
The volume must be at least 0 and at most 500.
Warning
It is recommended not to allow users to set the volume past 200 as it is then virtually earrape.
- Parameters
volume (int, default: 100) – The new volume of the player.
- async set_volume(volume: int = 100) None¶
Sets the player volume in percent.
The volume must be at least 0 and at most 500.
Warning
It is recommended not to allow users to set the volume past 200 as it is then virtually earrape.
- Parameters
volume (int, default: 100) – The new volume of the player.
- async stop(*, force: bool = False) None¶
Stops the current playing track.
- Parameters
force (bool, default: False) – Whether or not to force stop the track.
PresetPlayer¶
- class obsidian.PresetPlayer(*args, **kwargs)¶
Basic music player with many things already built and handled for you.
Note that this class should still be inherited from in order to add required methods.
- async add_filter(*filters: obsidian.filters.BaseFilter) None¶
Appends a new filter, or filters, to the current filter sink.
- Parameters
filters (
BaseFilter) – The filter(s) to add.
- async add_filters(*filters: obsidian.filters.BaseFilter) None¶
Appends a new filter, or filters, to the current filter sink.
- Parameters
filters (
BaseFilter) – The filter(s) to add.
- property bot: Union[discord.client.Client, discord.shard.AutoShardedClient, discord.ext.commands.bot.Bot, discord.ext.commands.bot.AutoShardedBot]¶
discord.ClientThe bot that this player uses.
- property channel: discord.channel.VoiceChannel¶
The voice channel that this player is connected to.
- Type
- async connect(channel: discord.channel.VoiceChannel, *, cls: type = <class 'obsidian.player.Protocol'>, timeout: Optional[float] = None, reconnect: Optional[bool] = None, self_deaf: bool = False) obsidian.player.Protocol¶
Connects to a
discord.VoiceChannel.- Parameters
channel (
discord.VoiceChannel) – The channel to connect to.cls (type, default:
Protocol) – The connection protocol class to use.timeout (float, optional) – The timeout to use when connecting.
reconnect (bool, optional) – Whether or not to reconnect.
self_deaf (bool, default: False) – Whether or not to self-deafen upon connecting.
- Returns
The connection protocol created.
- Return type
- property current_track_id: Optional[str]¶
The raw base 64 ID of the current track playing.
- Type
Optional[str]
- async destroy(*, force: bool = False) None¶
Destroys, disconnects, and deletes this player.
- Parameters
force (bool, default: False) – Whether or not to force disconnection.
- async disconnect(*, force: bool = False) None¶
Disconnects from the current voice connection.
- Parameters
force (bool, default: False) – Whether or not to force disconnection.
- property dj: discord.member.Member¶
The current DJ of this player.
- Type
- async do_next() Optional[obsidian.track.Track]¶
Plays the track fetched from
PointerBasedQueue.get().- Returns
The track that will be played, if any.
- Return type
Optional[
Track]
- enqueue(track: Union[obsidian.track.Track, obsidian.track.Playlist]) None¶
- property eq: Optional[obsidian.filters.Equalizer]¶
The current equalizer of the music audio.
- Type
Optional[
Equalizer]
- property equalizer: Optional[obsidian.filters.Equalizer]¶
The current equalizer of the music audio.
- Type
Optional[
Equalizer]
- property filters: obsidian.filters.FilterSink¶
The
FilterSinkof filters this player is using.- Type
- property guild: Union[discord.guild.Guild, discord.object.Object]¶
The guild that corresponds to this player.
- Type
Union[
discord.Guild,discord.Object]
- property listeners: List[discord.member.Member]¶
Returns a list of
discord.Memberin the voice channel that are undeafened.- Type
List[
discord.Member]
- async move(channel: discord.channel.VoiceChannel) None¶
Moves the connection to another voice channel.
- Parameters
channel (
discord.VoiceChannel) – The channel to move to.
- async overwrite_filters(filters: obsidian.filters.FilterSink) None¶
Completely overwrites the current filter sink into a new one.
- Parameters
filters (
FilterSink) – The new filter sink to use.
See also
Player.add_filter()Appends a new filter to the current filter sink.
- async play(track: Union[obsidian.track.Track, obsidian.track.Playlist], *, start_time: int = 0, end_time: int = 0, no_replace: bool = False) None¶
Plays a track using this player.
If you provide a playlist, the player will play the Playlist.selected_track.
- Parameters
track (
Track) – The track to play.start_time (int, default: 0) – The start time offset of the track, in milliseconds.
end_time (int, default: 0) – When to end the track, in milliseconds.
no_replace (bool, default: False) – If set to True, this will do nothing if a track is already playing. If set to False, this will overwrite the current playing track.
- property playing: bool¶
Whether or not this player is playing music.
- property position: float¶
The position, in milliseconds, of the current track playing.
For example, this can return 62000 if the track is 62 seconds in.
- Type
- property queue: obsidian.queue.Queue¶
The current queue for this player.
- Type
- async remove_filter(*filters) None¶
Removes a filter from the current filter sink.
- Parameters
filters (
BaseFilter) – The filter(s) to remove.
- async remove_filters(*filters) None¶
Removes a filter from the current filter sink.
- Parameters
filters (
BaseFilter) – The filter(s) to remove.
- async seek(position: float) None¶
Sets the current time position, in milliseconds, of the current playing track.
- Parameters
position (float) – The new time position, in milliseconds.
- async set_eq(equalizer: obsidian.filters.Equalizer) None¶
Overwrites and changes the current audio equalizer.
- Parameters
equalizer (
Equalizer) – The new equalizer to use.
- async set_equalizer(equalizer: obsidian.filters.Equalizer) None¶
Overwrites and changes the current audio equalizer.
- Parameters
equalizer (
Equalizer) – The new equalizer to use.
- async set_filter(filters: obsidian.filters.FilterSink) None¶
Completely overwrites the current filter sink into a new one.
- Parameters
filters (
FilterSink) – The new filter sink to use.
See also
Player.add_filter()Appends a new filter to the current filter sink.
- async set_filters(filters: obsidian.filters.FilterSink) None¶
Completely overwrites the current filter sink into a new one.
- Parameters
filters (
FilterSink) – The new filter sink to use.
See also
Player.add_filter()Appends a new filter to the current filter sink.
- set_loop_type(new: obsidian.queue.LoopType) None¶
Changes the
LoopTypeof the queue.- Parameters
new (
LoopType) – The new loop type to use.
- async set_position(position: float) None¶
Sets the current time position, in milliseconds, of the current playing track.
- Parameters
position (float) – The new time position, in milliseconds.
- async set_vol(volume: int = 100) None¶
Sets the player volume in percent.
The volume must be at least 0 and at most 500.
Warning
It is recommended not to allow users to set the volume past 200 as it is then virtually earrape.
- Parameters
volume (int, default: 100) – The new volume of the player.
- async set_volume(volume: int = 100) None¶
Sets the player volume in percent.
The volume must be at least 0 and at most 500.
Warning
It is recommended not to allow users to set the volume past 200 as it is then virtually earrape.
- Parameters
volume (int, default: 100) – The new volume of the player.
- async skip() Optional[obsidian.track.Track]¶
Skips the current track regardless of the loop type.
This uses
PointerBasedQueue.skip().- Returns
The new track to be played, if any.
- Return type
Optional[
Track]
- async stop(*, force: bool = False) None¶
Stops the current playing track.
- Parameters
force (bool, default: False) – Whether or not to force stop the track.
Protocol¶
- class obsidian.player.Protocol(player: obsidian.player.Player)¶
- async connect(*, timeout: Optional[float] = None, reconnect: Optional[bool] = None, self_deaf: bool = False) None¶
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 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.
- async disconnect(*, force: bool = False) None¶
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.
Tracks¶
Track¶
- class obsidian.Track(*, id: str, info: Dict[str, Any], ctx: Optional[discord.ext.commands.context.Context] = None, **kwargs)¶
Represents an obsidian song track.
- Parameters
id (str) – The base 64 track ID.
info (Dict[str, Any]) – The raw JSON payload returned by Obsidian, containing information about this track.
ctx (Optional[
commands.Context]) – An optional context to use for this track. By default, if this is provided,Track.requesterwill be the author of the context.kwargs – Extra keyword arguments to pass into the constructor.
- property ctx: Optional[discord.ext.commands.context.Context]¶
The
Contextthat invoked the track. Could be None .- Type
Optional[
Context]
- property id: str¶
The Base64 Track ID, can be used to rebuild track objects.
See also
- Type
- property requester: Optional[discord.member.Member]¶
The
discord.Memberthat requested the track.- Type
Optional[
discord.Member]
- property source: obsidian.enums.Source¶
Return an enum indicates the type of the
Source.- Type
Source
Playlist¶
- class obsidian.Playlist(*, info: Dict[str, Any], tracks: List[Dict[str, Any]], ctx: Optional[discord.ext.commands.context.Context] = None, cls: type = <class 'obsidian.track.Track'>, **kwargs)¶
Represents a playlist of tracks.
- property ctx: Optional[discord.ext.commands.context.Context]¶
The
Contextthat invoked the playlist. Could be None .- Type
Optional[
Context]
- property requester: Optional[discord.member.Member]¶
The
discord.Memberthat requested the playlist.- Type
Optional[
discord.Member]
- property selected_track: Optional[obsidian.track.Track]¶
The selected track returned by Obsidian, could be None .
Filters¶
FilterSink¶
- class obsidian.FilterSink(player)¶
Represents a sink of filters.
BaseFilter¶
- class obsidian.BaseFilter¶
VolumeFilter¶
TimescaleFilter¶
RotationFilter¶
Equalizer¶
VibratoFilter¶
TremoloFilter¶
KaraokeFilter¶
ChannelMixFilter¶
LowPassFilter¶
Events¶
- class obsidian.events.BaseEvent(data: Dict[str, Any])¶
The base event class that all events inherit from.
- property guild_id: int¶
The snowflake ID of the guild of the corresponding player this event occured in.
- property type: obsidian.enums.EventType¶
The type of the event.
- class obsidian.events.TrackEndEvent(data: Dict[str, Any])¶
The event for when a track ends.
- property reason: obsidian.enums.TrackEndReason¶
A
TrackEndReasonon why this track ended.
- property track_id: str¶
The raw base 64 track ID of the track that ended.
- class obsidian.events.TrackExceptionEvent(data: Dict[str, Any])¶
Event for when Obsidian encounters an error while playing a track.
- property cause: str¶
The cause of the error.
- property message: str¶
The error message provided by Obsidian.
- property severity: obsidian.enums.TrackExceptionSeverity¶
A
TrackExceptionSeverityrepresenting the severity of this exception.
- property track_id: str¶
The raw base 64 track ID of the track.
- class obsidian.events.TrackStartEvent(data: Dict[str, Any])¶
The event for when a track starts playing.
- property track_id: str¶
The raw base 64 track ID of the track that started.
- class obsidian.events.TrackStuckEvent(data: Dict[str, Any])¶
The event for when a track gets stuck.
- property threshold: float¶
The wait threshold that was exceeded for this event to trigger, in seconds.
- property threshold_ms: int¶
The wait threshold that was exceeded for this event to trigger, in milliseconds.
- property track_id: str¶
The raw base 64 track ID of the track that got stuck.
- class obsidian.events.WebsocketCloseEvent(data: Dict[str, Any])¶
Event for when the websocket gets closed.
- property by_remote: bool¶
Whether or not the websocket was closed remotely.
- property code: int¶
The websocket close code, provided by Discord.
- property reason: str¶
Reason on why the websocket was closed.
Queues¶
Utility queue classes are built into obsidian.py.
Queue¶
- class obsidian.Queue(max_size: Optional[int], *, cls: type = <class 'collections.deque'>)¶
Utility queue class made only for Tracks and Playlists.
Warning
You can only queue Tracks and Playlists. Playlists will be implicitly handled for you.
- Parameters
- add(track: Union[obsidian.track.Track, obsidian.track.Playlist], *, left: bool = False) None¶
Adds a
TrackorPlaylistto the queue.If a playlist is provided, the queue will extend from it’s tracks.
- append(track: Union[obsidian.track.Track, obsidian.track.Playlist], *, left: bool = False) None¶
Adds a
TrackorPlaylistto the queue.If a playlist is provided, the queue will extend from it’s tracks.
- copy() obsidian.queue.Queue¶
Copies this queue and returns a new queue with the same tracks.
- Returns
The new, copied queue.
- Return type
- extend(tracks: Iterable[Union[obsidian.track.Track, obsidian.track.Playlist]]) None¶
Extends the queue by an iterable of
Track.Because this just called
Queue.add()for each track in the iterable,Playlistwill run this method recursively.
- get() obsidian.track.Track¶
Pops and returns the next track in the queue.
- Returns
The track to play.
- Return type
- insert(index: int, track: Union[obsidian.track.Track, obsidian.track.Playlist]) None¶
Inserts a track at the given index.
- property internal_queue: collections.deque¶
The internal
collections.dequeclass this queue uses.- Type
- property max_size: Optional[int]¶
The max size of the queue, passed into the class constructor.
- Type
Optional[int]
- pop(index: int = 0) obsidian.track.Track¶
The rough equivalent of
Queue.remove()but is internally done differently.Note: This removes from the left, not the right unlike regular Python lists. This is because queues would usually work like this.
- put(track: Union[obsidian.track.Track, obsidian.track.Playlist], *, left: bool = False) None¶
Adds a
TrackorPlaylistto the queue.If a playlist is provided, the queue will extend from it’s tracks.
- remove(track_or_index: Union[int, obsidian.track.Track]) None¶
Removes a
Trackfrom the queue.If a
Trackis provided, it will search and remove it, linearly. If an integer is provided, it will simply remove the track at that index.- Parameters
track_or_index (Union[int,
Track]) – The track or index of the track to remove.
- set(index: int, new: obsidian.track.Track) None¶
Sets the track at the given index to the given track.
- skip() obsidian.track.Track¶
Skips and returns the next track in the queue.
- Returns
The next track to play.
- Return type
PointerBasedQueue¶
- class obsidian.PointerBasedQueue(max_size: Optional[int] = None, *, cls: type = <class 'collections.deque'>, default_loop_type: obsidian.queue.LoopType = LoopType.NONE)¶
A certain type of queue that uses a pointer to point to a track in the queue, rather than popping tracks.
This allows for looping, therefore it is also implemented in this class.
- add(track: Union[obsidian.track.Track, obsidian.track.Playlist], *, left: bool = False) None¶
Adds a
TrackorPlaylistto the queue.If a playlist is provided, the queue will extend from it’s tracks.
- append(track: Union[obsidian.track.Track, obsidian.track.Playlist], *, left: bool = False) None¶
Adds a
TrackorPlaylistto the queue.If a playlist is provided, the queue will extend from it’s tracks.
- copy() obsidian.queue.Queue¶
Copies this queue and returns a new queue with the same tracks.
- Returns
The new, copied queue.
- Return type
- extend(tracks: Iterable[Union[obsidian.track.Track, obsidian.track.Playlist]]) None¶
Extends the queue by an iterable of
Track.Because this just called
Queue.add()for each track in the iterable,Playlistwill run this method recursively.
- get() Optional[obsidian.track.Track]¶
Retrieves the next track in the queue.
If the
Queueis NONE and the queue has been exhausted, this will return None instead.If the
Queueis TRACK, this will return the same track playing. SeePointerBasedQueue.skip()to skip the current track.
- insert(index: int, track: Union[obsidian.track.Track, obsidian.track.Playlist]) None¶
Inserts a track at the given index.
- property internal_queue: collections.deque¶
The internal
collections.dequeclass this queue uses.- Type
- property max_size: Optional[int]¶
The max size of the queue, passed into the class constructor.
- Type
Optional[int]
- pop(index: int = 0) obsidian.track.Track¶
The rough equivalent of
Queue.remove()but is internally done differently.Note: This removes from the left, not the right unlike regular Python lists. This is because queues would usually work like this.
- put(track: Union[obsidian.track.Track, obsidian.track.Playlist], *, left: bool = False) None¶
Adds a
TrackorPlaylistto the queue.If a playlist is provided, the queue will extend from it’s tracks.
- remove(track_or_index: Union[int, obsidian.track.Track]) None¶
Removes a
Trackfrom the queue.If a
Trackis provided, it will search and remove it, linearly. If an integer is provided, it will simply remove the track at that index.- Parameters
track_or_index (Union[int,
Track]) – The track or index of the track to remove.
- set(index: int, new: obsidian.track.Track) None¶
Sets the track at the given index to the given track.
- skip() Optional[obsidian.track.Track]¶
Skips the current track in the queue.
This will always retrieve a new track (or None). See
PointerBasedQueue.get()if you aren’t skipping the track.This is different to
PointerBasedQueue.get()as it will always skip the current track regardless of the LoopType.
Enums¶
- class obsidian.enums.EventType(value)¶
This class is an enum.
Represents the type of event Obsidian has sent.
- TRACK_START¶
A track has started.
- TRACK_END¶
A track has ended.
- TRACK_STUCK¶
A track has gotten stuck.
- TRACK_EXCEPTION¶
There was an error while playing the track.
- WEBSOCKET_OPEN¶
A websocket connection with Obsidian has been opened.
- WEBSOCKET_CLOSED¶
A websocket connection with Obsidian has been closed.
- class obsidian.enums.LoadType(value)¶
This class is an enum.
Represents load types that Obsidian sends.
- NO_MATCHES¶
No matches were found.
- LOAD_FAILED¶
Something went wrong while trying to load tracks.
- PLAYLIST_LOADED¶
A playlist was loaded.
- TRACK_LOADED¶
A track (or tracks) were loaded.
- SEARCH_RESULT¶
A result from a search query was loaded.
- class obsidian.enums.Source(value)¶
This class is an enum.
Represents a search source.
- YOUTUBE¶
The search source for Youtube.
- YOUTUBE_MUSIC¶
The search source for Youtube Music.
- SOUNDCLOUD¶
The search source for Soundcloud.
- SPOTIFY¶
The search soruce for Spotify. Your node must have a valid
SpotifyClientin order to use this source.
- YARN¶
The search source for Yarn.
- BANDCAMP¶
The search source for Bandcamp.
- TWITCH¶
The search source for Twitch.
- VIMEO¶
The search source for Vimeo.
- NICO¶
The search source Nico.
- LOCAL¶
Searches your local files.
- HTTP¶
If the query is a direct URL, allow them.
See also
Node.search_track(),Node.search_tracks()
- class obsidian.enums.TrackEndReason(value)¶
This class is an enum.
Represents a reason on why a track has ended.
- STOPPED¶
The track was manually stopped.
- REPLACED¶
The track was replaced by another track.
- CLEANUP¶
The track was cleared on cleanup.
- LOAD_FAILED¶
The track failed to load.
- FINISHED¶
The track finished.
See also
Stats¶
- class obsidian.Stats(data: Dict[str, Any])¶
Stats of a Obsidian node.
- cpu_cores¶
- cpu_process_load¶
- cpu_system_load¶
- heap_used_committed¶
- heap_used_init¶
- heap_used_max¶
- heap_used_used¶
- non_heap_used_committed¶
- non_heap_used_init¶
- non_heap_used_max¶
- non_heap_used_used¶
- players_active¶
- players_total¶
- threads_daemon¶
- threads_peak¶
- threads_running¶
- threads_total_started¶
Exceptions and Errors¶
- exception obsidian.errors.HTTPError(message: str, response: aiohttp.client_reqrep.ClientResponse)¶
Raised when an error via HTTP request occurs.
- exception obsidian.errors.NoSearchMatchesFound(query: str)¶
Raised when no matches are found via search query.
- exception obsidian.errors.NodeAlreadyExists(identifier: str)¶
Raised when a node with the same identifier already exists.
- exception obsidian.errors.NodeCreationError¶
Raised when a node could not be successfully created.
- exception obsidian.errors.NodeNotConnected¶
Raised when a socket request is sent without the node being connected.
- exception obsidian.errors.ObsidianAuthorizationFailure(node, *args, **kwargs)¶
Raised when connecting fails due to invalid authorization.
- exception obsidian.errors.ObsidianConnectionFailure(node, error: BaseException)¶
Raised when connecting fails.
- exception obsidian.errors.ObsidianException¶
Raised when an error related to this module occurs.
- exception obsidian.errors.ObsidianSearchFailure¶
Raised when searching for a track fails.
- exception obsidian.errors.ObsidianSpotifyException¶
Raised when an error related to spotify occurs.