lavalink.client.io.jda.JdaLavalink Java Examples
The following examples show how to use
lavalink.client.io.jda.JdaLavalink.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LavalinkTest.java From Lavalink-Client with MIT License | 6 votes |
@BeforeAll static void setUp() throws Exception { JDABuilder jdaBuilder = new JDABuilder(AccountType.BOT) .setToken(getSystemProperty(PROPERTY_TOKEN)); JDA selfId = jdaBuilder.build(); lavalink = new JdaLavalink(selfId.retrieveApplicationInfo().submit().get(30, TimeUnit.SECONDS).getId(), 1, integer -> jda); selfId.shutdown(); lavalink.addNode(new URI("ws://localhost:5555"), "youshallnotpass"); jda = jdaBuilder .addEventListeners(lavalink) .build(); Thread.sleep(2000); assertTrue(lavalink.getNodes().get(0).isAvailable(), "Could not connect to lavalink server"); }
Example #2
Source File: LavalinkTest.java From Lavalink-Client with MIT License | 6 votes |
private static void ensureConnected(JdaLavalink lavalink, VoiceChannel voiceChannel) { JdaLink link = lavalink.getLink(voiceChannel.getGuild()); link.connect(voiceChannel); long started = System.currentTimeMillis(); while (link.getState() != Link.State.CONNECTED && System.currentTimeMillis() - started < 10000 //wait 10 sec max && !Thread.currentThread().isInterrupted()) { try { Thread.sleep(100); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } link.connect(voiceChannel); } assertEquals(Link.State.CONNECTED, link.getState(), "Failed to connect to voice channel in a reasonable amount of time"); }
Example #3
Source File: LavalinkTest.java From Lavalink-Client with MIT License | 6 votes |
private static void ensureNotConnected(JdaLavalink lavalink, VoiceChannel voiceChannel) { Link link = lavalink.getLink(voiceChannel.getGuild()); link.disconnect(); long started = System.currentTimeMillis(); while (link.getState() != Link.State.NOT_CONNECTED && link.getState() != Link.State.DISCONNECTING && System.currentTimeMillis() - started < 10000 //wait 10 sec max && !Thread.currentThread().isInterrupted()) { try { Thread.sleep(100); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } link.disconnect(); } assertTrue(link.getState() == Link.State.NOT_CONNECTED || link.getState() == Link.State.DISCONNECTING, "Failed to disconnect from voice channel in a reasonable amount of time"); }
Example #4
Source File: LavalinkManager.java From SkyBot with GNU Affero General Public License v3.0 | 5 votes |
public void start(DunctebotConfig c, AudioUtils a) { this.config = c; this.audioUtils = a; if (!isEnabled()) return; final String userId = getIdFromToken(config.discord.token); lavalink = new JdaLavalink( userId, config.discord.totalShards, shardId -> SkyBot.getInstance().getShardManager().getShardById(shardId) ); loadNodes(); }
Example #5
Source File: LavalinkManager.java From SkyBot with GNU Affero General Public License v3.0 | 5 votes |
private void loadNodes() { final JdaLavalink lavalink = getLavalink(); for (final DunctebotConfig.Lavalink.LavalinkNode node : config.lavalink.nodes) { lavalink.addNode(URI.create(node.wsurl), node.pass, LavalinkRegion.valueOf(node.region)); } }
Example #6
Source File: DefaultAudioServiceImpl.java From JuniperBot with GNU General Public License v3.0 | 5 votes |
@Override public void configure(DiscordService discordService, DefaultShardManagerBuilder builder) { if (!getConfiguration().isEnabled()) { return; } lavaLink = new JdaLavalink( discordService.getUserId(), workerProperties.getDiscord().getShardsTotal(), discordService::getShardById ); builder.setVoiceDispatchInterceptor(lavaLink.getVoiceInterceptor()); builder.addEventListeners(lavaLink); if (CollectionUtils.isNotEmpty(getConfiguration().getNodes())) { getConfiguration().getNodes().forEach(e -> { try { lavaLink.addNode(e.getName(), new URI(e.getUrl()), e.getPassword()); } catch (URISyntaxException e1) { log.warn("Could not add node {}", e, e1); } }); } var discovery = getConfiguration().getDiscovery(); if (discovery != null && discovery.isEnabled() && StringUtils.isNotEmpty(discovery.getServiceName())) { scheduler.scheduleWithFixedDelay(this::lookUpDiscovery, 60000); } }
Example #7
Source File: LavalinkManager.java From SkyBot with GNU Affero General Public License v3.0 | 4 votes |
public JdaLavalink getLavalink() { return lavalink; }
Example #8
Source File: MantaroBot.java From MantaroBot with GNU General Public License v3.0 | 4 votes |
public JdaLavalink getLavaLink() { return this.lavaLink; }
Example #9
Source File: LavaAudioService.java From JuniperBot with GNU General Public License v3.0 | votes |
JdaLavalink getLavaLink();