API Overview

This is an overview containing some important classes and functions.

Client

create_client(http_uri, web_socket_uri, password, user_id, *, state=None)[source]

Create a new combined Andesite client.

Parameters
  • http_uri (Union[str, URL]) – URI for the http endpoint

  • web_socket_uri (Union[str, URL]) – URI for the web socket endpoint

  • password (Optional[str]) – Andesite password for authorization

  • user_id (int) – User ID

  • state (Union[AbstractState, bool, None]) – State handler to use. Defaults to in-memory State. You can pass False to disable state handling.

Return type

Client

Returns

A new combined client with HTTPBase and WebSocketBase as its clients.

Pool

create_pool(http_nodes, web_socket_nodes, *, user_id, state=None, http_pool_kwargs=None, web_socket_pool_kwargs=None)[source]

Create an Client with client pools.

Uses HTTPBase and WebSocketBase which are contained in HTTPPoolBase and WebSocketPoolBase pools respectively.

Parameters
  • http_nodes (Iterable[Tuple[Union[str, URL], Optional[str]]]) – Tuples of [uri, password] for each REST node to connect to.

  • web_socket_nodes (Iterable[Tuple[Union[str, URL], Optional[str]]]) – Tuples of [uri, password] for each WebSocket node to connect to.

  • user_id (int) – Bot’s user id.

  • state (Union[AbstractState, bool, None]) – State handler to use for the pools. Defaults to State, because a state handler is required for node migration to work. You can pass False to disable state handling though.

  • http_pool_kwargs (Optional[Mapping[str, Any]]) – Additional keyword arguments to pass to the http pool constructor.

  • web_socket_pool_kwargs (Optional[Mapping[str, Any]]) – Additional keyword arguments to pass to the web socket pool constructor.

Return type

Client

Returns

A combined Andesite client operation on an http pool and a web socket pool.

Models

Player/Track

class Player(time, position, paused, volume, filters, frame, mixer, mixer_enabled)[source]
mixer

map of mixer player id -> mixer player

Type

MixerMap

mixer_enabled

whether or not the mixer is the current source of audio

Type

bool

property live_position

Interpolated version of position based on the time that has passed.

Return type

Optional[float]

Returns

None if there is no position attribute, equal to position if the player is paused, and interpolated otherwise.

class LoadedTrack(load_type, tracks, playlist_info, cause=None, severity=None)[source]

Result provided by a load track request.

load_type

type of the response

Type

LoadType

tracks

loaded tracks

Type

Optional[List[TrackInfo]]

playlist_info

metadata of the loaded playlist

Type

Optional[PlaylistInfo]

cause

error that happened while loading tracks

Type

Optional[Error]

severity

severity of the error

Type

Optional[str]

This class provides the magic methods __bool__ and __len__ which operate in respect to tracks.

get_selected_track()[source]

Get the selected track.

“Selected” means that either the result is a playlist with an entry selected (PlaylistInfo.selected_track), or the result is a LoadType.TRACK_LOADED result (in which case the first and only track is returned).

All other cases will return in None being returned.

Return type

Optional[TrackInfo]

Returns

The selected track if there is any, or None if the selected track doesn’t exist.

class LoadType[source]

Load type of a LoadedTrack

property success

Whether the load type is a successful one.

Only LOAD_FAILED counts as unsuccessful.

Return type

bool

class TrackInfo(track, info)[source]

Track info represents a track and its metadata.

track

base64 encoded track

Type

str

info

metadata of the track

Type

TrackMetadata

class TrackMetadata(class_name, title, author, length, identifier, uri, is_stream, is_seekable, position)[source]

Additional information for a track.

class_name

class name of the lavaplayer track

Type

str

title

title of the track

Type

str

author

author of the track

Type

str

length

duration of the track, in seconds. Set to None if it’s a stream. Andesite would normally return 2^63 - 1 (Long.MAX_VALUE), but that value doesn’t have any significance in Python so it’s represented with something more meaningful.

Type

Optional[float]

identifier

identifier of the track

Type

str

uri

uri of the track

Type

str

is_stream

whether or not the track is a livestream

Type

bool

is_seekable

whether or not the track supports seeking

Type

bool

position

current position of the track

Type

float

property author_unknown

Whether or not the author is unknown.

Uses constant UNKNOWN_ARTIST to check against.

Keep in mind that there is no way to detect whether the author’s name just happens to coincide with the UNKNOWN_ARTIST text. Use with caution.

