use of discord4j.core.object.entity.VoiceChannel in project lavaplayer by sedmelluq.
the class Main method attachToFirstVoiceChannel.
private static void attachToFirstVoiceChannel(Guild guild, D4jAudioProvider provider) {
VoiceChannel voiceChannel = guild.getChannels().ofType(VoiceChannel.class).blockFirst();
boolean inVoiceChannel = // Check if any VoiceState for this guild relates to bot
guild.getVoiceStates().any(voiceState -> guild.getClient().getSelfId().map(voiceState.getUserId()::equals).orElse(false)).block();
if (!inVoiceChannel) {
voiceChannel.join(spec -> spec.setProvider(provider)).block();
}
}
Aggregations