Search in sources :

Example 6 with VoiceConnection

use of io.discloader.discloader.entity.voice.VoiceConnection in project DiscLoader by R3alCl0ud.

the class Main method runVoiceChannelTest.

public static void runVoiceChannelTest() throws Exception {
    CompletableFuture<VoiceConnection> future = new CompletableFuture<>();
    IGuildVoiceChannel channel = guild.getVoiceChannelByName("General");
    VoiceConnection voiceconnection = channel.join().get();
    voiceconnection.addListener(new VoiceEventAdapter() {

        @Override
        public void end(AudioTrack track, AudioTrackEndReason endReason) {
            if (endReason == AudioTrackEndReason.LOAD_FAILED) {
                logger.severe("Test Failed\nFailed to load the audio track.");
            } else {
                logger.info("Track Finished Playing");
            }
            CompletableFuture<VoiceConnection> f16 = voiceconnection.disconnect();
            f16.exceptionally(ex -> {
                future.completeExceptionally(ex);
                return null;
            });
            f16.thenAcceptAsync(vc -> {
                logger.config("Disconnected From VC");
                future.complete(vc);
            });
        }
    });
    voiceconnection.play("https://soundcloud.com/r3alcl0ud/guardians-of-animus");
    future.get();
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Options(io.discloader.discloader.common.start.Options) Gson(com.google.gson.Gson) RichEmbed(io.discloader.discloader.core.entity.message.embed.RichEmbed) DiscLoader(io.discloader.discloader.common.DiscLoader) DLLogger(io.discloader.discloader.common.logger.DLLogger) AudioTrackEndReason(com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason) IGuild(io.discloader.discloader.entity.guild.IGuild) IGuildVoiceChannel(io.discloader.discloader.entity.channel.IGuildVoiceChannel) IUser(io.discloader.discloader.entity.user.IUser) Files(java.nio.file.Files) VoiceEventAdapter(io.discloader.discloader.entity.voice.VoiceEventAdapter) VoiceConnection(io.discloader.discloader.entity.voice.VoiceConnection) IOException(java.io.IOException) Logger(java.util.logging.Logger) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) IGuildTextChannel(io.discloader.discloader.entity.channel.IGuildTextChannel) Paths(java.nio.file.Paths) CommandRegistry(io.discloader.discloader.common.registry.CommandRegistry) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) UnauthorizedException(io.discloader.discloader.common.exceptions.UnauthorizedException) IChannelCategory(io.discloader.discloader.entity.channel.IChannelCategory) IMessage(io.discloader.discloader.entity.message.IMessage) DLOptions(io.discloader.discloader.common.DLOptions) VoiceConnection(io.discloader.discloader.entity.voice.VoiceConnection) CompletableFuture(java.util.concurrent.CompletableFuture) AudioTrackEndReason(com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason) VoiceEventAdapter(io.discloader.discloader.entity.voice.VoiceEventAdapter) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) IGuildVoiceChannel(io.discloader.discloader.entity.channel.IGuildVoiceChannel)

Aggregations

VoiceConnection (io.discloader.discloader.entity.voice.VoiceConnection)6 CompletableFuture (java.util.concurrent.CompletableFuture)4 IGuild (io.discloader.discloader.entity.guild.IGuild)3 Gson (com.google.gson.Gson)2 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)2 AudioTrackEndReason (com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason)2 DLOptions (io.discloader.discloader.common.DLOptions)2 DiscLoader (io.discloader.discloader.common.DiscLoader)2 UnauthorizedException (io.discloader.discloader.common.exceptions.UnauthorizedException)2 DLLogger (io.discloader.discloader.common.logger.DLLogger)2 CommandRegistry (io.discloader.discloader.common.registry.CommandRegistry)2 Options (io.discloader.discloader.common.start.Options)2 RichEmbed (io.discloader.discloader.core.entity.message.embed.RichEmbed)2 IChannelCategory (io.discloader.discloader.entity.channel.IChannelCategory)2 IGuildTextChannel (io.discloader.discloader.entity.channel.IGuildTextChannel)2 IGuildVoiceChannel (io.discloader.discloader.entity.channel.IGuildVoiceChannel)2 IMessage (io.discloader.discloader.entity.message.IMessage)2 IUser (io.discloader.discloader.entity.user.IUser)2 VoiceEventAdapter (io.discloader.discloader.entity.voice.VoiceEventAdapter)2 File (java.io.File)2