Return type

bool

class PlaylistInfo(name, selected_track)[source]

Information for of the playlist a track belongs to.

name

name of the playlist

selected_track

index of the selected track in the tracks list, or None if no track is selected

Command Operations

class VoiceServerUpdate(session_id, event)[source]

Operation providing a voice server update.

session_id

Session ID for the current user in the event’s guild

Type

str

event

Voice server update event sent by discord

Type

Dict[str, Any]

class Play(track, start=None, end=None, pause=None, volume=None, no_replace=False)[source]

Operation playing a track.

track

base64 encoded lavaplayer track

Type

str

start

timestamp, in seconds, to start the track

Type

Optional[float]

end

timestamp, in seconds, to end the track

Type

Optional[float]

pause

whether or not to pause the player

Type

Optional[bool]

volume

volume to set on the player

Type

Optional[float]

no_replace

if True and a track is already playing/paused, this command is ignored. (Defaults to False)

Type

bool

class Pause(pause)[source]

Operation pausing the player.

pause

whether or not to pause the player

Type

bool

class Seek(position)[source]

Operation seeking the current track.

position

timestamp to set the current track to, in seconds

Type

float

class Volume(volume)[source]

Operation adjusting the volume.

volume

volume to set on the player

Type

float

class FilterUpdate(filters)[source]

Operation adjusting the filter settings.

See also

This class inherits from FilterMap.

clear() → None. Remove all items from D.
property equalizer

Equalizer filter settings

Return type

Equalizer

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
get_filter(name, cls)

Get the filter with the name.

Parameters
  • name (str) – Name of the filter to get

  • cls (Type[~FT]) – Filter class to use for the filter.

Return type

~FT

items() → a set-like object providing a view on D's items
property karaoke

Karaoke filter settings

Return type

Karaoke

