Update to use environment variables

This commit is contained in:
illegitimate-egg 2025-08-08 15:54:04 +01:00
parent 81acf75760
commit efdd502b52
5 changed files with 17 additions and 8 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
token.txt
.env
app.jar
duke-bot*

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# Duke Bot
The bot for the Duke Syndicate discord.
## Example docker compose
```yaml
services:
bot:
build: .
environment:
- BOT_TOKEN=token_goes_here
```

View File

@ -4,12 +4,9 @@ import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.requests.GatewayIntent;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
String token = new String(Main.class.getResourceAsStream("/token.txt").readAllBytes(), StandardCharsets.UTF_8);
public static void main(String[] args) {
String token = System.getenv("BOT_TOKEN");
JDABuilder builder = JDABuilder.createDefault(token)
.addEventListeners(new ReadyListener(), new MessageListener());

View File

@ -3,12 +3,13 @@ package hard.rock;
import net.dv8tion.jda.api.events.GenericEvent;
import net.dv8tion.jda.api.events.session.ReadyEvent;
import net.dv8tion.jda.api.hooks.EventListener;
import org.jetbrains.annotations.NotNull;
public class ReadyListener implements EventListener {
@Override
public void onEvent(GenericEvent event) {
public void onEvent(@NotNull GenericEvent event) {
if (event instanceof ReadyEvent) {
System.out.println("Duke is rizzing");
System.out.println("Duke is omniscient");
}
}
}