@remedia/client reference
Options, members, events, and errors exported by @remedia/client.
Use these tables to find client options and session methods. For a working integration, start with Using @remedia/client. Published declarations include the complete parameter and return types.
RemediaClient
const client = await RemediaClient.create(options);| Option | Type | Description |
|---|---|---|
nodes | RemediaNodeConfig[] | Required, at least one. Node IDs must be unique. |
send | (guildId, payload) => void | Promise<void> | Required. Sends a Discord Gateway payload through the shard responsible for the guild. |
botUserId | string | Bot user snowflake. Required when any node is remote. Sent as X-Remedia-Bot-Id. |
requestTimeoutMs | number | Remote RPC timeout. Default 15000. |
maxPendingRequests | number | Concurrent RPC requests per remote node. Default 128. |
selectNode | NodeSelection | Optional callback choosing among healthy candidates for a new guild. |
| Member | Description |
|---|---|
createDiscordSession(options) | Register one guild session. Throws if the guild already has one on this client. |
receive(packet) | Forward a raw Gateway packet. Unrelated packets are ignored. |
probe(source, options?) | Inspect media without playing it. See Media sources and probing. |
plugins.list(options?), plugins.execute(options) | Discover and run plugin operations. See Executing plugin operations. |
nodes | Read-only NodeSnapshot[]: status, health, capacity, capabilities, assigned guilds. |
assignments, getAssignment(guildId) | Sticky guild-to-node mapping. |
close() | Dispose sessions and close nodes. Rejects with an AggregateError if cleanup fails. |
Node configuration
| Type | Fields |
|---|---|
{ type: 'embedded' } | id, capacity? (default 64). Requires @remedia/node. |
{ type: 'remote' } | id, url (remedia://, remedias://, ws:// or wss://), auth?: { username, password }, capacity? (defaults to the server's reported player maximum). |
DiscordSession
Created with createDiscordSession(options).
| Option | Description |
|---|---|
guildId, channelId, userId | Required snowflake strings. userId is the bot's user ID. |
nodeId | Pin the guild to a configured node. |
pluginHosts | Only consider nodes that configure all of these plugin host IDs. |
selfDeaf, selfMute | Discord voice state. Default true and false. |
volume, filterGraph | Initial gain (0 to 2, default 1) and FFmpeg filtergraph. |
crossfade | Opt in to crossfading. |
| Member | Description |
|---|---|
connect(options?) | Join the channel. { signal, timeoutMs }. |
play(source, options?) | Start a source. Resolves with AudioStreamInfo. options: customMetadata, signal. |
pause(), resume(), stop(), seek(ms) | Playback controls. |
setVolume(gain), filters.set(graph), filters.clear() | Gain and filtergraph. |
getPlaybackTime() | Current adapter elapsed-time estimate in milliseconds. See Positions. |
wait(), refresh() | Wait for a terminal state. Fetch a fresh snapshot. |
move(channelId), setSelfDeaf(flag), setSelfMute(flag) | Voice state. See Session lifecycle. |
migrate(nodeId) | Move to another node. See Nodes and routing. |
stageNext(source, options), stagedSource(), clearStage() | Crossfade staging. |
disconnect(), dispose() | Leave the channel. Leave and release. |
state, position, durationMs, volume, error, connectionState, nodeId, nodeType, assignmentStatus, snapshot | Cached observations. |
hooks.beforePlay(hook) | Ordered middleware before playback. See Events and hooks. |
Events
PlaybackSessionEvents, VoiceSessionEvents and RemediaClientEventNames are exported as const
objects. See Events and hooks for the names and payloads.
Errors
All extend RemediaClientError.
| Class | Raised when |
|---|---|
RemediaRpcError | A remote command failed; code is the server's error code. |
NodeUnavailableError | The node is disconnected. |
NodeSelectionError | A node cannot be selected, or a selection is ambiguous or contradictory. |
UnsupportedMediaSourceError | The node cannot accept the source type. |
PluginOperationsUnsupportedError | The node is embedded, has no plugin hosts, or predates forwarding. |
SessionLostError | The server dropped the resumable session. |
ProtocolError | A node violated the RPC contract. |
DiscordBotMismatchError | A session's userId differs from the client's botUserId. |
Exported types
MediaSource, OperationMediaSource, JsonValue, AudioStreamInfo, PlaybackSnapshot,
NodeSnapshot, NodeCapabilities, GuildAssignment, PluginHostDescriptor,
PluginExecuteOptions, PluginExecuteResult and the option types above are exported from the
package root.