Interface VoiceManager
public interface VoiceManager
Manager for voice connections and audio handling.
Plugins can use this interface to join/leave voice channels and manage audio.
DAVE Requirement: Starting March 1st, 2026, all voice connections require
DAVE (Discord Audio/Voice Encryption). Plugins MUST provide a DAVEProvider
when connecting to voice channels.
Example Usage:
VoiceManager voiceManager = context.getVoiceManager();
// Check DAVE availability before connecting
if (!voiceManager.isDAVEAvailable(guildId)) {
context.log("error", "DAVE implementation required for voice");
return;
}
// Connect to voice channel
voiceManager.connect(guildId, voiceChannelId)
.thenAccept(status -> {
if (status == VoiceConnectionStatus.CONNECTED) {
context.log("info", "Connected to voice!");
}
});
-
Method Summary
Modifier and TypeMethodDescriptionconnect(long guildId, long voiceChannelId) Connect to a voice channel.disconnect(long guildId) Disconnect from a voice channel in a guild.Get the currently active DAVE provider.getAudioProvider(long guildId) Get the current audio provider for a guild.getAudioReceiver(long guildId) Get the current audio receiver for a guild.getConnectedChannelId(long guildId) Get the voice channel ID the bot is connected to in a guild.getConnectionStatus(long guildId) Get the current connection status for a guild.default StringGet the DAVE deadline date.booleanisConnected(long guildId) Check if the bot is connected to a voice channel in a guild.booleanisDAVEAvailable(long guildId) Check if a DAVE implementation is available for use.booleanCheck if the current Java version is compatible with DAVE.booleanisSelfDeafened(long guildId) Check if the bot is self-deafened in a guild.booleanisSelfMuted(long guildId) Check if the bot is self-muted in a guild.voidregisterDAVEProvider(String pluginName, DAVEProvider provider) Register a DAVE provider for a plugin.voidsetAudioProvider(long guildId, AudioProvider provider) Set the audio provider for a guild.voidsetAudioReceiver(long guildId, AudioReceiver receiver) Set the audio receiver for a guild.voidsetSelfDeafened(long guildId, boolean deafened) Set whether the bot is self-deafened in a guild.voidsetSelfMuted(long guildId, boolean muted) Set whether the bot is self-muted in a guild.voidunregisterDAVEProvider(String pluginName) Unregister a DAVE provider.
-
Method Details
-
connect
Connect to a voice channel.This requires a DAVE implementation to be registered for the guild.
- Parameters:
guildId- the guild IDvoiceChannelId- the voice channel ID- Returns:
- a future containing the connection status
-
disconnect
Disconnect from a voice channel in a guild.- Parameters:
guildId- the guild ID- Returns:
- a future that completes when disconnected
-
getConnectionStatus
Get the current connection status for a guild.- Parameters:
guildId- the guild ID- Returns:
- the current connection status
-
isConnected
boolean isConnected(long guildId) Check if the bot is connected to a voice channel in a guild.- Parameters:
guildId- the guild ID- Returns:
- true if connected
-
getConnectedChannelId
Get the voice channel ID the bot is connected to in a guild.- Parameters:
guildId- the guild ID- Returns:
- the voice channel ID, or null if not connected
-
setAudioProvider
Set the audio provider for a guild. The provider will supply audio data to be played in the voice channel.- Parameters:
guildId- the guild IDprovider- the audio provider, or null to clear
-
getAudioProvider
Get the current audio provider for a guild.- Parameters:
guildId- the guild ID- Returns:
- the audio provider, or null if none set
-
setAudioReceiver
Set the audio receiver for a guild. The receiver will receive audio data from users in the voice channel.- Parameters:
guildId- the guild IDreceiver- the audio receiver, or null to clear
-
getAudioReceiver
Get the current audio receiver for a guild.- Parameters:
guildId- the guild ID- Returns:
- the audio receiver, or null if none set
-
isDAVEAvailable
boolean isDAVEAvailable(long guildId) Check if a DAVE implementation is available for use.This checks if any DAVE provider has been registered and is ready.
- Parameters:
guildId- the guild ID (for future per-guild DAVE support)- Returns:
- true if DAVE is available
-
isJavaVersionCompatible
boolean isJavaVersionCompatible()Check if the current Java version is compatible with DAVE.- Returns:
- true if Java version meets minimum requirements
-
getDAVEDeadline
Get the DAVE deadline date.- Returns:
- the deadline date string "March 1st, 2026"
-
registerDAVEProvider
Register a DAVE provider for a plugin. Plugins providing DAVE implementations should call this.- Parameters:
pluginName- the name of the plugin providing DAVEprovider- the DAVE provider implementation
-
unregisterDAVEProvider
Unregister a DAVE provider.- Parameters:
pluginName- the name of the plugin
-
getActiveDAVEProvider
DAVEProvider getActiveDAVEProvider()Get the currently active DAVE provider.- Returns:
- the active DAVE provider, or null if none
-
setSelfMuted
void setSelfMuted(long guildId, boolean muted) Set whether the bot is self-muted in a guild.- Parameters:
guildId- the guild IDmuted- true to mute
-
isSelfMuted
boolean isSelfMuted(long guildId) Check if the bot is self-muted in a guild.- Parameters:
guildId- the guild ID- Returns:
- true if self-muted
-
setSelfDeafened
void setSelfDeafened(long guildId, boolean deafened) Set whether the bot is self-deafened in a guild.- Parameters:
guildId- the guild IDdeafened- true to deafen
-
isSelfDeafened
boolean isSelfDeafened(long guildId) Check if the bot is self-deafened in a guild.- Parameters:
guildId- the guild ID- Returns:
- true if self-deafened
-