sorted all errors and made first Jar file

version 1.0
This commit is contained in:
nzBryce101
2024-04-15 23:18:28 +12:00
parent 4cf29ee0bd
commit 79517ca036
10 changed files with 80 additions and 17 deletions

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"java.compile.nullAnalysis.mode": "automatic"
}

BIN
MCdiscord_bot-1.jar Normal file

Binary file not shown.

50
pom.xml
View File

@@ -7,6 +7,7 @@
<groupId>com.example</groupId> <groupId>com.example</groupId>
<artifactId>minecraft-chatbot</artifactId> <artifactId>minecraft-chatbot</artifactId>
<version>1.0</version> <version>1.0</version>
<packaging>jar</packaging> <!-- Specify the correct packaging type here -->
<properties> <properties>
<!-- Specify Java version --> <!-- Specify Java version -->
@@ -14,19 +15,28 @@
<maven.compiler.target>21</maven.compiler.target> <maven.compiler.target>21</maven.compiler.target>
</properties> </properties>
<repositories>
<repository>
<id>spigot-repo</id>
<name>spigot-1.20.4</name>
<url>https://repo.rosewooddev.io/repository/public/</url>
</repository>
</repositories>
<dependencies> <dependencies>
<!-- Spigot API dependency --> <!-- Spigot API dependency -->
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version> <version>1.20.4</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!--(Java Discord API) with JFlac and Tritonus-dsp --> <!--(Java Discord API) with JFlac and Tritonus-dsp -->
<dependency> <dependency>
<!-- https://mvnrepository.com/artifact/net.dv8tion/JDA -->
<groupId>net.dv8tion</groupId> <groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId> <artifactId>JDA</artifactId>
<version>1.2.2_139</version> <!-- Update version to the latest stable version --> <version>5.0.0-alpha.4</version><!-- Update version to the latest stable version -->
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>jflac</groupId> <groupId>jflac</groupId>
@@ -38,15 +48,34 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<!-- Logging--> <!-- Logging-->
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId> <artifactId>log4j-core</artifactId>
<version>2.23.1</version> <!-- Use the latest STABLE version --> <version>2.23.1</version> <!-- Use the latest STABLE version -->
</dependency> </dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.23.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<type>maven-plugin</type>
</dependency>
<!-- Add other dependencies as needed --> <!-- Add other dependencies as needed -->
<dependency>
<groupId>net.katsstuff</groupId>
<artifactId>ackcord-data_sjs1_2.13</artifactId>
<version>2.0.0.0-M1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@@ -55,14 +84,23 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <!-- Use the appropriate version --> <version>3.13.0</version> <!-- Use the appropriate version -->
<executions>
<execution>
<configuration> <configuration>
<rules>
<requireMavenVersion>
<version>3.0</version>
</requireMavenVersion>
</rules>
<source>21</source> <!-- Update to the Java version you're using --> <source>21</source> <!-- Update to the Java version you're using -->
<target>21</target> <!-- Update to the Java version you're using --> <target>21</target> <!-- Update to the Java version you're using -->
<compilerArgs> <compilerArgs>
<arg>--enable-preview</arg> <!-- Enable preview features --> <arg>--enable-preview</arg> <!-- Enable preview features -->
</compilerArgs> </compilerArgs>
</configuration> </configuration>
</execution>
</executions>
</plugin> </plugin>
<!-- Add other plugins as needed --> <!-- Add other plugins as needed -->
</plugins> </plugins>

View File

@@ -1,12 +1,12 @@
import net.dv8tion.jda.api.JDABuilder; import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.entities.TextChannel;
import javax.annotation.Nonnull;
import javax.security.auth.login.LoginException; import javax.security.auth.login.LoginException;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.*;
import org.apache.logging.log4j.Logger;
public class disMCbot extends ListenerAdapter { public class disMCbot extends ListenerAdapter {
@@ -17,13 +17,14 @@ public class disMCbot extends ListenerAdapter {
public static void main(String[] args) throws LoginException { public static void main(String[] args) throws LoginException {
logger.info("Starting Discord Comms..."); logger.info("Starting Discord Comms...");
JDABuilder builder = JDABuilder.createDefault("MTIyNjY1NTgxODU0NDMxNjQxNw.GALTlL.vPRJyKTEJNqN1Snfj5G-_2306lBKFdOYB1eDXE"); JDABuilder builder = JDABuilder
.createDefault("MTIyNjY1NTgxODU0NDMxNjQxNw.GALTlL.vPRJyKTEJNqN1Snfj5G-_2306lBKFdOYB1eDXE");
builder.addEventListeners(new disMCbot()); builder.addEventListeners(new disMCbot());
builder.build(); builder.build();
} }
@Override @Override
public void onMessageReceived(MessageReceivedEvent event) { public void onMessageReceived(@Nonnull MessageReceivedEvent event) {
if (event.getAuthor().isBot()) return; // Ignore messages from bots if (event.getAuthor().isBot()) return; // Ignore messages from bots
String message = event.getMessage().getContentRaw(); String message = event.getMessage().getContentRaw();
@@ -55,10 +56,13 @@ public class disMCbot extends ListenerAdapter {
// Log It // Log It
logger.info("Message sent to Discord."); logger.info("Message sent to Discord.");
} }
}
}
public void setUpdateChannel(TextChannel channel) { public void setUpdateChannel(TextChannel channel) {
this.updateChannel = channel; this.updateChannel = channel;
} }
} }

Binary file not shown.

13
target/classes/log4j2.xml Normal file
View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<File name="File" fileName="../logs/bot.log">
<PatternLayout pattern="%d{dd-MM-yyyy HH:mm:ss} [%t] %-5level %logger{36} - %msg%n" />
</File>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="File" />
</Root>
</Loggers>
</Configuration>

View File

@@ -0,0 +1,3 @@
artifactId=minecraft-chatbot
groupId=com.example
version=1.0

View File

@@ -0,0 +1 @@
disMCbot.class

View File

@@ -0,0 +1 @@
C:\Users\hbmann\Documents\Projects\_MCdiscord-bot\MCdiscord_bot-1\src\main\java\disMCbot.java

Binary file not shown.