Remedia

@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);
OptionTypeDescription
nodesRemediaNodeConfig[]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.
botUserIdstringBot user snowflake. Required when any node is remote. Sent as X-Remedia-Bot-Id.
requestTimeoutMsnumberRemote RPC timeout. Default 15000.
maxPendingRequestsnumberConcurrent RPC requests per remote node. Default 128.
selectNodeNodeSelectionOptional callback choosing among healthy candidates for a new guild.
MemberDescription
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.
nodesRead-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

TypeFields
{ 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).

OptionDescription
guildId, channelId, userIdRequired snowflake strings. userId is the bot's user ID.
nodeIdPin the guild to a configured node.
pluginHostsOnly consider nodes that configure all of these plugin host IDs.
selfDeaf, selfMuteDiscord voice state. Default true and false.
volume, filterGraphInitial gain (0 to 2, default 1) and FFmpeg filtergraph.
crossfadeOpt in to crossfading.
MemberDescription
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, snapshotCached 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.

ClassRaised when
RemediaRpcErrorA remote command failed; code is the server's error code.
NodeUnavailableErrorThe node is disconnected.
NodeSelectionErrorA node cannot be selected, or a selection is ambiguous or contradictory.
UnsupportedMediaSourceErrorThe node cannot accept the source type.
PluginOperationsUnsupportedErrorThe node is embedded, has no plugin hosts, or predates forwarding.
SessionLostErrorThe server dropped the resumable session.
ProtocolErrorA node violated the RPC contract.
DiscordBotMismatchErrorA 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.

On this page