diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..abbc49e --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,31 @@ +name: Deploy to Dokku + +on: + push: + branches: ["master"] + paths-ignore: + - .gitignore + - README.md + - LICENSE + +jobs: + docker: + strategy: + matrix: + arch: ["ubuntu-latest"] + runs-on: ${{ matrix.arch }} + + # Steps to run + steps: + # Checkout the repo + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Deploy to Dokku + - name: Push to dokku + uses: dokku/github-action@master + with: + git_remote_url: "ssh://dokku@10.0.50.232:22/bat" + ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index aed68c7..2c8ff19 100644 --- a/pom.xml +++ b/pom.xml @@ -20,14 +20,57 @@ + ${project.artifactId} + - org.springframework.boot - spring-boot-maven-plugin + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + ${java.version} + ${java.version} + + + + false + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.3 + + false + + + + package + + shade + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + cc.fascinated.bat.BatApplication + + + + diff --git a/src/main/java/cc/fascinated/bat/common/NumberUtils.java b/src/main/java/cc/fascinated/bat/common/NumberUtils.java index 075483d..426e1fa 100644 --- a/src/main/java/cc/fascinated/bat/common/NumberUtils.java +++ b/src/main/java/cc/fascinated/bat/common/NumberUtils.java @@ -1,16 +1,24 @@ package cc.fascinated.bat.common; +import java.text.DecimalFormat; +import java.text.NumberFormat; + /** * @author Fascinated (fascinated7) */ public class NumberUtils { /** * Formats a number with commas. + *

+ * Example: 1000 -> 1,000 | Example: 1000.5 -> 1,000.5 + *

* * @param number the number to format * @return the formatted number */ public static String formatNumberCommas(double number) { - return String.format("%,.0f", number); + NumberFormat format = NumberFormat.getNumberInstance(); + format.setGroupingUsed(true); + return format.format(number); } } diff --git a/src/main/java/cc/fascinated/bat/service/CommandService.java b/src/main/java/cc/fascinated/bat/service/CommandService.java index 3bff266..6e69402 100644 --- a/src/main/java/cc/fascinated/bat/service/CommandService.java +++ b/src/main/java/cc/fascinated/bat/service/CommandService.java @@ -98,13 +98,7 @@ public class CommandService extends ListenerAdapter { }); // Register all commands - for (BatCommand command : commands.values()) { - if (command.getCommandData() == null) { - continue; - } - - jda.upsertCommand(command.getCommandData()).complete(); // Register the command on Discord - } + jda.updateCommands().addCommands(commands.values().stream().map(BatCommand::getCommandData).toList()).complete(); log.info("Registered all slash commands in {}ms", System.currentTimeMillis() - before); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9dcfa00..4235a83 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -10,5 +10,5 @@ spring: # MongoDB Configuration mongodb: uri: "mongodb://bat:p4$$w0rd@localhost:27017" - database: "bonfire" + database: "bat" auto-index-creation: true # Automatically create collection indexes diff --git a/src/test/java/cc/fascinated/bat/BatApplicationTests.java b/src/test/java/cc/fascinated/bat/BatApplicationTests.java deleted file mode 100644 index dc2257f..0000000 --- a/src/test/java/cc/fascinated/bat/BatApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package cc.fascinated.bat; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class BatApplicationTests { - - @Test - void contextLoads() { - } - -}