Skip to content

Commit

Permalink
Merge pull request #25 from NovaFox161/v3-rewrite
Browse files Browse the repository at this point in the history
V3 rewrite
  • Loading branch information
NovaFox161 authored Mar 19, 2019
2 parents d2ba9b3 + ee61d49 commit 03c7386
Show file tree
Hide file tree
Showing 68 changed files with 2,132 additions and 2,699 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ hs_err_pid*
**/target/
/src/main/resources/client_secret.json

**/*.iml
**/*.iml
**/dependency-reduced-pom.xml
**/META-INF/
**/META-INF/
73 changes: 29 additions & 44 deletions client/client.iml
Original file line number Diff line number Diff line change
@@ -1,60 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/../target/classes" />
<output-test url="file://$MODULE_DIR$/../target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="core" />
<orderEntry type="library" name="Maven: org.jetbrains:annotations:16.0.2" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains:annotations:17.0.0" level="project" />
<orderEntry type="library" name="Maven: org.dreamexposure:NovaUtils:1.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.discord4j.discord4j:discord4j-core:82e1df452e" level="project" />
<orderEntry type="library" name="Maven: com.discord4j.discord4j:discord4j-rest:82e1df452e" level="project" />
<orderEntry type="library" name="Maven: com.discord4j.discord4j:discord4j-common:82e1df452e" level="project" />
<orderEntry type="library" name="Maven: com.github.quanticc:reactor-netty:v0.8.0.M1-20180724" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-http:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-http2:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler-proxy:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-socks:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-epoll:linux-x86_64:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-unix-common:4.1.27.Final" level="project" />
<orderEntry type="library" name="Maven: com.discord4j:discord4j-core:3.0.0" level="project" />
<orderEntry type="library" name="Maven: com.discord4j:discord4j-rest:3.0.0" level="project" />
<orderEntry type="library" name="Maven: com.discord4j:discord4j-common:3.0.0" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor.netty:reactor-netty:0.8.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-http:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-http2:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler-proxy:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec-socks:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-epoll:linux-x86_64:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-unix-common:4.1.33.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.9" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.8.9" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor.addons:reactor-extra:3.2.0.M1" level="project" />
<orderEntry type="library" name="Maven: com.discord4j.discord4j:discord4j-gateway:82e1df452e" level="project" />
<orderEntry type="library" name="Maven: com.discord4j.stores:stores-jdk:ea3e145" level="project" />
<orderEntry type="library" name="Maven: com.discord4j.stores:stores-common:ea3e145" level="project" />
<orderEntry type="library" name="Maven: com.discord4j.stores:stores-api:ea3e145" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor.addons:reactor-extra:3.2.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:2.0.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.discord4j:discord4j-gateway:3.0.0" level="project" />
<orderEntry type="library" name="Maven: com.discord4j:discord4j-voice:3.0.0" level="project" />
<orderEntry type="library" name="Maven: com.discord4j:simple-fsm:1.0.1" level="project" />
<orderEntry type="library" name="Maven: com.discord4j:stores-jdk:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.discord4j:stores-common:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.discord4j:stores-api:1.0.0" level="project" />
<orderEntry type="library" name="Maven: com.austinv11.servicer:Servicer:1.0.0" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" name="Maven: com.google.auto.service:auto-service:1.0-rc4" level="project" />
<orderEntry type="library" name="Maven: com.google.auto:auto-common:0.8" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:23.5-jre" level="project" />
<orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.0.0" level="project" />
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.0.18" level="project" />
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.7" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.11" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
Expand All @@ -76,14 +63,12 @@
<orderEntry type="library" name="Maven: com.google.oauth-client:google-oauth-client-java6:1.22.0" level="project" />
<orderEntry type="library" name="Maven: org.mortbay.jetty:jetty:6.1.26" level="project" />
<orderEntry type="library" name="Maven: org.mortbay.jetty:jetty-util:6.1.26" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.12" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.15" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.6.1" level="project" />
<orderEntry type="library" name="Maven: org.json:json:20140107" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.9" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.10.0" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.14.0" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.2.0.M3" level="project" />
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.2" level="project" />
</component>
</module>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.dreamexposure.discal.client;

import discord4j.core.DiscordClient;
import discord4j.core.DiscordClientBuilder;
import discord4j.core.event.domain.lifecycle.ReadyEvent;
import org.dreamexposure.discal.client.listeners.discal.CrossTalkEventListener;
import org.dreamexposure.discal.client.listeners.discord.ReadyEventListener;
import org.dreamexposure.discal.client.message.MessageManager;
Expand All @@ -10,17 +13,14 @@
import org.dreamexposure.discal.core.object.BotSettings;
import org.dreamexposure.novautils.event.EventManager;
import org.dreamexposure.novautils.network.crosstalk.ClientSocketHandler;
import sx.blah.discord.api.ClientBuilder;
import sx.blah.discord.api.IDiscordClient;
import sx.blah.discord.api.events.EventDispatcher;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class DisCalClient {
private static IDiscordClient client;
private static DiscordClient client;

public static void main(String[] args) throws IOException {
//Get settings
Expand All @@ -35,16 +35,12 @@ public static void main(String[] args) throws IOException {
client = createClient();

//Register discord events
EventDispatcher dispatcher = client.getDispatcher();
dispatcher.registerListener(new ReadyEventListener());
client.getEventDispatcher().on(ReadyEvent.class).subscribe(ReadyEventListener::handle);

//Register discal events
EventManager.get().init();
EventManager.get().getEventBus().register(new CrossTalkEventListener());

//Login
client.login();

//Register commands
CommandExecutor executor = CommandExecutor.getExecutor().enable();
executor.registerCommand(new HelpCommand());
Expand Down Expand Up @@ -73,25 +69,26 @@ public static void main(String[] args) throws IOException {
ClientSocketHandler.setValues(BotSettings.CROSSTALK_SERVER_HOST.get(), Integer.valueOf(BotSettings.CROSSTALK_SERVER_PORT.get()), BotSettings.CROSSTALK_CLIENT_HOST.get(), Integer.valueOf(BotSettings.CROSSTALK_CLIENT_PORT.get()));

ClientSocketHandler.initListener();

//Login
client.login().block();
}

/**
* Creates the DisCal bot client.
*
* @return The client if successful, otherwise <code>null</code>.
*/
private static IDiscordClient createClient() {
ClientBuilder clientBuilder = new ClientBuilder().withToken(BotSettings.TOKEN.get());
//In case of disconnects and shit
clientBuilder.setMaxReconnectAttempts(10);
clientBuilder.setMaxReconnectAttempts(10);
private static DiscordClient createClient() {
DiscordClientBuilder clientBuilder = new DiscordClientBuilder(BotSettings.TOKEN.get());
//Handle shard count and index.
clientBuilder.setShard(Integer.valueOf(BotSettings.SHARD_INDEX.get()), Integer.valueOf(BotSettings.SHARD_COUNT.get()));
clientBuilder.setShardIndex(Integer.valueOf(BotSettings.SHARD_INDEX.get()));
clientBuilder.setShardCount(Integer.valueOf(BotSettings.SHARD_COUNT.get()));
return clientBuilder.build();
}

//Public stuffs
public static IDiscordClient getClient() {
public static DiscordClient getClient() {
return client;
}
}
Loading

0 comments on commit 03c7386

Please sign in to comment.