Skip to content

Commit

Permalink
Fixed Shadowjar Application Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
beanbeanjuice committed Jul 20, 2024
1 parent c5f6f96 commit f03e1ab
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
15 changes: 11 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ plugins {
group = "com.beanbeanjuice"
version = "4.0.0"

tasks.withType<Jar> {
manifest {
attributes["Main-Class"] = "com.beanbeanjuice.cafebot.CafeBot"
}
}

allprojects {
group = "com.beanbeanjuice"

Expand Down Expand Up @@ -54,7 +60,6 @@ allprojects {
}

tasks.withType<ShadowJar> {
minimize()
archiveClassifier.set("")
archiveBaseName.set(project.name)
destinationDirectory.set(File(rootProject.projectDir, "libs"))
Expand Down Expand Up @@ -88,18 +93,20 @@ dependencies {

implementation("com.fasterxml.jackson.core:jackson-databind:2.17.1")

implementation("com.github.twitch4j", "twitch4j", "1.15.0")
implementation("com.github.twitch4j", "twitch4j", "1.21.0")

compileOnly("org.projectlombok", "lombok", "1.18.32")
annotationProcessor("org.projectlombok", "lombok", "1.18.32")

testImplementation("junit", "junit", "4.13.2")
testImplementation("org.junit.jupiter", "junit-jupiter", "5.8.1")

implementation("com.github.plexpt", "chatgpt", "4.4.0")
}

tasks.withType<ShadowJar> {
minimize {
exclude(dependency("io.github.xanthic.cache:.*:.*"))
}

relocate("net.dv8tion", "com.beanbeanjuice.cafebot.libs.net.dv8tion")
relocate("org.slf4j", "com.beanbeanjuice.cafebot.libs.org.slf4j")
relocate("org.apache.logging.log4j", "com.beanbeanjuice.cafebot.libs.org.apache.logging.log4j")
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/com/beanbeanjuice/cafebot/CafeBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.beanbeanjuice.cafebot.commands.social.MemberCountCommand;
import com.beanbeanjuice.cafebot.commands.social.vent.VentCommand;
import com.beanbeanjuice.cafebot.commands.twitch.TwitchCommand;
import com.beanbeanjuice.cafebot.utility.EnvironmentVariable;
import com.beanbeanjuice.cafebot.utility.commands.CommandHandler;
import com.beanbeanjuice.cafebot.utility.helper.DailyChannelHelper;
import com.beanbeanjuice.cafebot.utility.helper.Helper;
Expand Down Expand Up @@ -110,22 +111,22 @@ public CafeBot() throws InterruptedException {
this.logger = new LogManager(
this,
"cafeBot Logging System",
System.getenv("CAFEBOT_GUILD_ID"),
System.getenv("CAFEBOT_GUILD_LOG_CHANNEL_ID"),
EnvironmentVariable.CAFEBOT_GUILD_ID.getSystemVariable(),
EnvironmentVariable.CAFEBOT_GUILD_LOG_CHANNEL_ID.getSystemVariable(),
"logs/"
);
this.cafeAPI = new CafeAPI(
"beanbeanjuice",
System.getenv("API_PASSWORD"),
RequestLocation.valueOf(System.getenv("CAFEBOT_REQUEST_LOCATION"))
EnvironmentVariable.API_PASSWORD.getSystemVariable(),
RequestLocation.valueOf(EnvironmentVariable.CAFEBOT_REQUEST_LOCATION.getSystemVariable())
);
this.cafeAPI.setKawaiiAPI(System.getenv("KAWAII_API_TOKEN"));
this.cafeAPI.setKawaiiAPI(EnvironmentVariable.KAWAII_API_TOKEN.getSystemVariable());

this.logger.addWebhookURL(System.getenv("CAFEBOT_GUILD_WEBHOOK_URL"));
this.logger.addWebhookURL(EnvironmentVariable.CAFEBOT_GUILD_WEBHOOK_URL.getSystemVariable());
this.logger.log(CafeBot.class, LogLevel.OKAY, "Starting bot!", true, false);

this.JDA = JDABuilder
.createDefault(System.getenv("CAFEBOT_TOKEN"))
.createDefault(EnvironmentVariable.CAFEBOT_TOKEN.getSystemVariable())
.setActivity(Activity.playing("The barista is starting..."))
.setStatus(OnlineStatus.IDLE)
.enableIntents(
Expand Down Expand Up @@ -275,13 +276,11 @@ private void setupCommands() {
new UpdateCommand(this),
new DailyCommand(this),
new CustomChannelsCommand(this)

// new EmbedCommand(this)
);

this.JDA.addEventListener(commandHandler);
this.helpHandler = new HelpHandler(commandHandler);
this.twitchHandler = new TwitchHandler(System.getenv("CAFEBOT_TWITCH_ACCESS_TOKEN"), this);
this.twitchHandler = new TwitchHandler(EnvironmentVariable.CAFEBOT_TWITCH_ACCESS_TOKEN.getSystemVariable(), this);

UpdateCheckHelper updateCheckHelper = new UpdateCheckHelper(this);
updateCheckHelper.checkUpdate();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.beanbeanjuice.cafebot.utility;

public enum EnvironmentVariable {

CAFEBOT_TOKEN,
CAFEBOT_GUILD_ID,
CAFEBOT_GUILD_LOG_CHANNEL_ID,
CAFEBOT_GUILD_WEBHOOK_URL,
CAFEBOT_REQUEST_LOCATION,
CAFEBOT_TWITCH_ACCESS_TOKEN,
KAWAII_API_TOKEN,
API_PASSWORD;

public String getSystemVariable() {
return System.getenv(this.name());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class TwitchHandler {

public TwitchHandler(final String token, final CafeBot cafeBot) {
twitchClient = TwitchClientBuilder.builder()
.withEnableHelix(true)
.withDefaultAuthToken(new OAuth2Credential("twitch", token))
.build();

Expand Down

0 comments on commit f03e1ab

Please sign in to comment.