use of org.javacord.api.event.server.VoiceServerUpdateEvent in project Javacord by BtoBastian.
the class VoiceServerUpdateHandler method handle.
@Override
public void handle(JsonNode packet) {
String token = packet.get("token").asText();
String endpoint = packet.get("endpoint").asText();
long serverId = packet.get("guild_id").asLong();
// We need the session id to connect to an audio websocket
AudioConnectionImpl pendingAudioConnection = api.getPendingAudioConnectionByServerId(serverId);
if (pendingAudioConnection != null) {
pendingAudioConnection.setToken(token);
pendingAudioConnection.setEndpoint(endpoint);
pendingAudioConnection.tryConnect();
}
api.getServerById(serverId).ifPresent(server -> {
VoiceServerUpdateEvent event = new VoiceServerUpdateEventImpl(server, token, endpoint);
api.getEventDispatcher().dispatchVoiceServerUpdateEvent((DispatchQueueSelector) server, server, event);
});
}
Aggregations