keys() → a set-like object providing a view on D's keys
pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() → (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

set_filter(andesite_filter)

Set the value for a filter.

Parameters

andesite_filter (Filter) – Filter to set

Return type

None

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
property timescale

Timescale filter settings

Return type

Timescale

property tremolo

Tremolo filter settings

Return type

Tremolo

update([E, ]**F) → None. Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() → an object providing a view on D's values
property vibrato

Vibrato filter settings

Return type

Vibrato

property volume

Volume filter settings

Return type

VolumeFilter

class Update(pause=None, position=None, volume=None, filters=None)[source]

Operation providing an update for the current track.

pause

whether or not to pause the player

Type

Optional[bool]

position

timestamp to set the current track to, in seconds

Type

Optional[float]

volume

volume to set on the player

Type

Optional[float]

filters

configuration for the filters

Type

Optional[FilterUpdate]

class MixerUpdate(enable, players)[source]

Operation adjusting the mixer players.

enable

if present, controls whether or not the mixer should be used

Type

Optional[bool]

players

map of player id to Play / Update payloads for each mixer source

Type

MixerPlayerUpdateMap

Responses

class PlayerUpdate(user_id, guild_id, state)[source]

Player update sent by Andesite for active players.

user_id

user id

Type

int

guild_id

guild id

Type

int

state

State of the player. None if no player exists yet.

Type

Optional[andesite.Player]

class PongResponse(user_id, guild_id)[source]

Simple pong response sent as a response to ping requests.

user_id

User id

Type

int

guild_id

Guild id

Type

int

class ConnectionUpdate(id)[source]

Message sent upon connecting to the Web socket.

id

Connection ID

Type

str

class MetadataUpdate(data)[source]

Payload sent on connection start containing handshake response header.

data

Map of metadata key to value.

Type

Dict[str, Union[int, str, List[str]]]

class StatsUpdate(user_id, stats)[source]

Message containing statistics.

user_id

User ID

Type

int

stats

Statistics

Type

andesite.Stats

Events

class WebSocketConnectEvent(client)[source]

Event dispatched when a connection has been established.

client

Web socket client which connected.

Type

AbstractWebSocketClient

class WebSocketDisconnectEvent(client, deliberate)[source]

Event dispatched when a client was disconnected.

client

Web socket client which connected.

Type

AbstractWebSocketClient

deliberate

Whether the disconnect was deliberate.

Type

bool

class RawMsgReceiveEvent(client, body)[source]

Event emitted when a web socket message is received.

client

Web socket client that received the message.

Type

AbstractWebSocket

body

Raw body of the received message. Note: The body isn’t manipulated in any way other than being loaded from the raw JSON string. For example, the names are still in dromedaryCase.

Type

Dict[str, Any]

class RawMsgSendEvent(client, guild_id, op, body)[source]

Event dispatched before a web socket message is sent.

It’s important to note that this is not a receipt of a message being sent, this event is dispatched even if the message fails to send.

client

Web socket client that received the message.

Type

AbstractWebSocketClient

guild_id

guild id

Type

int

op

Op-code to be executed

Type

str

body

Raw body of the message

Type

Dict[str, Any]

class TrackStartEvent(type, user_id, guild_id, track)[source]

Event emitted when a new track starts playing.

class TrackEndEvent(type, user_id, guild_id, track, reason, may_start_next)[source]

Event emitted when a track ended.

reason

Reason why a track stopped playing.

Type

TrackEndReason

may_start_next

Indicates whether a new track should be started on receiving this event. If this is False, either this event is already triggered because another track started (TrackEndReason.REPLACED) or because the player is stopped (TrackEndReason.STOPPED, TrackEndReason.CLEANUP).

Type

bool

class TrackEndReason[source]

Reason why a track stopped playing.

See also

TrackEndEvent

FINISHED

Usually caused by the track reaching the end, however it will also be used when it ends due to an exception.

LOAD_FAILED

Track failed to start, throwing an exception before providing any audio.

STOPPED

Track was stopped due to the player being stopped.

REPLACED

Track stopped playing because a new track started playing.

CLEANUP

Track was stopped because the cleanup threshold for the audio player was reached.

class TrackStuckEvent(type, user_id, guild_id, track, threshold)[source]

Event emitted when a track is stuck.

threshold

Threshold in seconds

Type

float

class TrackExceptionEvent(type, user_id, guild_id, track, error, exception)[source]

Event emitted when there’s an error.

error

Error message

Type

str

exception

Error data

Type

Error

class WebSocketClosedEvent(type, user_id, guild_id, reason, code, by_remote)[source]

Event emitted when the Andesite node disconnects from a voice channel.

reason

Reason for the disconnect

Type

str

code

Error code

Type

int

by_remote

Whether the disconnect was caused by the remote.

Type

bool

class UnknownAndesiteEvent(type, user_id, guild_id, body)[source]

Special kind of event for unknown events.

This shouldn’t occur at all unless the library is out-dated.

body

Entire event body sent by Andesite. Please note that the keys are in snake_case.

Type

object

Filters

class Equalizer(enabled=True, bands=<factory>)[source]
bands

array of bands to configure

Type

List[EqualizerBand]

classmethod from_gains(gains)[source]

Create an Equalizer filter from a list of gains.

Parameters

gains (Iterable[Optional[float]]) – Iterable of float which correspond to the gain for the band, or None if the band doesn’t specify a gain.

Return type

Equalizer

get_band(band, create=True)[source]

Get the specified band from the bands list.

If the band doesn’t exist it is created. If you don’t want to automatically create a band, pass create=False.

Parameters
  • band (int) – Band number to get

  • create (bool) – Whether or not to create a new band if it doesn’t exist. (Defaults to True)

Return type

Optional[EqualizerBand]

get_band_gain(band)[source]

Get the gain of a band.

Return type

Optional[float]

Returns

Gain of the band or None if it doesn’t exist.

set_band_gain(band, gain)[source]

Set the gain of a band to the specified value.

If the band does not exist it is created.

Parameters
  • band (int) – Band number to set the gain for.

  • gain (float) – Value to set for the gain. ( [-0.25, 1] )

Raises

ValueError – if the provided gain is invalid.

Return type

None

iter_band_gains(use_default=True)[source]

Get a list of all the bands’ gains in order.

Parameters

use_default (bool) – Whether or not to replace non-existent values with the default gain. If False and band doesn’t have a gain set, None is used instead.

Return type

List[Optional[float]]

reset()

Reset the filter settings back to their default values.

Return type

None

class EqualizerBand(band, gain=0.0)[source]
band

band number to configure ( 0 - 14 )

Type

int

gain

value to set for the band ( [-0.25, 1.0] )

Type

float

set_band(value)[source]

Setter for band which performs a value check.

Parameters

value (int) – Value to set for the band. ( [0, 14] )

Raises

ValueError – if the provided value is invalid.

Return type

None

set_gain(value)[source]

Setter for gain which performs a value check.

Parameters

value (float) – Value to set for the gain. ( [-0.25, 1] )

Raises

ValueError – if the provided value is invalid.

Return type

None

class Karaoke(enabled=True, level=1.0, mono_level=1.0, filter_band=220.0, filter_width=100.0)[source]
level
Type

float

mono_level
Type

float

filter_band
Type

float

filter_width
Type

float

reset()

Reset the filter settings back to their default values.

Return type

None

class Timescale(enabled=True, speed=1.0, pitch=1.0, rate=1.0)[source]
speed

speed to play music at (> 0)

Type

float

pitch

pitch to set (> 0)

Type

float

rate

rate to set (> 0)

Type

float

set_speed(value)[source]

Setter for speed which performs a value check.

Parameters

value (float) – Value to set for the speed. ( (0, INF] )

Raises

ValueError – if the provided value is invalid.

Return type

None

set_pitch(value)[source]

Setter for pitch which performs a value check.

Parameters

value (float) – Value to set for the pitch. ( (0, INF] )

Raises

ValueError – if the provided value is invalid.

Return type

None

set_rate(value)[source]

Setter for rate which performs a value check.

Parameters

value (float) – Value to set for the rate. ( (0, INF] )

Raises

ValueError – if the provided value is invalid.

Return type

None

reset()

Reset the filter settings back to their default values.

Return type

None

class Tremolo(enabled=True, frequency=2.0, depth=0.5)[source]
frequency

(> 0)

Type

float

depth

( (0, 1] )

Type

float

set_frequency(value)[source]

Setter for frequency which performs a value check.

Parameters

value (float) – Value to set for the frequency. ( (0, INF] )

Raises

ValueError – if the provided value is invalid.

Return type

None

set_depth(value)[source]

Setter for depth which performs a value check.

Parameters

value (float) – Value to set for the depth. ( (0, 1] )

Raises

ValueError – if the provided value is invalid.

Return type

None

reset()

Reset the filter settings back to their default values.

Return type

None

class Vibrato(enabled=True, frequency=2.0, depth=0.5)[source]
frequency

( (0, 14] )

Type

float

depth

( (0, 1] )

Type

float

set_frequency(value)[source]

Setter for frequency which performs a value check.

Parameters

value (float) – Value to set for the frequency. ( (0, 14] )

Raises

ValueError – if the provided value is invalid.

Return type

None

set_depth(value)[source]

Setter for depth which performs a value check.

Parameters

value (float) – Value to set for the depth. ( (0, 1] )

Raises

ValueError – if the provided value is invalid.

Return type

None

reset()

Reset the filter settings back to their default values.

Return type

None

class VolumeFilter(enabled=True, volume=1.0)[source]

Volume filter settings.

volume

Volume modifier. This acts as a factor for the actual volume.

Type

float

reset()

Reset the filter settings back to their default values.

Return type

None

class FilterMap(filters)[source]

Custom mapping type for filters.

filters

Dictionary containing all filters.

Type

Dict[str, Any]

Theoretically this is just a wrapper around the filters dictionary which contains the actual filter data. The class exposes the known filters as properties, but it also supports unknown filters should the library become outdated.

You can also use this as a wrapper for an existing filter dict.

get_filter(name, cls)[source]

Get the filter with the name.

Parameters
  • name (str) – Name of the filter to get

  • cls (Type[~FT]) – Filter class to use for the filter.

Return type

~FT

property equalizer

Equalizer filter settings

Return type

Equalizer

property karaoke

Karaoke filter settings

Return type

Karaoke

property timescale

Timescale filter settings

Return type

Timescale

property tremolo

Tremolo filter settings

Return type

Tremolo

clear() → None. Remove all items from D.
get(k[, d]) → D[k] if k in D, else d. d defaults to None.
items() → a set-like object providing a view on D's items
keys() → a set-like object providing a view on D's keys
pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() → (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) → None. Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() → an object providing a view on D's values
property vibrato

Vibrato filter settings

Return type

Vibrato

property volume

Volume filter settings

Return type

VolumeFilter

set_filter(andesite_filter)[source]

Set the value for a filter.

Parameters

andesite_filter (Filter) – Filter to set

Return type

None

Debug

Debug models for Andesite.

These models are used in either Stats which represents the Andesite stats returned by WebSocketInterface.get_stats or Error which is used to represent an Andesite error.

class StackFrame(class_loader, module_name, module_version, class_name, method_name, file_name, line_number, pretty)[source]

Andesite stack frame.

Can be found in Error.stack.

class_loader

name of the classloader

Type

Optional[str]

module_name

name of the module

Type

Optional[str]

module_version

version of the module

Type

Optional[str]

class_name

name of the class

Type

str

method_name

name of the method

Type

str

file_name

name of the source file

Type

Optional[str]

line_number

line in the source file

Type

Optional[int]

pretty

pretty printed version of this frame, as it would appear on Throwable#printStackTrace

Type

str

class Error(class_name, message, stack, suppressed, cause)[source]

Andesite error.

You can convert the Andesite error data into a Python exception using the as_python_exception method and the raise_python_exception to raise it.

class_name

class of the error

Type

str

message

message of the error

Type

Optional[str]

stack

stacktrace of the error

Type

List[StackFrame]

cause

cause of the error

Type

Optional[Error]

suppressed

suppressed errors

Type

List[Error]

as_python_exception()[source]

Create an AndesiteException which can be raised.

If cause is not None it is added to the exception.

Return type

AndesiteException

raise_error()[source]

Raise the Andesite error as an AndesiteException.

Raises

AndesiteException – Generated using the as_python_exception method.

Return type

NoReturn

exception AndesiteException(class_name, message, stack, suppressed)[source]

Andesite’s Error represented as python exceptions.

class_name

Class name of the error

Type

str

message

message of the error

Type

Optional[str]

stack

cause of the error

Type

List[StackFrame]

suppressed

suppressed errors

Type

List[Error]

class PlayersStats(total, playing)[source]

Players statistics sent by Andesite.

total

Total amount of players

Type

int

playing

Amount of players that are actively playing

Type

int

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class RuntimeVMStats(name, vendor, version)[source]

VM statistics.

name
Type

str

vendor
Type

str

version
Type

str

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class RuntimeSpecStats(name, vendor, version)[source]

Spec statistics.

name
Type

str

vendor
Type

str

version
Type

str

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class RuntimeVersionStats(feature, interim, update, patch, pre, build, optional)[source]

Version information stats.

feature
Type

int

interim
Type

int

update
Type

int

patch
Type

int

pre
Type

Optional[str]

build
Type

int

optional
Type

str

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class RuntimeStats(uptime, pid, management_spec_version, name, vm, spec, version)[source]

Runtime statistics.

uptime
Type

int

pid
Type

int

management_spec_version
Type

str

name
Type

str

vm
Type

RuntimeVMStats

spec
Type

RuntimeSpecStats

version
Type

RuntimeVersionStats

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class OSStats(processors, name, arch, version)[source]

OS statistics.

processors
Type

int

name
Type

str

arch
Type

str

version
Type

str

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class CPUStats(andesite, system)[source]

CPU statistics.

andesite
Type

float

system
Type

float

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class ClassLoadingStats(loaded, total_loaded, unloaded)[source]

Class loading statistics.

loaded
Type

int

total_loaded
Type

int

unloaded
Type

int

class ThreadStats(running, daemon, peak, total_started)[source]

Thread statistics.

running
Type

int

daemon
Type

int

peak
Type

int

total_started
Type

int

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class CompilationStats(name, total_time)[source]

Compilation statistics.

name
Type

str

total_time
Type

int

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class MemoryCommonUsageStats(init, used, committed, max)[source]

Memory usage statistics.

init
Type

int

used
Type

int

committed
Type

int

max
Type

int

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class MemoryStats(pending_finalization, heap, non_heap)[source]

Memory statistics.

pending_finalization
Type

int

heap
Type

MemoryCommonUsageStats

non_heap
Type

MemoryCommonUsageStats

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class GCStats(name, collection_count, collection_time, pools)[source]

Garbage collection statistics.

name
Type

str

collection_count
Type

int

collection_time
Type

int

pools
Type

List[str]

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class MemoryPoolStats(name, type, collection_usage, collection_usage_threshold, collection_usage_threshold_count, peak_usage, usage, usage_threshold, usage_threshold_count, managers)[source]

Memory pool statistics.

name

Name of the pool

Type

str

type

Type of the pool. This is either “HEAP” or “NON_HEAP”.

Type

str

collection_usage
Type

Optional[MemoryHeapStats]

collection_usage_threshold
Type

Optional[int]

collection_usage_threshold_count
Type

Optional[int]

peak_usage
Type

MemoryCommonUsageStats

usage
Type

MemoryCommonUsageStats

usage_threshold
Type

int

usage_threshold_count
Type

int

managers
Type

List[str]

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class MemoryManagerStats(name, pools)[source]

Memory manager statistics.

name

Name of the manager

Type

str

pools

Memory pools

Type

List[str]

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class FrameStats(user, guild, success, loss)[source]

Frame statistics for a guild player.

user

User ID

Type

int

guild

Guild ID

Type

int

success

Amount of successful frames

Type

int

loss

Amount of lost frames

Type

int

See also

This statistic can be found in Stats which is retrieved from Andesite by the clients. Both HTTP and WebSocket are able to get them.

class Stats(players, runtime, os, cpu, class_loading, thread, compilation, memory, gc, memory_pools, memory_managers, frame_stats)[source]

Statistics sent by Andesite

players

Player statistics

Type

PlayersStats

runtime

Runtime statistics

Type

RuntimeStats

os

OS statistics

Type

OSStats

cpu

CPU statistics

Type

CPUStats

class_loading

Class loading statistics

Type

ClassLoadingStats

thread

Thread statistics

Type

ThreadStats

compilation

Compilation statistics

Type

CompilationStats

memory

Memory statistics

Type

MemoryStats

gc

GC statistics

Type

List[GCStats]

memory_pools

Memory pool statistics

Type

List[MemoryPoolStats]

memory_managers

Memory manager statistics

Type

List[MemoryManagerStats]

frame_stats

Frame statistics

Type

List[FrameStats]

Exceptions

exception AndesiteException(class_name, message, stack, suppressed)[source]

Bases: Exception

Andesite’s Error represented as python exceptions.

class_name

Class name of the error

Type

str

message

message of the error

Type

Optional[str]

stack

cause of the error

Type

List[StackFrame]

suppressed

suppressed errors

Type

List[Error]

exception HTTPError(code, message)[source]

Bases: Exception

Andesite error.

code

HTTP error code

Type

int

message

Message sent by Andesite

Type

str

exception PoolException(pool)[source]

Bases: Exception

Pool exceptions.

pool

Pool which raised the error

Type

ClientPool

exception PoolEmptyError(pool)[source]

Bases: andesite.pools.PoolException

Raised when a pool is empty but shouldn’t be.

discord.py integration

add_voice_server_update_handler(discord_client, andesite_client)[source]

Add a voice server update listener to the discord client.

Parameters
  • discord_client (Client) – Discord client to add the listener to.

  • andesite_client (WebSocketInterface) – Andesite web socket client to use to send the voice server update.

This will listen to socket responses using the discord client and trigger WebSocketInterface.voice_server_update.

Return type

None

remove_voice_server_update_handler(discord_client, andesite_client)[source]

Remove the socket response handler added by add_voice_server_update_handler.

Parameters
  • discord_client (Client) – Discord client to remove listener from.

  • andesite_client (WebSocketInterface) – Andesite web socket client to use to send the voice server update.

Return type

None

async connect_voice_channel(client, *args, **kwargs)[source]

Connect to a voice channel.

This function has two signatures, you can either call it with a VoiceChannel, or provide a guild / guild id and the voice channel id.

Return type

None

async disconnect_voice_channel(client, guild)[source]

Disconnect from the current voice channel.

Return type

None

async update_voice_state(client, guild_id, channel_id)[source]

Update the voice state.

Parameters
  • client (Client) – discord.py client.

  • guild_id (int) – Guild id to target

  • channel_id (Optional[int]) – Channel id to connect to. If None, disconnect from the current channel.

Return type

None

create_region_comparator(discord_client, *, region_comp=None)[source]

Create a region comparator which compares the guild region with the node region.

You can use the created comparator for the WebSocketPool.

Parameters
  • discord_client (Client) – Client to use to determine the guild region.

  • region_comp (Optional[Callable[[str, str], int]]) – Specify the actual function which compares the guild region and the Andesite node region. Defaults to compare_regions.

Return type

Callable[[int, Optional[str]], int]

Returns

Region comparator which uses region_comp to compare guild region with node region.

compare_regions(a_region, b_region)[source]

Compare two region names.

The order of the provided regions is irrelevant.

Parameters
  • a_region (str) – First region name

  • b_region (str) – Second region name

Return type

int

Returns

0 if the regions can’t be properly compared (ex: Node region unknown or guild id unknown). If the regions can be compared the result is the sum of the following points:

  • 2 points if both regions are in the same country

  • 1 point if both regions are in the same part of a country (ex: us_west) (This point is also awarded if both regions don’t specify a country part)