Skip to content

Commit 7c44ad2

Browse files
committed
Added Listener for onReady of the bot. Minor Fixes.
1 parent 66063cd commit 7c44ad2

File tree

4 files changed

+93
-7
lines changed

4 files changed

+93
-7
lines changed

.idea/compiler.xml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,73 @@
77
<groupId>com.Jacrispys</groupId>
88
<artifactId>DiscordBot</artifactId>
99
<version>1.0-SNAPSHOT</version>
10+
<build>
11+
<plugins>
12+
<plugin>
13+
<groupId>org.apache.maven.plugins</groupId>
14+
<artifactId>maven-compiler-plugin</artifactId>
15+
<configuration>
16+
<proc>none</proc>
17+
<source>17</source>
18+
<target>17</target>
19+
</configuration>
20+
<executions>
21+
<execution>
22+
<id>process-test-annotations</id>
23+
<phase>generate-test-resources</phase>
24+
<goals>
25+
<goal>testCompile</goal>
26+
</goals>
27+
<configuration>
28+
<proc>only</proc>
29+
<annotationProcessors>
30+
<annotationProcessor>com.jacrispys.JavaBot.Utils.ExperimentalUtils.ExperimentalProcessor</annotationProcessor>
31+
</annotationProcessors>
32+
</configuration>
33+
</execution>
34+
</executions>
35+
</plugin>
36+
<plugin>
37+
<groupId>org.apache.maven.plugins</groupId>
38+
<artifactId>maven-shade-plugin</artifactId>
39+
<version>3.2.4</version>
40+
<executions>
41+
<execution>
42+
<phase>package</phase>
43+
<goals>
44+
<goal>shade</goal>
45+
</goals>
46+
</execution>
47+
</executions>
48+
</plugin>
49+
50+
<plugin>
51+
<groupId>org.apache.maven.plugins</groupId>
52+
<artifactId>maven-jar-plugin</artifactId>
53+
<version>2.3.1</version>
54+
<configuration>
55+
<archive>
56+
<manifest>
57+
<addClasspath>true</addClasspath>
58+
<classpathPrefix>lib/</classpathPrefix>
59+
<mainClass>com.jacrispys.JavaBot.JavaBotMain</mainClass>
60+
</manifest>
61+
</archive>
62+
<outputDirectory>C:\Users\jvanz\Desktop\Bot</outputDirectory>
63+
</configuration>
64+
</plugin>
65+
</plugins>
66+
</build>
1067

1168
<properties>
1269
<maven.compiler.source>8</maven.compiler.source>
1370
<maven.compiler.target>8</maven.compiler.target>
1471
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1572
<author>Jacrispys</author>
73+
<mainClass>com.jacrispys.JavaBot.JavaBotMain</mainClass>
1674
</properties>
1775

1876
<repositories>
19-
<repository>
20-
<id>dv8tion</id>
21-
<name>m2-dv8tion</name>
22-
<url>https://m2.dv8tion.net/releases</url>
23-
</repository>
2477
<repository>
2578
<id>dv8tion</id>
2679
<name>m2-dv8tion</name>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.jacrispys.JavaBot.Events;
2+
3+
import com.jacrispys.JavaBot.Utils.ChannelStorageManager;
4+
import net.dv8tion.jda.api.entities.Guild;
5+
import net.dv8tion.jda.api.events.ReadyEvent;
6+
import net.dv8tion.jda.api.hooks.ListenerAdapter;
7+
import org.jetbrains.annotations.NotNull;
8+
import org.yaml.snakeyaml.Yaml;
9+
10+
public class BotStartup extends ListenerAdapter {
11+
12+
public void onReady(@NotNull ReadyEvent event) {
13+
// Start GameSpy on enabled servers.
14+
for(Guild guild : event.getJDA().getGuilds()) {
15+
try {
16+
ChannelStorageManager storageManager = new ChannelStorageManager(new Yaml());
17+
if(storageManager.getGuildData(guild, "GameSpy") instanceof Boolean) {
18+
boolean isGameSpyEnabled = (boolean) storageManager.getGuildData(guild, "GameSpy");
19+
if(isGameSpyEnabled) {
20+
GameSpy gameSpy = new GameSpy(guild);
21+
gameSpy.addSpy();
22+
}
23+
}
24+
System.out.println("ready");
25+
} catch(Exception ex) {
26+
return;
27+
}
28+
}
29+
}
30+
}

src/main/resources/META-INF/services/javax.annotation.processing.Processor

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)