Public API for Discord voice support.
Manages voice connections per guild, including joining/leaving voice channels, audio playback, and listening to incoming audio.
Usage
# Join a voice channel
EDA.Voice.join(guild_id, channel_id)
# Play audio from a URL
EDA.Voice.play(guild_id, "https://example.com/audio.mp3")
# Stop playback
EDA.Voice.stop(guild_id)
# Leave voice
EDA.Voice.leave(guild_id)
Summary
Functions
Returns the channel ID the bot is connected to in the given guild, or nil.
Returns a specification to start this module under a supervisor.
Returns the voice state for the given guild if the connection is ready.
Joins a voice channel.
Leaves the voice channel in the given guild.
Receives count voice packets (blocking).
Pauses audio playback.
Plays audio from the given input.
Returns true if audio is currently playing in the given guild.
Returns true if the voice connection is ready for the given guild.
Resumes audio playback.
Sets the audio pid for a guild, preventing conflicts with play/3.
Use nil to clear it when done.
Enables continuous audio receiving for the given guild.
Stops audio playback in the given guild.
Disables continuous audio receiving for the given guild.
Functions
Returns the channel ID the bot is connected to in the given guild, or nil.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get_voice_state(String.t()) :: {:ok, EDA.Voice.State.t()} | {:error, :not_ready | :not_connected}
Returns the voice state for the given guild if the connection is ready.
Joins a voice channel.
Options:
:mute- Join self-muted (default:false):deaf- Join self-deafened (default:false)
@spec leave(String.t()) :: :ok
Leaves the voice channel in the given guild.
Receives count voice packets (blocking).
Returns a list of {ssrc, opus_data} tuples.
@spec pause(String.t()) :: :ok
Pauses audio playback.
@spec play(String.t(), String.t() | Enumerable.t()) :: :ok | {:error, term()}
Plays audio from the given input.
Types:
:url- URL or file path (passed to ffmpeg):raw- Raw opus frames
Options:
:volume- FFmpeg volume multiplier applied to:urlinputs
@spec play(String.t(), String.t() | Enumerable.t(), keyword()) :: :ok | {:error, term()}
@spec play(String.t(), String.t() | Enumerable.t(), atom()) :: :ok | {:error, term()}
Returns true if audio is currently playing in the given guild.
Returns true if the voice connection is ready for the given guild.
@spec resume(String.t()) :: :ok
Resumes audio playback.
Sets the audio pid for a guild, preventing conflicts with play/3.
Use nil to clear it when done.
Enables continuous audio receiving for the given guild.
Incoming voice packets will be dispatched as VOICE_AUDIO events
via EDA.Gateway.Events, along with VOICE_SPEAKING_START and
VOICE_SPEAKING_STOP events when users begin or stop speaking.
@spec stop(String.t()) :: :ok
Stops audio playback in the given guild.
@spec stop_listening(String.t()) :: :ok
Disables continuous audio receiving for the given guild.