Compare commits

..

No commits in common. "3473657fbb38e6b7a5dc6f3f20346a3e02cd967e" and "d78c4ec9fd98b6f990625534548c28d84ecc8337" have entirely different histories.

7 changed files with 5 additions and 102 deletions

View File

@ -1,2 +0,0 @@
ENVIRONMENT=Production
TOKEN=<YOUR BOT TOKEN>

2
.gitignore vendored
View File

@ -3,5 +3,3 @@
# Ignore Gradle build output directory
build
.vscode
.env

View File

@ -1,3 +1,3 @@
# TomatenMusic3
A simple Discord Music Bot written in Java with Javacord
A simple Discord Music Bot written in Java with Discord4J

View File

@ -8,7 +8,6 @@
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
application
id("com.gradleup.shadow") version "8.3.3"
}
repositories {
@ -24,9 +23,6 @@ dependencies {
// This dependency is used by the application.
implementation(libs.guava)
implementation(libs.javacord)
implementation(libs.dotenv)
implementation(libs.log4j)
}
// Apply a specific Java toolchain to ease working on different environments.
@ -41,13 +37,6 @@ application {
mainClass = "net.tomatentum.tomatenmusic3.App"
}
tasks.withType<Jar> {
manifest {
attributes["Main-Class"] = application.mainClass
}
}
tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()

View File

@ -1,64 +1,10 @@
/*
* This source file was generated by the Gradle 'init' task
*/
package net.tomatentum.tomatenmusic3;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder;
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
import org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuilder;
import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import org.javacord.api.DiscordApi;
import org.javacord.api.DiscordApiBuilder;
import org.javacord.api.entity.intent.Intent;
import io.github.cdimascio.dotenv.Dotenv;
public class App {
public static void main(String[] args) {
new App().connect();
}
private static String LOGGERPATTERN = "%-22d{dd MMM yyyy HH:mm:ss} (%t) [%c{3}] %p: %m%n";
private Config config;
private DiscordApi client;
private Logger logger;
private App() {
Dotenv env = Dotenv.configure().ignoreIfMissing().load();
this.config = new Config(env);
initLogger();
}
private void initLogger() {
ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
AppenderComponentBuilder cbuilder =
builder.newAppender("Console", "Console")
.add(builder
.newLayout("PatternLayout")
.addAttribute("pattern", LOGGERPATTERN)
);
RootLoggerComponentBuilder rlbuilder =
builder.newRootLogger(config.isDevelopment() ? Level.DEBUG : Level.INFO)
.add(builder.newAppenderRef("Console"));
BuiltConfiguration logconf = builder.add(cbuilder).add(rlbuilder).build();
Configurator.reconfigure(logconf);
logger = LogManager.getLogger(this);
}
public void connect() {
client = new DiscordApiBuilder()
.setToken(config.token())
.addIntents(Intent.GUILD_VOICE_STATES)
.login().join();
logger.log(Level.INFO, "connected as {}", client.getYourself().getName());
}
}

View File

@ -1,20 +0,0 @@
package net.tomatentum.tomatenmusic3;
import io.github.cdimascio.dotenv.Dotenv;
public class Config {
private Dotenv env;
public Config(Dotenv env) {
this.env = env;
}
public String token() {
return env.get("TOKEN");
}
public boolean isDevelopment() {
return env.get("ENVIRONMENT").equals("Development");
}
}

View File

@ -4,15 +4,7 @@
[versions]
guava = "33.0.0-jre"
junit-jupiter = "5.10.2"
javacord = "3.8.0"
dotenv = "3.0.0"
log4j = "2.24.1"
[libraries]
guava = { module = "com.google.guava:guava", version.ref = "guava" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
javacord = { module = "org.javacord:javacord", version.ref = "javacord" }
dotenv = { module = "io.github.cdimascio:dotenv-java", version.ref = "dotenv"}
log4j = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j"}