discord4j.core.DiscordClientBuilder Java Examples
The following examples show how to use
discord4j.core.DiscordClientBuilder.
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: DisCalClient.java From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates the DisCal bot client. * * @return The client if successful, otherwise <code>null</code>. */ private static DiscordClient createClient() { DiscordClientBuilder clientBuilder = new DiscordClientBuilder(BotSettings.TOKEN.get()); //Handle shard count and index for multiple java instances clientBuilder.setShardIndex(Integer.valueOf(BotSettings.SHARD_INDEX.get())); clientBuilder.setShardCount(Integer.valueOf(BotSettings.SHARD_COUNT.get())); clientBuilder.setInitialPresence(Presence.online(Activity.playing("Booting Up!"))); //Redis info + store service for caching if (BotSettings.USE_REDIS_STORES.get().equalsIgnoreCase("true")) { RedisURI uri = RedisURI.Builder .redis(BotSettings.REDIS_HOSTNAME.get(), Integer.valueOf(BotSettings.REDIS_PORT.get())) .withPassword(BotSettings.REDIS_PASSWORD.get()) .build(); RedisStoreService rss = new RedisStoreService(RedisClient.create(uri)); MappingStoreService mss = MappingStoreService.create() .setMappings(rss, GuildBean.class, MessageBean.class) .setFallback(new JdkStoreService()); clientBuilder.setStoreService(mss); } else { clientBuilder.setStoreService(new JdkStoreService()); } return clientBuilder.build(); }
Example #2
Source File: DisCalClient.java From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 | 4 votes |
/** * Creates the DisCal bot client. * * @return The client if successful, otherwise <code>null</code>. */ private static DiscordClient createClient() { DiscordClientBuilder clientBuilder = new DiscordClientBuilder(BotSettings.TOKEN.get()); //Handle shard count and index for multiple java instances clientBuilder.setShardIndex(Integer.valueOf(BotSettings.SHARD_INDEX.get())); clientBuilder.setShardCount(Integer.valueOf(BotSettings.SHARD_COUNT.get())); clientBuilder.setInitialPresence(Presence.online(Activity.playing("Booting Up!"))); //Redis info + store service for caching if (BotSettings.USE_REDIS_STORES.get().equalsIgnoreCase("true")) { RedisURI uri = RedisURI.Builder .redis(BotSettings.REDIS_HOSTNAME.get(), Integer.valueOf(BotSettings.REDIS_PORT.get())) .withPassword(BotSettings.REDIS_PASSWORD.get()) .build(); RedisStoreService rss = new RedisStoreService(RedisClient.create(uri)); MappingStoreService mss = MappingStoreService.create() .setMappings(rss, GuildBean.class, MessageBean.class) .setFallback(new JdkStoreService()); clientBuilder.setStoreService(mss); } else { clientBuilder.setStoreService(new JdkStoreService()); } return clientBuilder.build(); }
Example #3
Source File: Main.java From lavaplayer with Apache License 2.0 | 4 votes |
public static void main(String[] args) { DiscordClient client = new DiscordClientBuilder(System.getProperty("botToken")).build(); new Main().registerListeners(client.getEventDispatcher()); client.login().block(); }