From 2dfc2d536638f3f25c346cb4b6e9a54118f1a82b Mon Sep 17 00:00:00 2001 From: lundy Date: Thu, 27 Jul 2023 05:11:16 +0200 Subject: [PATCH] Remove brigadier and replaced it with JDA's stuff (#135) * Ignore eclipse files * update gitignore * switch to gradle * Add Brigadier command parser * Push progress, not finished yet. * gitignore should not ignore itself * Remove remnants from roll * Push more progress * Update README.md For changes to gradle * Update README.md Don't bug the guy, he doesn't work on this anymore. * Push more progress * It compiles * Delete maven.yml * Create dependabot.yml * Create codeql.yml * Fix gradle jar not being included in the repository * Update README.md Correct build output location * Update README.md * Delete pr.yml * Bump ch.qos.logback:logback-core from 1.2.3 to 1.4.7 Bumps [ch.qos.logback:logback-core](https://github.com/qos-ch/logback) from 1.2.3 to 1.4.7. - [Commits](https://github.com/qos-ch/logback/compare/v_1.2.3...v_1.4.7) --- updated-dependencies: - dependency-name: ch.qos.logback:logback-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Bump mysql:mysql-connector-java from 8.0.28 to 8.0.33 Bumps mysql:mysql-connector-java from 8.0.28 to 8.0.33. --- updated-dependencies: - dependency-name: mysql:mysql-connector-java dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Bump org.jsoup:jsoup from 1.10.3 to 1.16.1 Bumps [org.jsoup:jsoup](https://github.com/jhy/jsoup) from 1.10.3 to 1.16.1. - [Release notes](https://github.com/jhy/jsoup/releases) - [Changelog](https://github.com/jhy/jsoup/blob/master/CHANGES) - [Commits](https://github.com/jhy/jsoup/compare/jsoup-1.10.3...jsoup-1.16.1) --- updated-dependencies: - dependency-name: org.jsoup:jsoup dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Bump com.zaxxer:HikariCP from 2.6.0 to 5.0.1 Bumps [com.zaxxer:HikariCP](https://github.com/brettwooldridge/HikariCP) from 2.6.0 to 5.0.1. - [Changelog](https://github.com/brettwooldridge/HikariCP/blob/dev/CHANGES) - [Commits](https://github.com/brettwooldridge/HikariCP/compare/HikariCP-2.6.0...HikariCP-5.0.1) --- updated-dependencies: - dependency-name: com.zaxxer:HikariCP dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Bump com.google.guava:guava from 30.1.1-jre to 31.1-jre Bumps [com.google.guava:guava](https://github.com/google/guava) from 30.1.1-jre to 31.1-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production ... Signed-off-by: dependabot[bot] * Fix UnsupportedOperationException * The console can now execute commands * Update dependabot.yml * Bump com.google.code.gson:gson from 2.8.9 to 2.10.1 Bumps [com.google.code.gson:gson](https://github.com/google/gson) from 2.8.9 to 2.10.1. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.8.9...gson-parent-2.10.1) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Bump org.yaml:snakeyaml from 1.29 to 2.0 Bumps [org.yaml:snakeyaml](https://bitbucket.org/snakeyaml/snakeyaml) from 1.29 to 2.0. - [Commits](https://bitbucket.org/snakeyaml/snakeyaml/branches/compare/snakeyaml-2.0..snakeyaml-1.29) --- updated-dependencies: - dependency-name: org.yaml:snakeyaml dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Bump io.sentry:sentry-logback from 1.7.3 to 6.19.1 Bumps [io.sentry:sentry-logback](https://github.com/getsentry/sentry-java) from 1.7.3 to 6.19.1. - [Release notes](https://github.com/getsentry/sentry-java/releases) - [Changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-java/compare/v1.7.3...6.19.1) --- updated-dependencies: - dependency-name: io.sentry:sentry-logback dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * update loggers * Bump org.codehaus.groovy:groovy-jsr223 from 3.0.8 to 3.0.17 Bumps [org.codehaus.groovy:groovy-jsr223](https://github.com/apache/groovy) from 3.0.8 to 3.0.17. - [Commits](https://github.com/apache/groovy/commits) --- updated-dependencies: - dependency-name: org.codehaus.groovy:groovy-jsr223 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Admin commands can now be executed by owners * Update LICENSE * rm outdated comment * I thought I deleted this shit * Fix threading issues when retrieving discord users for suggestions * Fix infinite loop when executing an invalid command. * One command dispatcher now * Fix AnyStringSuggestion * GUILD_MEMBERS intent for suggestions * Push the rest * rm debug code * make ping response empher * State that riitag temporarily not working due to upstream issue * more cleanup * register flag command * Fix UnsupportedOperationException * Fix flag suggestions * Add NON_COUNTRIES and COUNTRIES as valid FlagArgumentTypes * CodeType suggestion no longer case sensitive * New easy deferring system * Fix isDiscordContext returning false if the context was an InteractionHook * Migrate Error command to new context deferral system * Readability * grammar * Fix commands with optional arguments not being able to be executed with no arguments in discord. * oops * Fix LiteralArgument suggestions fucking up suggestions * ExciteSuggestionsBuilder -> RiiSuggestionsBuilder * push * Flag suggestions now show the flag image * cleanup * Fix flag names with spaces being unable to be parsed * cleanup * Remove MAC OS Finder remnants * Update .gitignore ignore MAC OS Finder file remnants * Move brigadier stuff to its own library * Update BDE to 0.3.0.0 * Update BDE to 0.3.1.1 * Bump io.sentry:sentry-logback from 6.19.1 to 6.20.0 Bumps [io.sentry:sentry-logback](https://github.com/getsentry/sentry-java) from 6.19.1 to 6.20.0. - [Release notes](https://github.com/getsentry/sentry-java/releases) - [Changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-java/compare/6.19.1...6.20.0) --- updated-dependencies: - dependency-name: io.sentry:sentry-logback dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * getAuthor() -> getUser() * Update BDE to Version 0.4.0.0 * Add command descriptions and requirements * Add all command requirements * remove duplicate checks * Update BDE to 0.4.1.0 * Bump com.google.guava:guava from 31.1-jre to 32.0.0-jre Bumps [com.google.guava:guava](https://github.com/google/guava) from 31.1-jre to 32.0.0-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production ... Signed-off-by: dependabot[bot] * Temporary fix for /riitag * Fix issues with /flag and /code commands * rm unused annotation * Update BDE to 0.5.0.0 * Fix bot presence * Update BDE to 0.5.0.1 * Bump io.sentry:sentry-logback from 6.20.0 to 6.21.0 Bumps [io.sentry:sentry-logback](https://github.com/getsentry/sentry-java) from 6.20.0 to 6.21.0. - [Release notes](https://github.com/getsentry/sentry-java/releases) - [Changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-java/compare/6.20.0...6.21.0) --- updated-dependencies: - dependency-name: io.sentry:sentry-logback dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Add missing command descriptions * oops * Update BDE to 0.5.0.2 * Bump com.datadoghq:java-dogstatsd-client from 2.8 to 4.2.0 Bumps [com.datadoghq:java-dogstatsd-client](https://github.com/DataDog/java-dogstatsd-client) from 2.8 to 4.2.0. - [Release notes](https://github.com/DataDog/java-dogstatsd-client/releases) - [Changelog](https://github.com/DataDog/java-dogstatsd-client/blob/master/CHANGELOG.md) - [Commits](https://github.com/DataDog/java-dogstatsd-client/compare/v2.8...v4.2.0) --- updated-dependencies: - dependency-name: com.datadoghq:java-dogstatsd-client dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Update code for DataDogBuilder * Remove unused command * Removed brigadier and replaced it with JDA's stuff * Minor changes * Change Members to Users to allow command usage through dms --------- Signed-off-by: dependabot[bot] Co-authored-by: Gamebuster19901 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/dependabot.yml | 7 + .github/workflows/codeql.yml | 81 +++++ .github/workflows/maven.yml | 30 -- .github/workflows/pr.yml | 25 -- .gitignore | 30 +- LICENSE | 2 +- README.md | 6 +- build.gradle | 84 +++++ gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 61608 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 244 ++++++++++++++ gradlew.bat | 92 ++++++ pom.xml | 251 --------------- settings.gradle | 5 + src/.DS_Store | Bin 6148 -> 0 bytes src/main/.DS_Store | Bin 6148 -> 0 bytes src/main/java/xyz/rc24/bot/Bot.java | 237 ++++---------- src/main/java/xyz/rc24/bot/Config.java | 6 +- src/main/java/xyz/rc24/bot/Const.java | 53 ---- .../java/xyz/rc24/bot/RiiConnect24Bot.java | 60 ++-- .../java/xyz/rc24/bot/commands/Command.java | 9 + .../bot/commands/CommandAutoCompletion.java | 40 +++ .../xyz/rc24/bot/commands/CommandManager.java | 60 ++++ .../xyz/rc24/bot/commands/botadm/Bash.java | 101 ------ .../rc24/bot/commands/botadm/BashCommand.java | 101 ++++++ .../xyz/rc24/bot/commands/botadm/Eval.java | 117 ------- .../{Shutdown.java => ShutdownCommand.java} | 41 +-- .../bot/commands/general/BirthdayCmd.java | 90 ------ .../bot/commands/general/BirthdayCommand.java | 102 ++++++ .../rc24/bot/commands/general/CountCmd.java | 95 ------ .../bot/commands/general/CountCommand.java | 96 ++++++ .../rc24/bot/commands/general/FlagCmd.java | 75 ----- .../bot/commands/general/FlagCommand.java | 68 ++++ .../{InviteCmd.java => InviteCommand.java} | 31 +- .../rc24/bot/commands/general/PingCmd.java | 66 ---- .../rc24/bot/commands/general/ReviveCmd.java | 77 ----- .../rc24/bot/commands/general/RiiTagCmd.java | 132 -------- .../bot/commands/general/RiiTagCommand.java | 93 ++++++ .../{RuleCmd.java => RuleCommand.java} | 58 ++-- .../bot/commands/general/SetBirthdayCmd.java | 93 ------ .../bot/commands/tools/DefaultAddCmd.java | 68 ---- .../bot/commands/tools/DefaultAddCommand.java | 62 ++++ .../rc24/bot/commands/tools/PrefixCmd.java | 90 ------ .../{StatsCmd.java => StatsCommand.java} | 91 +++--- .../xyz/rc24/bot/commands/wii/AddCmd.java | 121 ------- .../xyz/rc24/bot/commands/wii/AddCommand.java | 87 +++++ .../xyz/rc24/bot/commands/wii/BlocksCmd.java | 78 ----- .../wii/{DNS.java => BlocksCommand.java} | 48 ++- .../xyz/rc24/bot/commands/wii/CodeCmd.java | 220 ------------- .../rc24/bot/commands/wii/CodeCommand.java | 192 +++++++++++ .../wii/{WiiWare.java => DNSCommand.java} | 39 ++- ...rrorInfoCmd.java => ErrorInfoCommand.java} | 300 +++++++++--------- .../{Categories.java => wii/WadsCommand.java} | 30 +- .../wii/{WadsCmd.java => WiiWareCommand.java} | 33 +- src/main/java/xyz/rc24/bot/core/BotCore.java | 3 +- .../xyz/rc24/bot/core/entities/CodeType.java | 10 +- .../java/xyz/rc24/bot/core/entities/Flag.java | 45 +-- .../bot/core/entities/impl/BotCoreImpl.java | 7 +- .../core/entities/impl/GuildSettingsImpl.java | 4 +- .../rc24/bot/database/CodeDataManager.java | 4 +- .../java/xyz/rc24/bot/database/Database.java | 3 +- .../database/GuildSettingsDataManager.java | 8 +- .../bot/listeners/DataDogStatsListener.java | 20 +- ...cksSakeListener.java => RaidListener.java} | 12 +- .../rc24/bot/managers/BirthdayManager.java | 8 +- .../xyz/rc24/bot/managers/PollManager.java | 51 ++- .../java/xyz/rc24/bot/utils/FinderUtil.java | 113 ------- .../java/xyz/rc24/bot/utils/FormatUtil.java | 62 +--- .../java/xyz/rc24/bot/utils/SearcherUtil.java | 57 ---- src/main/resources/birthdays.sql | 7 +- src/main/resources/codes.sql | 3 +- src/main/resources/settings.sql | 7 +- 72 files changed, 1953 insertions(+), 2694 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/codeql.yml delete mode 100644 .github/workflows/maven.yml delete mode 100644 .github/workflows/pr.yml create mode 100644 build.gradle create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat delete mode 100644 pom.xml create mode 100644 settings.gradle delete mode 100644 src/.DS_Store delete mode 100644 src/main/.DS_Store delete mode 100644 src/main/java/xyz/rc24/bot/Const.java create mode 100644 src/main/java/xyz/rc24/bot/commands/Command.java create mode 100644 src/main/java/xyz/rc24/bot/commands/CommandAutoCompletion.java create mode 100644 src/main/java/xyz/rc24/bot/commands/CommandManager.java delete mode 100644 src/main/java/xyz/rc24/bot/commands/botadm/Bash.java create mode 100644 src/main/java/xyz/rc24/bot/commands/botadm/BashCommand.java delete mode 100644 src/main/java/xyz/rc24/bot/commands/botadm/Eval.java rename src/main/java/xyz/rc24/bot/commands/botadm/{Shutdown.java => ShutdownCommand.java} (61%) delete mode 100644 src/main/java/xyz/rc24/bot/commands/general/BirthdayCmd.java create mode 100644 src/main/java/xyz/rc24/bot/commands/general/BirthdayCommand.java delete mode 100644 src/main/java/xyz/rc24/bot/commands/general/CountCmd.java create mode 100644 src/main/java/xyz/rc24/bot/commands/general/CountCommand.java delete mode 100644 src/main/java/xyz/rc24/bot/commands/general/FlagCmd.java create mode 100644 src/main/java/xyz/rc24/bot/commands/general/FlagCommand.java rename src/main/java/xyz/rc24/bot/commands/general/{InviteCmd.java => InviteCommand.java} (65%) delete mode 100644 src/main/java/xyz/rc24/bot/commands/general/PingCmd.java delete mode 100644 src/main/java/xyz/rc24/bot/commands/general/ReviveCmd.java delete mode 100644 src/main/java/xyz/rc24/bot/commands/general/RiiTagCmd.java create mode 100644 src/main/java/xyz/rc24/bot/commands/general/RiiTagCommand.java rename src/main/java/xyz/rc24/bot/commands/general/{RuleCmd.java => RuleCommand.java} (81%) delete mode 100644 src/main/java/xyz/rc24/bot/commands/general/SetBirthdayCmd.java delete mode 100644 src/main/java/xyz/rc24/bot/commands/tools/DefaultAddCmd.java create mode 100644 src/main/java/xyz/rc24/bot/commands/tools/DefaultAddCommand.java delete mode 100644 src/main/java/xyz/rc24/bot/commands/tools/PrefixCmd.java rename src/main/java/xyz/rc24/bot/commands/tools/{StatsCmd.java => StatsCommand.java} (61%) delete mode 100644 src/main/java/xyz/rc24/bot/commands/wii/AddCmd.java create mode 100644 src/main/java/xyz/rc24/bot/commands/wii/AddCommand.java delete mode 100644 src/main/java/xyz/rc24/bot/commands/wii/BlocksCmd.java rename src/main/java/xyz/rc24/bot/commands/wii/{DNS.java => BlocksCommand.java} (55%) delete mode 100644 src/main/java/xyz/rc24/bot/commands/wii/CodeCmd.java create mode 100644 src/main/java/xyz/rc24/bot/commands/wii/CodeCommand.java rename src/main/java/xyz/rc24/bot/commands/wii/{WiiWare.java => DNSCommand.java} (59%) rename src/main/java/xyz/rc24/bot/commands/wii/{ErrorInfoCmd.java => ErrorInfoCommand.java} (59%) rename src/main/java/xyz/rc24/bot/commands/{Categories.java => wii/WadsCommand.java} (62%) rename src/main/java/xyz/rc24/bot/commands/wii/{WadsCmd.java => WiiWareCommand.java} (65%) rename src/main/java/xyz/rc24/bot/listeners/{StopRaidingUsForFucksSakeListener.java => RaidListener.java} (87%) delete mode 100644 src/main/java/xyz/rc24/bot/utils/FinderUtil.java delete mode 100644 src/main/java/xyz/rc24/bot/utils/SearcherUtil.java diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..3f606d8d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + - package-ecosystem: "gradle" + directory: "/" + schedule: + interval: "daily" + open-pull-requests-limit: 99 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..62966461 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,81 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + schedule: + - cron: '21 19 * * 6' + +jobs: + analyze: + name: Analyze + if: ${{github.event.pull_request.head.repo.full_name}} != {{$github.repository}} + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Set up JDK 19 + uses: actions/setup-java@v1 + with: + java-version: 19 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index 0de97b95..00000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Java CI - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - if: "!contains(github.event.commits[0].message, '[ci-skip]')" - - strategy: - matrix: - java: [16] - fail-fast: true - - steps: - - uses: actions/checkout@v2 - - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 - with: - java-version: ${{ matrix.java }} - distribution: 'adopt' - - - name: Build with Maven - run: mvn clean package - - - uses: actions/upload-artifact@master - with: - name: RC24-Bot - path: target/RC24-Bot.jar \ No newline at end of file diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index b27a45de..00000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Pull Request - -on: [pull_request] - -jobs: - build: - runs-on: ubuntu-latest - if: "!contains(github.event.commits[0].message, '[ci-skip]')" - - strategy: - matrix: - java: [16] - fail-fast: true - - steps: - - uses: actions/checkout@v2 - - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v1 - with: - java-version: ${{ matrix.java }} - distribution: 'adopt' - - - name: Build with Maven - run: mvn clean package diff --git a/.gitignore b/.gitignore index 660272b5..00ef7a73 100644 --- a/.gitignore +++ b/.gitignore @@ -7,11 +7,29 @@ # BlueJ files *.ctxt +# eclipse +bin +*.launch +.metadata +.classpath +.project +/.settings + +# idea +out +*.ipr +*.iws +*.iml +.idea + +# gradle +build +.gradle + # Mobile Tools for Java (J2ME) .mtj.tmp/ # Package Files -*.jar *.war *.ear *.zip @@ -29,3 +47,13 @@ target/* .idea/* *.iml dependency-reduced-pom.xml +polls_049.yml +polls_110.yml +.DS_Store + +# eclipse +bin +.settings +.metadata +.classpath +.project diff --git a/LICENSE b/LICENSE index 177861dd..f3d20229 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017-2020 RiiConnect24 and its contributors +Copyright (c) 2017-2023 RiiConnect24 and its contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 2faa1658..9af05c49 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,12 @@ I'm glad you asked. ##### A note: We no longer use [YAML](http://yaml.org/) except for the config (which was just a [Ruby](https://www.ruby-lang.org/) class before), as [Java](https://www.java.com/) really doesn't like [YAML](http://yaml.org/). Check out the following steps: -1. You'll need to have MySQL and Maven installed. +1. You'll need to have MySQL installed. 2. We'll create the Redis structures as we go, so no need to set anything up. 3. `git clone` the repo somewhere and `cd` into it. -4. It's time to start building... Run `mvn package`! And... tada! That's it. You can find JAR(s) created in `target`. Easy! +4. It's time to start building... Run `./gradlew shadowJar`! And... tada! That's it. You can find JAR(s) created in `/build/libs`. Easy! 5. For running, make sure you have MySQL installed on whatever machine. -If you need support for the bot, head on over to [the bot's official support server](https://discord.gg/PVsh4jP) or DM `Artuto#0424 | 264499432538505217` in Discord. +If you need support for the bot, head on over to [the bot's official support server](https://discord.gg/PVsh4jP). For more infos about JDA, [click here](https://github.com/DV8FromTheWorld/JDA). diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..ffcb9f72 --- /dev/null +++ b/build.gradle @@ -0,0 +1,84 @@ +/* + * This file was generated by the Gradle 'init' task. + */ + +plugins { + id 'java' + id 'maven-publish' + id 'eclipse' + id 'com.github.johnrengelman.shadow' version "8.1.1" +} + +repositories { + mavenCentral() + maven { + url = uri('https://m2.dv8tion.net/releases/') + } + + maven { + url = uri('https://repo.maven.apache.org/maven2/') + } + + maven { + url "https://repo.spongepowered.org/maven/" + } + + maven { + url = uri('https://repo.aikar.co/content/groups/aikar/') + } + +} + +dependencies { + shadow 'net.dv8tion:JDA:5.0.0-beta.12' + shadow 'io.sentry:sentry-logback:6.21.0' + shadow 'org.codehaus.groovy:groovy-jsr223:3.0.17' + shadow 'org.jsoup:jsoup:1.16.1' + shadow 'mysql:mysql-connector-java:8.0.33' + shadow 'co.aikar:idb-core:1.0.0-SNAPSHOT' + shadow 'com.zaxxer:HikariCP:5.0.1' + shadow 'org.yaml:snakeyaml:2.0' + shadow 'com.google.code.gson:gson:2.10.1' + shadow 'com.google.guava:guava:32.0.0-jre' + shadow 'com.datadoghq:java-dogstatsd-client:4.2.0' + shadow 'org.json:json:20230227' + shadow group: 'org.apache.commons', name: 'commons-text', version: '1.10.0' +} + +shadowJar { + mergeServiceFiles() + configurations = [project.configurations.shadow] + exclude 'META-INF/LICENSE' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/LICENSsE.txt' + exclude 'META-INF/NOTICE' + exclude 'META-INF/NOTICE.txt' + exclude 'META-INF/DEPENDENCIES' + exclude 'LICENSE.txt' +} + +group = 'xyz.rc24.bot' +version = '5.3.4' +description = 'RC24-Bot' +java.sourceCompatibility = JavaVersion.VERSION_19 +compileJava.options.encoding = "UTF-8" +compileTestJava.options.encoding = "UTF-8" + +jar { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + manifest { + attributes( + 'Class-Path': configurations.runtimeClasspath.collect { it.getName() }.join(' '), + 'MixinConfigs': 'mixins.json', + 'Main-Class': 'xyz.rc24.bot.RiiConnect24Bot', + 'Specification-Version': 8.0, + 'Multi-Release': 'true' + ) + } + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } { + exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA' + } +} + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..ccebba7710deaf9f98673a68957ea02138b60d0a GIT binary patch literal 61608 zcmb5VV{~QRw)Y#`wrv{~+qP{x72B%VwzFc}c2cp;N~)5ZbDrJayPv(!dGEd-##*zr z)#n-$y^sH|_dchh3@8{H5D*j;5D<{i*8l5IFJ|DjL!e)upfGNX(kojugZ3I`oH1PvW`wFW_ske0j@lB9bX zO;2)`y+|!@X(fZ1<2n!Qx*)_^Ai@Cv-dF&(vnudG?0CsddG_&Wtae(n|K59ew)6St z#dj7_(Cfwzh$H$5M!$U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zD8Ro0LI*W#+9?^xlOS^c>Z^^n^0I|FH^@^`ZR`{H=$ zjO0_$cnpBM7Zcm?H_RXIu-Lu~qweDSV|tEZBZh!e6hQy->}e;d#osZ1hQj{HhHkC0 zJ|F-HKmeTGgDe979ogBz24;@<|I7;TU!IXb@oWMsMECIETmQy`zPtM`|NP}PjzR_u zKMG1Z{%1kWeMfEf(10U#w!clmQ2)JC8zm(Fv!H4dUHQHCFLikID?hrd{0>kCQt?kP zdqn2ZG0}ytcQJ7t_B3s0ZvH3PYjkjQ`Q%;jV@?MK-+z3etBCGGo4f4`y^|AdCs!DH zThTQ;cL5dM{|tB_1y6K3bVa^hx_<9J(}5`2SDz1^0bT!Vm*JV;9~t&{IC{$DUAVV* z{|E=#yN{wNdTY@$6z{_KNA3&%w|vFu1n9XRcM0Ak>`UW!lQ`ah3D4r%}Z literal 0 HcmV?d00001 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..37aef8d3 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 00000000..79a61d42 --- /dev/null +++ b/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# Copyright Š 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions ÂĢ$varÂģ, ÂĢ${var}Âģ, ÂĢ${var:-default}Âģ, ÂĢ${var+SET}Âģ, +# ÂĢ${var#prefix}Âģ, ÂĢ${var%suffix}Âģ, and ÂĢ$( cmd )Âģ; +# * compound commands having a testable exit status, especially ÂĢcaseÂģ; +# * various built-in commands including ÂĢcommandÂģ, ÂĢsetÂģ, and ÂĢulimitÂģ. +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..6689b85b --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 603f54a9..00000000 --- a/pom.xml +++ /dev/null @@ -1,251 +0,0 @@ - - - - - 4.0.0 - - xyz.rc24.bot - RC24-Bot - 5.3.4 - - - UTF-8 - - - - - m2-dv8tion - m2-dv8tion - https://m2.dv8tion.net/releases/ - - - - central - bintray - https://jcenter.bintray.com - - - - aikar - https://repo.aikar.co/content/groups/aikar/ - - - - jitpack.io - https://jitpack.io - - - - - - - net.dv8tion - JDA - LATEST - - - - - club.minced - opus-java - - - - - - com.jagrosh - - jda-utilities-command - 2.0 - compile - - - - - com.github.RiiConnect24-Bot.JDA-Utilities - jda-utilities-menu - c3e09d51aa - - - - com.github.RiiConnect24-Bot.JDA-Utilities - jda-utilities-commons - - - - - - - ch.qos.logback - logback-core - 1.2.3 - - - - io.sentry - sentry-logback - 1.7.3 - - - - - org.codehaus.groovy - groovy-jsr223 - 3.0.8 - - - - org.jsoup - jsoup - 1.10.3 - - - - - mysql - mysql-connector-java - 8.0.28 - - - - co.aikar - idb-core - 1.0.0-SNAPSHOT - - - - com.zaxxer - HikariCP - 2.6.0 - - - - - org.yaml - snakeyaml - 1.29 - - - - com.google.code.gson - gson - 2.8.9 - - - - com.google.guava - guava - 30.1.1-jre - - - - com.datadoghq - java-dogstatsd-client - 2.8 - - - - - RC24-Bot - clean package - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - - 11 - 11 - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.1.0 - - - package - - shade - - - - RC24-Bot - - - - xyz.rc24.bot.RiiConnect24Bot - - - - - - - - - net.md-5 - scriptus - 0.1 - - - - initialize - - - describe - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.5 - - - - - - ${project.version}:${describe} - - - - - - - - - src/main/resources - true - - - - diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..fef5bca7 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,5 @@ +/* + * This file was generated by the Gradle 'init' task. + */ + +rootProject.name = 'RC24-Bot' \ No newline at end of file diff --git a/src/.DS_Store b/src/.DS_Store deleted file mode 100644 index bd9364e496ae5811c62a130a77379c3a256eeb55..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5Z<-XrW7FuMUM+!3#L{C@e*Qv0V8@)sR=0>OtYm)&7l->)fe(jd>&_Z zH)1ho5jz9B-~8@oKgj+t#<)L^`;0k^F&i2pN2Ni~-5A<1$%q`sh{}8#r7{Bh-NgPn z;I~_B!a|m??ECje(=^Eo*ZtrdEo*bDZMW^NeIGo@GAP1gp8MhK7Og8O)2PWZPg3Z=ifF=OvhBsmvb1SLfGxgv0G4T87YrqQ`*Oft?dUyp%b=fE7Kc%+?Mq)@HPwJB&fE`i1-^ejeXT zQgLj8ClU7^y!?{)ry;+Tyo52vd*i6Xn8O&eKoM&;G)n~is0&gv7DTSTF=iRNV?&mQ zlZ9w9{6z+E?`+sL*fS>Cm;K8}VIo8DzJ;SC&I{Ll=e2rcZM|tVt(JA;Kgfw+1jRV- z1=$sj&ZSJksvm?G@o+M5Hcw<)1aUgdR6-mLA>{fpP9r(#$#ELxD%aNz%eL%+vpt=5 zx^2;QJF~W!9__nranL=S&1`FHcklRY@R&TM@-v!A7jOz**4 zWmXx4!~iis46FE3;x+C^0|`{FDJa9|S0(XRy?$jt*$>`iTApA`0~JErBQu zdIn34-~r(}6;P*g^Tgmf9qhuyc?L_3I-PMfGknL)%*_jhtJ%RWR5;_FMrw%xVql(u zx*j@M|4+Yv|Ia7Uh!`LS{uKkf(f9j3Sdyu&3yZ^AD?o2SQ82F5_?ZG7Rf-`NOYsh< a60i&G0D1;XjbH(xi-4km8e-sA8TbGti%n$! diff --git a/src/main/java/xyz/rc24/bot/Bot.java b/src/main/java/xyz/rc24/bot/Bot.java index 9040f231..7006c522 100644 --- a/src/main/java/xyz/rc24/bot/Bot.java +++ b/src/main/java/xyz/rc24/bot/Bot.java @@ -24,16 +24,12 @@ package xyz.rc24.bot; -import ch.qos.logback.classic.Logger; import co.aikar.idb.DB; import co.aikar.idb.DatabaseOptions; import co.aikar.idb.PooledDatabaseOptions; -import com.jagrosh.jdautilities.command.CommandClientBuilder; -import com.jagrosh.jdautilities.command.SlashCommand; -import com.jagrosh.jdautilities.commons.waiter.EventWaiter; import com.mysql.cj.jdbc.Driver; import com.mysql.cj.jdbc.MysqlDataSource; -import com.timgroup.statsd.NonBlockingStatsDClient; +import com.timgroup.statsd.NonBlockingStatsDClientBuilder; import com.timgroup.statsd.StatsDClient; import io.sentry.Sentry; import net.dv8tion.jda.api.JDA; @@ -41,56 +37,34 @@ import net.dv8tion.jda.api.OnlineStatus; import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.events.ReadyEvent; -import net.dv8tion.jda.api.events.ShutdownEvent; +import net.dv8tion.jda.api.events.session.ReadyEvent; +import net.dv8tion.jda.api.events.session.ShutdownEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import okhttp3.OkHttpClient; -import org.reflections.Reflections; -import xyz.rc24.bot.commands.botadm.Bash; -import xyz.rc24.bot.commands.botadm.Eval; -import xyz.rc24.bot.commands.botadm.Shutdown; -import xyz.rc24.bot.commands.general.BirthdayCmd; -import xyz.rc24.bot.commands.general.CountCmd; -import xyz.rc24.bot.commands.general.FlagCmd; -import xyz.rc24.bot.commands.general.InviteCmd; -import xyz.rc24.bot.commands.general.PingCmd; -import xyz.rc24.bot.commands.general.RiiTagCmd; -import xyz.rc24.bot.commands.general.RuleCmd; -import xyz.rc24.bot.commands.general.SetBirthdayCmd; -import xyz.rc24.bot.commands.tools.DefaultAddCmd; -import xyz.rc24.bot.commands.tools.PrefixCmd; -import xyz.rc24.bot.commands.tools.StatsCmd; -import xyz.rc24.bot.commands.wii.AddCmd; -import xyz.rc24.bot.commands.wii.BlocksCmd; -import xyz.rc24.bot.commands.wii.CodeCmd; -import xyz.rc24.bot.commands.wii.DNS; -import xyz.rc24.bot.commands.wii.ErrorInfoCmd; -import xyz.rc24.bot.commands.wii.WadsCmd; -import xyz.rc24.bot.commands.wii.WiiWare; +import org.slf4j.Logger; +import xyz.rc24.bot.commands.CommandAutoCompletion; +import xyz.rc24.bot.commands.CommandManager; import xyz.rc24.bot.core.BotCore; +import xyz.rc24.bot.core.entities.GuildSettings; import xyz.rc24.bot.core.entities.impl.BotCoreImpl; import xyz.rc24.bot.database.BirthdayDataManager; import xyz.rc24.bot.database.CodeDataManager; import xyz.rc24.bot.database.Database; import xyz.rc24.bot.database.GuildSettingsDataManager; import xyz.rc24.bot.listeners.DataDogStatsListener; +import xyz.rc24.bot.listeners.RaidListener; import xyz.rc24.bot.managers.BirthdayManager; -import javax.security.auth.login.LoginException; import java.time.Duration; import java.time.OffsetDateTime; import java.time.ZonedDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.Set; /** * Add all commands, and start all listeners. @@ -98,15 +72,13 @@ * @author Spotlight and Artuto */ -@SuppressWarnings({"unused", "WeakerAccess"}) -public class Bot extends ListenerAdapter -{ +public class Bot extends ListenerAdapter { + public BotCore core; public Config config; - public EventWaiter waiter; public JDA jda; - // Database & Data managers + // Database & Data Managers private Database db; private BirthdayDataManager birthdayDataManager; private CodeDataManager codeDataManager; @@ -119,16 +91,16 @@ public class Bot extends ListenerAdapter private final OkHttpClient httpClient = new OkHttpClient(); private final ScheduledExecutorService botScheduler = Executors.newScheduledThreadPool(5); private final ScheduledExecutorService birthdaysScheduler = Executors.newSingleThreadScheduledExecutor(); + private final ConcurrentLinkedDeque consoleCommandsAwaitingProcessing = new ConcurrentLinkedDeque<>(); + + private CommandManager commandManager; - void run() throws LoginException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException - { - RiiConnect24Bot.setInstance(this); + JDABuilder initialize() { this.config = new Config(); this.core = new BotCoreImpl(this); - this.waiter = new EventWaiter(); // Start Sentry (if enabled) - if(config.isSentryEnabled() && !(config.getSentryDSN().isEmpty())) + if (config.isSentryEnabled() && !(config.getSentryDSN().isEmpty())) Sentry.init(config.getSentryDSN()); // Start database @@ -140,12 +112,16 @@ void run() throws LoginException, IllegalAccessException, InstantiationException // Start managers this.birthdayManager = new BirthdayManager(getBirthdayDataManager()); + commandManager = new CommandManager(); + DataDogStatsListener dataDogStatsListener = null; - if(config.isDatadogEnabled()) - { - StatsDClient statsd = new NonBlockingStatsDClient(config.getDatadogPrefix(), - config.getDatadogHost(), config.getDatadogPort()); + if (config.isDatadogEnabled()) { + NonBlockingStatsDClientBuilder dataDogBuilder = new NonBlockingStatsDClientBuilder() + .prefix(config.getDatadogPrefix()) + .hostname(config.getDatabaseHost()) + .port(config.getDatadogPort()); + StatsDClient statsd = dataDogBuilder.build(); dataDogStatsListener = new DataDogStatsListener(statsd); } @@ -153,88 +129,43 @@ void run() throws LoginException, IllegalAccessException, InstantiationException List owners = config.getSecondaryOwners(); String[] coOwners = new String[owners.size()]; - for(int i = 0; i < owners.size(); i++) + for (int i = 0; i < owners.size(); i++) coOwners[i] = String.valueOf(owners.get(i)); - List slashCommands = new ArrayList<>(); - - slashCommands.add(new AddCmd(this)); - slashCommands.add(new BirthdayCmd(this)); - slashCommands.add(new BlocksCmd()); - slashCommands.add(new CodeCmd(this)); - slashCommands.add(new CountCmd(this)); - slashCommands.add(new DNS()); - slashCommands.add(new ErrorInfoCmd(this)); - slashCommands.add(new InviteCmd()); - slashCommands.add(new RiiTagCmd(this)); - slashCommands.add(new RuleCmd()); - slashCommands.add(new SetBirthdayCmd(this)); - slashCommands.add(new WadsCmd()); - slashCommands.add(new WiiWare()); - - // Setup Command Client - CommandClientBuilder client = new CommandClientBuilder() - .setActivity(Activity.playing(config.getPlaying())) - .setStatus(config.getStatus()) - .setEmojis(Const.SUCCESS_E, Const.WARN_E, Const.ERROR_E) - .setLinkedCacheSize(40) - .setOwnerId(String.valueOf(config.getPrimaryOwner())) - .setPrefix("@mention") - .setServerInvite("https://discord.gg/5rw6Tur") - .setGuildSettingsManager(getGuildSettingsDataManager()) - .setCoOwnerIds(coOwners) - .setScheduleExecutor(botScheduler) - .addCommands( - // Bot administration - new Bash(), new Eval(this), new Shutdown(), - - // General - new BirthdayCmd(this), new CountCmd(this), new FlagCmd(this), new InviteCmd(), - new PingCmd(), new RiiTagCmd(this), new RuleCmd(), new SetBirthdayCmd(this), - - // Tools - new DefaultAddCmd(this), new PrefixCmd(getGuildSettingsDataManager()), - new StatsCmd(this), - - // Wii-related - new AddCmd(this), new CodeCmd(this), new BlocksCmd(), - new ErrorInfoCmd(this), new DNS(), new WadsCmd(), new WiiWare()) - .addSlashCommands(slashCommands.toArray(new SlashCommand[0])); - - if(!(dataDogStatsListener == null)) - client.setListener(dataDogStatsListener); - // JDA Connection JDABuilder builder = JDABuilder.createLight(config.getToken()) - .setEnabledIntents(Const.INTENTS) + .setEnabledIntents(RiiConnect24Bot.INTENTS) .setStatus(OnlineStatus.DO_NOT_DISTURB) - .setActivity(Activity.playing("Loading...")) - .addEventListeners(this, client.build(), waiter); + .addEventListeners(new RaidListener(config.useRaidProtection())) + .addEventListeners(commandManager) + .addEventListeners(this) + .addEventListeners(new CommandAutoCompletion()) + .setActivity(Activity.listening("Slash commands")); + - if(!(dataDogStatsListener == null)) + if (!(dataDogStatsListener == null)) builder.addEventListeners(dataDogStatsListener); - builder.build(); + return builder; + } + + void run() { + JDABuilder jdaBuilder = initialize(); + this.jda = jdaBuilder.build(); + jda.updateCommands().addCommands(commandManager.getCommandDataList()).queue(); } @Override - public void onReady(ReadyEvent event) - { - this.jda = event.getJDA(); + public void onReady(ReadyEvent event) { logger.info("Done loading!"); - // Check if we need to set a game - if(config.getPlaying().isEmpty()) - event.getJDA().getPresence().setActivity(Activity.playing("Type " + config.getPrefix() + "help")); - ZonedDateTime zonedNow = OffsetDateTime.now().toZonedDateTime(); ZonedDateTime zonedNext; - if(config.areBirthdaysEnabled()) - { + if (config.areBirthdaysEnabled()) { // Every day at 8AM zonedNext = zonedNow.withHour(8).withMinute(0).withSecond(0); - if(zonedNow.compareTo(zonedNext) > 0) + if (zonedNow.compareTo(zonedNext) > 0) zonedNext = zonedNext.plusDays(1); Duration duration = Duration.between(zonedNow, zonedNext); @@ -247,17 +178,14 @@ public void onReady(ReadyEvent event) } @Override - public void onShutdown(ShutdownEvent event) - { + public void onShutdown(ShutdownEvent event) { birthdaysScheduler.shutdown(); DB.close(); } - private Database initDatabase() - { - if(config.getDatabaseUser().isEmpty() || config.getDatabasePassword().isEmpty() || - config.getDatabase().isEmpty() || config.getDatabaseHost().isEmpty()) - { + private Database initDatabase() { + if (config.getDatabaseUser().isEmpty() || config.getDatabasePassword().isEmpty() || + config.getDatabase().isEmpty() || config.getDatabaseHost().isEmpty()) { throw new IllegalStateException("You haven't configured database details in the config file!"); } @@ -267,12 +195,10 @@ private Database initDatabase() .dataSourceClassName(MysqlDataSource.class.getName() /*"com.mysql.cj.jdbc.MysqlDataSource"*/) .build(); - Map props = new HashMap<>() - {{ + Map props = new HashMap<>() {{ put("useSSL", config.useSSL()); put("verifyServerCertificate", config.verifyServerCertificate()); put("autoReconnect", config.autoReconnect()); - //put("serverTimezone", "CST"); // Doesn't really matter put("characterEncoding", "UTF-8"); }}; @@ -286,79 +212,56 @@ private Database initDatabase() return new Database(); } - public BotCore getCore() - { + public BotCore getCore() { return core; } - public Config getConfig() - { + public Config getConfig() { return config; } - public Database getDatabase() - { + public Database getDatabase() { return db; } - public EventWaiter getWaiter() - { - return waiter; - } - - public JDA getJDA() - { + public JDA getJDA() { return jda; } - public ScheduledExecutorService getBotScheduler() - { + public ScheduledExecutorService getBotScheduler() { return botScheduler; } - // Data managers - public BirthdayDataManager getBirthdayDataManager() - { + public BirthdayDataManager getBirthdayDataManager() { return birthdayDataManager; } - public CodeDataManager getCodeDataManager() - { + public CodeDataManager getCodeDataManager() { return codeDataManager; } - public GuildSettingsDataManager getGuildSettingsDataManager() - { + public GuildSettingsDataManager getGuildSettingsDataManager() { return guildSettingsDataManager; } - // Managers - public BirthdayManager getBirthdayManager() - { - return birthdayManager; + public GuildSettings getGuildSettings(long snowflakeID) { + return getGuildSettingsDataManager().getGuildSettings(snowflakeID); } - // Other - public OkHttpClient getHttpClient() - { - return httpClient; + public GuildSettings getGuildSettings(Guild guild) { + return getGuildSettingsDataManager().getSettings(guild); } - public String getPrefix(Guild guild) - { - return getCore().getGuildSettings(guild).getPrefix(); - } - - private static SlashCommand[] getSlashCommands() throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException - { - Reflections reflections = new Reflections("xyz.rc24.bot.commands"); - Set> subTypes = reflections.getSubTypesOf(SlashCommand.class); - List commands = new ArrayList<>(); + public BirthdayManager getBirthdayManager() { + return birthdayManager; + } - for (Class theClass : subTypes) { - commands.add(theClass.getDeclaredConstructor().newInstance()); - } + public OkHttpClient getHttpClient() { + return httpClient; + } - return commands.toArray(new SlashCommand[0]); + public String getPrefix(Guild guild) { + return getCore().getGuildSettings(guild).getPrefix(); } + } diff --git a/src/main/java/xyz/rc24/bot/Config.java b/src/main/java/xyz/rc24/bot/Config.java index 2ed77ee4..52222e7f 100644 --- a/src/main/java/xyz/rc24/bot/Config.java +++ b/src/main/java/xyz/rc24/bot/Config.java @@ -41,8 +41,6 @@ /** * @author Artuto */ - -@SuppressWarnings({"WeakerAccess", "unused"}) public class Config { private final Map config; @@ -195,6 +193,10 @@ boolean autoReconnect() return getBoolean("autoReconnect", database); } + boolean useRaidProtection() { + return getBoolean("raid_prevention", config); + } + // Util methods private boolean getBoolean(String key) { diff --git a/src/main/java/xyz/rc24/bot/Const.java b/src/main/java/xyz/rc24/bot/Const.java deleted file mode 100644 index 46bde492..00000000 --- a/src/main/java/xyz/rc24/bot/Const.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot; - -import net.dv8tion.jda.api.requests.GatewayIntent; - -import java.util.EnumSet; - -import static net.dv8tion.jda.api.requests.GatewayIntent.DIRECT_MESSAGES; -import static net.dv8tion.jda.api.requests.GatewayIntent.DIRECT_MESSAGE_REACTIONS; -import static net.dv8tion.jda.api.requests.GatewayIntent.GUILD_MESSAGES; -import static net.dv8tion.jda.api.requests.GatewayIntent.GUILD_MESSAGE_REACTIONS; - -/** - * Constants for the bot - * - * @author Artuto - */ - -public class Const -{ - public static final String VERSION = Const.class.getPackage().getImplementationVersion() == null ? "DEV" : - Const.class.getPackage().getImplementationVersion(); - public static final String PATCHING_URL = "http://mtw.rc24.xyz/patch"; - public static final String SUCCESS_E = "✅"; - public static final String WARN_E = "⚠"; - public static final String ERROR_E = "❌"; - - public static final EnumSet INTENTS = EnumSet.of(GUILD_MESSAGES, - GUILD_MESSAGE_REACTIONS, DIRECT_MESSAGES, DIRECT_MESSAGE_REACTIONS); -} diff --git a/src/main/java/xyz/rc24/bot/RiiConnect24Bot.java b/src/main/java/xyz/rc24/bot/RiiConnect24Bot.java index 87e21458..9444c68d 100644 --- a/src/main/java/xyz/rc24/bot/RiiConnect24Bot.java +++ b/src/main/java/xyz/rc24/bot/RiiConnect24Bot.java @@ -24,13 +24,13 @@ package xyz.rc24.bot; -import ch.qos.logback.classic.Logger; -import net.dv8tion.jda.api.requests.RestAction; +import net.dv8tion.jda.api.requests.GatewayIntent; +import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.security.auth.login.LoginException; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; +import java.util.EnumSet; + +import static net.dv8tion.jda.api.requests.GatewayIntent.*; /** * Bot entry point. @@ -38,47 +38,37 @@ * @author Artuto */ -public class RiiConnect24Bot -{ - private static Bot instance; +public class RiiConnect24Bot { - private static final Logger logger = (Logger) LoggerFactory.getLogger("RiiConnect24 Bot"); + public static final String VERSION = RiiConnect24Bot.class.getPackage().getImplementationVersion() == null ? "DEV" : RiiConnect24Bot.class.getPackage().getImplementationVersion(); + public static final String PATCHING_URL = "http://mtw.rc24.xyz/patch"; + public static final String SUCCESS_E = "✅"; + public static final String WARN_E = "⚠"; + public static final String ERROR_E = "❌"; + public static final EnumSet INTENTS = EnumSet.of(GUILD_MESSAGES, GUILD_MESSAGE_REACTIONS, DIRECT_MESSAGES, DIRECT_MESSAGE_REACTIONS); - public static void main(String[] args) throws LoginException, IOException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException - { + private static Bot instance; + private static final Logger logger = LoggerFactory.getLogger("RiiConnect24 Bot"); + + public static void main(String[] args) { // Sentry System.setProperty("sentry.stacktrace.app.packages", "xyz.rc24.bot"); - System.setProperty("sentry.release", Const.VERSION); - - // JDA - RestAction.setPassContext(true); // enable context by default - RestAction.setDefaultFailure(Throwable::printStackTrace); - - getLogger().info("Starting RiiConnect24 Bot - {}", Const.VERSION); - - new Bot().run(); + System.setProperty("sentry.release", VERSION); + logger.info("Starting RiiConnect24 Bot - {}", VERSION); + instance = new Bot(); + instance.run(); } - public static Bot getInstance() - { - if(instance == null) - throw new IllegalStateException("The bot is not initialized!"); - + public static Bot getInstance() { + if (instance == null) throw new IllegalStateException("The bot is not initialized!"); return instance; } - public static Logger getLogger() - { + public static Logger getLogger() { return logger; } - public static Logger getLogger(Class clazz) - { - return (Logger) LoggerFactory.getLogger(clazz); - } - - static void setInstance(Bot instance) - { - RiiConnect24Bot.instance = instance; + public static Logger getLogger(Class clazz) { + return LoggerFactory.getLogger(clazz); } } diff --git a/src/main/java/xyz/rc24/bot/commands/Command.java b/src/main/java/xyz/rc24/bot/commands/Command.java new file mode 100644 index 00000000..1ac6388b --- /dev/null +++ b/src/main/java/xyz/rc24/bot/commands/Command.java @@ -0,0 +1,9 @@ +package xyz.rc24.bot.commands; + +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; + +public interface Command { + void onCommand(SlashCommandInteractionEvent event); + SlashCommandData getCommandData(); +} diff --git a/src/main/java/xyz/rc24/bot/commands/CommandAutoCompletion.java b/src/main/java/xyz/rc24/bot/commands/CommandAutoCompletion.java new file mode 100644 index 00000000..61a600d7 --- /dev/null +++ b/src/main/java/xyz/rc24/bot/commands/CommandAutoCompletion.java @@ -0,0 +1,40 @@ +package xyz.rc24.bot.commands; + +import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import net.dv8tion.jda.api.interactions.commands.Command; +import org.jetbrains.annotations.NotNull; +import xyz.rc24.bot.core.entities.CodeType; +import xyz.rc24.bot.core.entities.Flag; + +import java.util.List; +import java.util.stream.Stream; + +public class CommandAutoCompletion extends ListenerAdapter { + + @Override + public void onCommandAutoCompleteInteraction(@NotNull CommandAutoCompleteInteractionEvent event) { + + if (event.getName().equals("flag") && event.getSubcommandName().equals("set")) { + if (event.getFocusedOption().getName().equals("flag")) { + Flag[] flags = Flag.values(); + List choices = Stream.of(flags) + .filter(flag -> flag.getName().startsWith(event.getFocusedOption().getValue())) + .map(flag -> new Command.Choice(flag.getName(), flag.getName())) + .toList(); + event.replyChoices(choices.size() > 25 ? List.of(new Command.Choice("Please be more specific", "no value")) : choices).queue(); + } + } + + if (event.getName().equals("defaultadd")) { + if (event.getFocusedOption().getName().equals("type")) { + CodeType[] codeTypes = CodeType.values(); + List choices = Stream.of(codeTypes) + .map(codeType -> new Command.Choice(codeType.getDisplayName(), codeType.getName())) + .toList(); + event.replyChoices(choices).queue(); + } + } + + } +} diff --git a/src/main/java/xyz/rc24/bot/commands/CommandManager.java b/src/main/java/xyz/rc24/bot/commands/CommandManager.java new file mode 100644 index 00000000..f11d2d6b --- /dev/null +++ b/src/main/java/xyz/rc24/bot/commands/CommandManager.java @@ -0,0 +1,60 @@ +package xyz.rc24.bot.commands; + +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import org.jetbrains.annotations.NotNull; +import xyz.rc24.bot.commands.botadm.BashCommand; +import xyz.rc24.bot.commands.botadm.ShutdownCommand; +import xyz.rc24.bot.commands.general.*; +import xyz.rc24.bot.commands.tools.DefaultAddCommand; +import xyz.rc24.bot.commands.tools.StatsCommand; +import xyz.rc24.bot.commands.wii.*; + +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; + +public class CommandManager extends ListenerAdapter { + + private final HashMap commands = new HashMap<>(); + + public CommandManager() { + registerCommand(new WiiWareCommand()); + registerCommand(new WadsCommand()); + registerCommand(new ErrorInfoCommand()); + registerCommand(new DNSCommand()); + registerCommand(new CodeCommand()); + registerCommand(new BlocksCommand()); + registerCommand(new AddCommand()); + registerCommand(new StatsCommand()); + registerCommand(new DefaultAddCommand()); + registerCommand(new RuleCommand()); + registerCommand(new RiiTagCommand()); + registerCommand(new InviteCommand()); + registerCommand(new FlagCommand()); + registerCommand(new CountCommand()); + registerCommand(new BirthdayCommand()); + registerCommand(new ShutdownCommand()); + registerCommand(new BashCommand()); + } + + @Override + public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) { + Command command = commands.get(event.getName()); + command.onCommand(event); + } + + private void registerCommand(Command command) { + commands.putIfAbsent(command.getCommandData().getName(), command); + } + + public HashMap getCommands() { + return commands; + } + + public List getCommandDataList() { + return this.commands.values().stream().map(Command::getCommandData).collect(Collectors.toList()); + } + +} diff --git a/src/main/java/xyz/rc24/bot/commands/botadm/Bash.java b/src/main/java/xyz/rc24/bot/commands/botadm/Bash.java deleted file mode 100644 index b190ffb1..00000000 --- a/src/main/java/xyz/rc24/bot/commands/botadm/Bash.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.botadm; - -import ch.qos.logback.classic.Logger; -import com.jagrosh.jdautilities.command.Command; -import com.jagrosh.jdautilities.command.CommandEvent; -import org.slf4j.LoggerFactory; -import xyz.rc24.bot.commands.Categories; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -/** - * Runs a shell command. - * - * @author Spotlight - */ -public class Bash extends Command -{ - private static Logger logger = (Logger) LoggerFactory.getLogger(Bash.class); - - public Bash() - { - this.name = "bash"; - this.help = "Runs a bash command."; - this.category = Categories.ADMIN; - this.ownerCommand = true; - } - - @Override - protected void execute(CommandEvent event) - { - if(event.getArgs().isEmpty()) - { - event.replyError("Cannot execute a empty command!"); - return; - } - - StringBuilder output = new StringBuilder(); - String finalOutput; - try - { - ProcessBuilder builder = new ProcessBuilder(event.getArgs().split(" ")); - Process p = builder.start(); - - BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); - - String runningLineOutput; - while(!((runningLineOutput = reader.readLine()) == null)) - output.append(runningLineOutput).append("\n"); - - if(output.toString().isEmpty()) - { - event.replySuccess("Done, with no output!"); - return; - } - - // Remove linebreak - finalOutput = output.substring(0, output.length() - 1); - reader.close(); - } - catch(IOException e) - { - event.replyError("I wasn't able to find the command `" + event.getArgs() + "`!"); - return; - } - catch(Exception e) - { - logger.warn("An unknown error occurred!"); - e.printStackTrace(); - event.replyError("An unknown error occurred! Check the bot console."); - return; - } - - event.replySuccess("Input: ```\n" + event.getArgs() + "``` Output: \n```\n" + finalOutput + "```"); - } -} \ No newline at end of file diff --git a/src/main/java/xyz/rc24/bot/commands/botadm/BashCommand.java b/src/main/java/xyz/rc24/bot/commands/botadm/BashCommand.java new file mode 100644 index 00000000..09f7bae6 --- /dev/null +++ b/src/main/java/xyz/rc24/bot/commands/botadm/BashCommand.java @@ -0,0 +1,101 @@ +/* + * MIT License + * + * Copyright (c) 2017-2020 RiiConnect24 and its contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package xyz.rc24.bot.commands.botadm; + +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions; +import net.dv8tion.jda.api.interactions.commands.OptionType; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import xyz.rc24.bot.commands.Command; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +/** + * Runs a shell command. + * + * @author Spotlight + */ +public class BashCommand implements Command { + + private final Logger logger = LoggerFactory.getLogger(BashCommand.class); + + @Override + public void onCommand(SlashCommandInteractionEvent event) { + + String bashCommand = event.getOption("command").getAsString(); + + if (bashCommand.isEmpty()) { + event.reply("Command cannot be empty!").setEphemeral(true).queue(); + return; + } + + StringBuilder output = new StringBuilder(); + String finalOutput; + + try { + + ProcessBuilder builder = new ProcessBuilder(bashCommand.split(" ")); + Process process = builder.start(); + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + String runningLineOutput; + + while (!((runningLineOutput = reader.readLine()) == null)) { + output.append(runningLineOutput).append("\n"); + } + + if (output.toString().isEmpty()) { + event.reply("Executed command without output!").queue(); + return; + } + + // Remove linebreak + finalOutput = output.substring(0, output.length() - 1); + reader.close(); + + } catch (IOException e) { + event.reply("I wasn't able to find the command `" + bashCommand + "`!").setEphemeral(true).queue(); + return; + } catch (Exception e) { + logger.error("An error occurred", e); + event.replyFormat("An error occurred: %s - Check the bot console.", e.getMessage()).setEphemeral(true).queue(); + return; + } + + event.replyFormat("Input:\n```%s```\nOutput:\n```%s```", bashCommand, finalOutput).queue(); + } + + @Override + public SlashCommandData getCommandData() { + return Commands.slash("bash", "Executes a bash command") + .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR)) + .addOption(OptionType.STRING, "command", "Bash command to run", true); + } +} \ No newline at end of file diff --git a/src/main/java/xyz/rc24/bot/commands/botadm/Eval.java b/src/main/java/xyz/rc24/bot/commands/botadm/Eval.java deleted file mode 100644 index d6567d7d..00000000 --- a/src/main/java/xyz/rc24/bot/commands/botadm/Eval.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.botadm; - -import com.jagrosh.jdautilities.command.Command; -import com.jagrosh.jdautilities.command.CommandEvent; -import net.dv8tion.jda.api.Permission; -import net.dv8tion.jda.api.entities.ChannelType; -import org.codehaus.groovy.jsr223.GroovyScriptEngineFactory; -import xyz.rc24.bot.Bot; -import xyz.rc24.bot.commands.Categories; - -import javax.script.ScriptEngine; -import java.util.Arrays; -import java.util.List; - -/** - * @author Artu, Spotlight - */ - -public class Eval extends Command -{ - private ScriptEngine engine; - private List imports; - private Bot bot; - - public Eval(Bot bot) - { - this.bot = bot; - this.name = "eval"; - this.help = "Executes Groovy code"; - this.category = Categories.ADMIN; - this.botPermissions = new Permission[]{Permission.MESSAGE_WRITE}; - this.userPermissions = new Permission[]{Permission.MESSAGE_WRITE}; - this.ownerCommand = true; - this.guildOnly = false; - - engine = new GroovyScriptEngineFactory().getScriptEngine(); - imports = Arrays.asList("com.jagrosh.jdautilities.command", - "com.jagrosh.jdautilities.command.impl", - "com.jagrosh.jdautilities.commons", - "com.jagrosh.jdautilities.commons.utils", - "java.io", "java.lang", "java.util", - "net.dv8tion.jda.api", - "net.dv8tion.jda.api.entities", - "net.dv8tion.jda.api.managers", - "net.dv8tion.jda.api.utils", - "net.dv8tion.jda.internal", - "net.dv8tion.jda.internal.entities", - "net.dv8tion.jda.internal.managers", - "xyz.rc24.bot", "xyz.rc24.bot.core", "xyz.rc24.bot.core.entities", "xyz.rc24.bot.core.entities.impl", - "xyz.rc24.bot.database", "xyz.rc24.bot.listeners", "xyz.rc24.bot.managers", "xyz.rc24.bot.utils"); - } - - @Override - protected void execute(CommandEvent event) - { - String importString = ""; - String eval; - - try - { - engine.put("event", event); - engine.put("jda", event.getJDA()); - engine.put("channel", event.getChannel()); - engine.put("message", event.getMessage()); - engine.put("bot", event.getSelfUser()); - engine.put("client", event.getClient()); - engine.put("author", event.getAuthor()); - engine.put("bot", bot); - if(event.isFromType(ChannelType.TEXT)) - { - engine.put("member", event.getMember()); - engine.put("guild", event.getGuild()); - engine.put("tc", event.getTextChannel()); - engine.put("selfmember", event.getGuild().getSelfMember()); - } - - for(final String s : imports) - importString += "import " + s + ".*;"; - - eval = event.getArgs().replaceAll("getToken", "getSelfUser"); - Object out = engine.eval(importString + eval); - - if(out == null || String.valueOf(out).isEmpty()) - event.reactSuccess(); - else - event.replySuccess("Done! Output:\n```java\n" + out.toString().replaceAll(event.getJDA().getToken(), "Nice try.") + " ```"); - } - catch(Exception e2) - { - event.replyError("Error! Output:\n```java\n" + e2 + " ```"); - } - } -} \ No newline at end of file diff --git a/src/main/java/xyz/rc24/bot/commands/botadm/Shutdown.java b/src/main/java/xyz/rc24/bot/commands/botadm/ShutdownCommand.java similarity index 61% rename from src/main/java/xyz/rc24/bot/commands/botadm/Shutdown.java rename to src/main/java/xyz/rc24/bot/commands/botadm/ShutdownCommand.java index 7b21c518..a6c09cc2 100644 --- a/src/main/java/xyz/rc24/bot/commands/botadm/Shutdown.java +++ b/src/main/java/xyz/rc24/bot/commands/botadm/ShutdownCommand.java @@ -24,33 +24,24 @@ package xyz.rc24.bot.commands.botadm; -import com.jagrosh.jdautilities.command.Command; -import com.jagrosh.jdautilities.command.CommandEvent; import net.dv8tion.jda.api.Permission; -import xyz.rc24.bot.commands.Categories; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import xyz.rc24.bot.commands.Command; -/** - * @author Spotlight - */ +public class ShutdownCommand implements Command { -public class Shutdown extends Command -{ - public Shutdown() - { - this.name = "shutdown"; - this.help = "Turns the bot off."; - this.category = Categories.ADMIN; - this.botPermissions = new Permission[]{Permission.MESSAGE_WRITE}; - this.userPermissions = new Permission[]{Permission.MESSAGE_WRITE}; - this.ownerCommand = true; - this.guildOnly = false; - } + @Override + public void onCommand(SlashCommandInteractionEvent event) { + event.reply("Shutting down bot...").queue(); + event.getJDA().shutdown(); + System.exit(0); + } - @Override - protected void execute(CommandEvent event) - { - event.getTextChannel().sendMessage("Done! Cya \uD83D\uDC4B").complete(); - event.getJDA().shutdown(); - System.exit(0); - } + @Override + public SlashCommandData getCommandData() { + return Commands.slash("shutdown", "Shuts down the bot").setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR)); + } } diff --git a/src/main/java/xyz/rc24/bot/commands/general/BirthdayCmd.java b/src/main/java/xyz/rc24/bot/commands/general/BirthdayCmd.java deleted file mode 100644 index e92ebb54..00000000 --- a/src/main/java/xyz/rc24/bot/commands/general/BirthdayCmd.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.general; - -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import net.dv8tion.jda.api.interactions.commands.OptionType; -import net.dv8tion.jda.api.interactions.commands.build.OptionData; -import xyz.rc24.bot.Bot; -import xyz.rc24.bot.commands.Categories; -import xyz.rc24.bot.utils.SearcherUtil; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Artuto - */ - -public class BirthdayCmd extends SlashCommand -{ - private final Bot bot; - - public BirthdayCmd(Bot bot) - { - this.bot = bot; - this.name = "birthday"; - this.help = "View the birthday of you or someone else."; - this.category = Categories.GENERAL; - - List data = new ArrayList<>(); - data.add(new OptionData(OptionType.USER, "user", "The user to look up for the birthday.").setRequired(true)); - this.options = data; - } - - @Override - protected void execute(SlashCommandEvent event) - { - Member target; - - try { - target = event.getOption("user").getAsMember(); - } catch (Exception e) { - target = event.getMember(); - } - - String date = bot.getBirthdayDataManager().getBirthday(target.getUser().getIdLong()); - - if(date == null) - { - if(target.equals(event.getMember())) - { - event.reply("You haven't have set your birthday!" + - " Set it using `/setbirthday`!").setEphemeral(true).queue(); - } - else - event.reply("This user hasn't set their birthday!").setEphemeral(true).queue(); - - return; - } - - if(target.equals(event.getMember())) - event.reply(" Your birthday is set to **" + date + "** (date format: DD/MM)").queue(); - else - event.reply(" **" + target.getEffectiveName() + "**'s birthday is set to **" + date + "** (date format: DD/MM)").queue(); - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/general/BirthdayCommand.java b/src/main/java/xyz/rc24/bot/commands/general/BirthdayCommand.java new file mode 100644 index 00000000..20fd2d95 --- /dev/null +++ b/src/main/java/xyz/rc24/bot/commands/general/BirthdayCommand.java @@ -0,0 +1,102 @@ +/* + * MIT License + * + * Copyright (c) 2017-2020 RiiConnect24 and its contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package xyz.rc24.bot.commands.general; + +import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.OptionType; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import net.dv8tion.jda.api.interactions.commands.build.SubcommandData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import xyz.rc24.bot.RiiConnect24Bot; +import xyz.rc24.bot.commands.Command; + +import java.time.LocalDate; +import java.time.MonthDay; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; + +/** + * @author Artuto, Gamebuster + */ + +public class BirthdayCommand implements Command { + + private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); + private final Logger logger = LoggerFactory.getLogger(BirthdayCommand.class); + + @Override + public void onCommand(SlashCommandInteractionEvent event) { + + switch (event.getSubcommandName()) { + + case "set" -> { + + String date = event.getOption("date").getAsString(); + MonthDay dateTime; + + try { + // HACK -- Using 1970 because Java needs a year to parse a LocalDate + // However, since we only need the month and day, we can ignore it this way. + dateTime = MonthDay.from(LocalDate.parse(date + "/1970", formatter)); + } catch (DateTimeParseException e) { + event.reply("Could not parse the date! Please use following format `dd/MM`").setEphemeral(true).queue(); + logger.error("Could not format date '{}'", date, e); + return; + } + + long authorId = event.getUser().getIdLong(); + boolean success = RiiConnect24Bot.getInstance().getBirthdayDataManager().setBirthday(authorId, dateTime.getDayOfMonth() + "/" + dateTime.getMonthValue()); + event.reply(success ? "Set birthday successfully" : "There was an error updating your birthday! Please contact a developer.").setEphemeral(true).queue(); + } + + case "get" -> { + + User user = event.getOption("user").getAsUser(); + String date = RiiConnect24Bot.getInstance().getBirthdayDataManager().getBirthday(user.getIdLong()); + + if (date == null) { + event.reply("This user hasn't set their birthday!").setEphemeral(true).queue(); + return; + } + + event.reply(" " + user.getAsMention() + "s birthday is on **" + date + "**").queue(); + } + + default -> event.reply("Please select a subcommand!").setEphemeral(true).queue(); + } + } + + @Override + public SlashCommandData getCommandData() { + return Commands.slash("birthday", "View the birthday of yourself or someone else") + .addSubcommands(new SubcommandData("set", "Set your birthday") + .addOption(OptionType.STRING, "date", "Date of your birthday (DD/MM)", true)) + .addSubcommands(new SubcommandData("get", "Get the birthday of a user") + .addOption(OptionType.USER, "user", "User you want to see the birthday of", true)); + } +} diff --git a/src/main/java/xyz/rc24/bot/commands/general/CountCmd.java b/src/main/java/xyz/rc24/bot/commands/general/CountCmd.java deleted file mode 100644 index d4257e53..00000000 --- a/src/main/java/xyz/rc24/bot/commands/general/CountCmd.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.general; - -import ch.qos.logback.classic.Logger; -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import org.jetbrains.annotations.NotNull; -import xyz.rc24.bot.Bot; -import xyz.rc24.bot.RiiConnect24Bot; -import xyz.rc24.bot.commands.Categories; - -import java.io.IOException; - -/** - * @author Larsenv - */ - -public class CountCmd extends SlashCommand { - private final boolean debug; - private final OkHttpClient httpClient; - - private final Logger logger = RiiConnect24Bot.getLogger(CountCmd.class); - - public CountCmd(Bot bot) { - this.debug = bot.getConfig().isDebug(); - this.httpClient = bot.getHttpClient(); - this.name = "count"; - this.help = "Looks up the number of Miis on the Check Mii Out Channel and Wiis registered to use Wii Mail."; - this.category = Categories.WII; - this.guildOnly = false; - } - - @Override - protected void execute(SlashCommandEvent event) { - String url = "https://miicontestp.wii.rc24.xyz/cgi-bin/count.cgi"; - - if (debug) - logger.info("Sending request to '{}'", url); - - Request request = new Request.Builder().url(url).build(); - httpClient.newCall(request).enqueue(new Callback() { - @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) { - event.reply("Hm, something went wrong on our end.").setEphemeral(true).queue(); - logger.error("Something went wrong whilst checking the RiiConnect24 count stats: {}", e.getMessage(), - e); - } - - @Override - public void onResponse(@NotNull Call call, @NotNull Response response) { - if (!(response.isSuccessful())) { - onFailure(call, new IOException("Not success response code: " + response.code())); - response.close(); - return; - } - - try { - event.reply(response.body().string()).queue(); - } catch (Exception e) { - event.reply("Hm, something went wrong on our end.").setEphemeral(true).queue(); - } - - response.close(); - } - }); - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/general/CountCommand.java b/src/main/java/xyz/rc24/bot/commands/general/CountCommand.java new file mode 100644 index 00000000..4e7e22a2 --- /dev/null +++ b/src/main/java/xyz/rc24/bot/commands/general/CountCommand.java @@ -0,0 +1,96 @@ +/* + * MIT License + * + * Copyright (c) 2017-2020 RiiConnect24 and its contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package xyz.rc24.bot.commands.general; + +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Request; +import okhttp3.Response; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import xyz.rc24.bot.RiiConnect24Bot; +import xyz.rc24.bot.commands.Command; + +import java.io.IOException; +import java.util.concurrent.CompletableFuture; + +/** + * @author Larsenv + */ + +public class CountCommand implements Command { + + private static final Logger logger = RiiConnect24Bot.getLogger(CountCommand.class); + + @Override + public void onCommand(SlashCommandInteractionEvent event) { + + String url = "https://miicontestp.wii.rc24.xyz/cgi-bin/count.cgi"; + + CompletableFuture.runAsync(() -> { + + if (RiiConnect24Bot.getInstance().getConfig().isDebug()) logger.info("Sending request to '{}'", url); + + Request request = new Request.Builder().url(url).build(); + + RiiConnect24Bot.getInstance().getHttpClient().newCall(request).enqueue(new Callback() { + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + event.reply("Hm, something went wrong on our end.").setEphemeral(true).queue(); + logger.error("Something went wrong whilst checking the RiiConnect24 count stats", e); + } + + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) { + + if (!(response.isSuccessful())) { + onFailure(call, new IOException("Not success response code: " + response.code())); + response.close(); + return; + } + + try { + event.reply(response.body().string()).queue(); + } catch (Exception e) { + event.reply("Hm, something went wrong on our end.").setEphemeral(true).queue(); + } + + response.close(); + } + }); + }); + + } + + @Override + public SlashCommandData getCommandData() { + return Commands.slash("count", "Looks up the number of Miis on the Check Mii Out Channel and Wiis registered to use Wii Mail."); + } + +} diff --git a/src/main/java/xyz/rc24/bot/commands/general/FlagCmd.java b/src/main/java/xyz/rc24/bot/commands/general/FlagCmd.java deleted file mode 100644 index 196a08a6..00000000 --- a/src/main/java/xyz/rc24/bot/commands/general/FlagCmd.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.general; - -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import net.dv8tion.jda.api.interactions.commands.OptionType; -import net.dv8tion.jda.api.interactions.commands.build.OptionData; -import xyz.rc24.bot.Bot; -import xyz.rc24.bot.commands.Categories; -import xyz.rc24.bot.core.entities.Flag; - -import java.util.ArrayList; -import java.util.List; - -public class FlagCmd extends SlashCommand -{ - private final Bot bot; - - public FlagCmd(Bot bot) - { - this.bot = bot; - this.name = "flag"; - this.help = "Sets your flag to show in your code lookup."; - this.aliases = new String[]{"setflag", "setcountry", "country"}; - this.category = Categories.GENERAL; - this.guildOnly = false; - - List data = new ArrayList<>(); - data.add(new OptionData(OptionType.STRING, "region", "The region to set your flag to.").setRequired(true)); - this.options = data; - } - - @Override - protected void execute(SlashCommandEvent event) - { - long id = event.getMember().getIdLong(); - - Flag flag = Flag.fromName(event.getOption("flag").getAsString()); - if(flag == Flag.UNKNOWN) - { - event.reply("Unknown country!").setEphemeral(true).queue(); - return; - } - - boolean success = bot.getCodeDataManager().setFlag(id, flag.getEmote()); - - if(success) - event.reply("Updated successfully!").setEphemeral(true).queue(); - else - event.reply("Error updating your flag! Please contact a developer.").setEphemeral(true).queue(); - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/general/FlagCommand.java b/src/main/java/xyz/rc24/bot/commands/general/FlagCommand.java new file mode 100644 index 00000000..0ebd125a --- /dev/null +++ b/src/main/java/xyz/rc24/bot/commands/general/FlagCommand.java @@ -0,0 +1,68 @@ +/* + * MIT License + * + * Copyright (c) 2017-2020 RiiConnect24 and its contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package xyz.rc24.bot.commands.general; + +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.OptionType; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import net.dv8tion.jda.api.interactions.commands.build.SubcommandData; +import xyz.rc24.bot.RiiConnect24Bot; +import xyz.rc24.bot.commands.Command; +import xyz.rc24.bot.core.entities.Flag; + +public class FlagCommand implements Command { + + @Override + public void onCommand(SlashCommandInteractionEvent event) { + + switch (event.getSubcommandName()) { + + case "clear" -> { + boolean success = RiiConnect24Bot.getInstance().getCodeDataManager().setFlag(event.getUser().getIdLong(), null); + event.reply(success ? "Updated successfully!" : "Error clearing your flag! Please contact a developer.").setEphemeral(true).queue(); + } + + case "set" -> { + Flag flag = Flag.fromName(event.getOption("flag").getAsString()); + if (flag == null) { + event.reply("Not a valid country, please try again.").setEphemeral(true).queue(); + return; + } + boolean success = RiiConnect24Bot.getInstance().getCodeDataManager().setFlag(event.getUser().getIdLong(), flag.getName()); + event.reply(success ? "Updated successfully!" : "Error clearing your flag! Please contact a developer.").setEphemeral(true).queue(); + } + } + } + + @Override + public SlashCommandData getCommandData() { + return Commands.slash("flag", "Sets the flag in your code lookup") + .addSubcommands(new SubcommandData("clear", "Clear your flag")) + .addSubcommands(new SubcommandData("set", "Set your flag") + .addOption(OptionType.STRING, "flag", "Flag", true, true)); + } + +} diff --git a/src/main/java/xyz/rc24/bot/commands/general/InviteCmd.java b/src/main/java/xyz/rc24/bot/commands/general/InviteCommand.java similarity index 65% rename from src/main/java/xyz/rc24/bot/commands/general/InviteCmd.java rename to src/main/java/xyz/rc24/bot/commands/general/InviteCommand.java index 1bcfe6bd..528c1e65 100644 --- a/src/main/java/xyz/rc24/bot/commands/general/InviteCmd.java +++ b/src/main/java/xyz/rc24/bot/commands/general/InviteCommand.java @@ -24,26 +24,23 @@ package xyz.rc24.bot.commands.general; -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import xyz.rc24.bot.commands.Categories; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import xyz.rc24.bot.commands.Command; /** - * @author Artuto + * @author Gamebuster */ +public class InviteCommand implements Command { -public class InviteCmd extends SlashCommand -{ - public InviteCmd() - { - this.name = "invite"; - this.category = Categories.GENERAL; - this.help = "Invite me to your server."; - } + @Override + public void onCommand(SlashCommandInteractionEvent event) { + event.reply("Aw, you want to invite me? <3\nInvite me here: " + event.getJDA().getInviteUrl()).queue(); + } - @Override - protected void execute(SlashCommandEvent event) - { - event.reply("Aw, you want to invite me? <3\nInvite me here: " + event.getJDA().getInviteUrl()).queue(); - } + @Override + public SlashCommandData getCommandData() { + return Commands.slash("invite", "Invite me to your server!"); + } } diff --git a/src/main/java/xyz/rc24/bot/commands/general/PingCmd.java b/src/main/java/xyz/rc24/bot/commands/general/PingCmd.java deleted file mode 100644 index 85d72172..00000000 --- a/src/main/java/xyz/rc24/bot/commands/general/PingCmd.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.general; - -import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.Permission; -import xyz.rc24.bot.commands.Categories; - -/** - * @author Artuto - */ - -public class PingCmd extends SlashCommand -{ - public PingCmd() { - this.name = "ping"; - this.help = "Ping the bot"; - this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS}; - this.guildOnly = false; - } - - @Override - protected void execute(SlashCommandEvent slashCommandEvent) { - // Has to be simpler due to interaction weirdness - slashCommandEvent.reply("Pong!").setEphemeral(true).queue(); - } - - @Override - protected void execute(CommandEvent commandEvent) { - // Get the timestamp of the ping message - long time = commandEvent.getMessage().getTimeCreated().toInstant().toEpochMilli(); - // Send a "Checking ping" message and calculate the difference between this message and the %^ping message - commandEvent.getChannel().sendMessageEmbeds(new EmbedBuilder().setDescription("Checking ping..").build()).queue((msg) -> { - EmbedBuilder eb = new EmbedBuilder().setDescription( - "Ping is " + (msg.getTimeCreated().toInstant().toEpochMilli() - time) + "ms\n" + - "Gateway Ping is " + commandEvent.getJDA().getGatewayPing() + "ms\n" - ); - msg.editMessageEmbeds(eb.build()).queue(); - }); - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/general/ReviveCmd.java b/src/main/java/xyz/rc24/bot/commands/general/ReviveCmd.java deleted file mode 100644 index e7c0223c..00000000 --- a/src/main/java/xyz/rc24/bot/commands/general/ReviveCmd.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.general; - -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.Permission; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import xyz.rc24.bot.Bot; -import xyz.rc24.bot.commands.Categories; -import xyz.rc24.bot.core.entities.Poll; -import xyz.rc24.bot.core.entities.impl.MiitomoPoll; -import xyz.rc24.bot.managers.PollManager; - -public class ReviveCmd extends SlashCommand -{ - private final PollManager manager; - - public ReviveCmd(Bot bot) - { - this.name = "revive"; - this.help = "Revives the chat by sending an Everybody Votes Channel or Miitomo poll for users to vote in."; - this.category = Categories.GENERAL; - this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS}; - this.manager = bot.getPollManager(); - } - - @Override - protected void execute(SlashCommandEvent event) - { - // Get a random poll - Poll poll = manager.getRandomPoll(); - - // Now we need to build the embed - EmbedBuilder embed = new EmbedBuilder() - {{ - setTitle("<:EverybodyVotesChannel:317090360449040388> " + poll.getQuestion()); - - if(!(poll instanceof MiitomoPoll)) - { - setDescription("\uD83C\uDD70 " + poll.getResponse1() + "\n" + - "_ _\n" + // Line separator - "\uD83C\uDD71 " + poll.getResponse2()); - setFooter("This question was from the " + poll.getCountryFlag() + " EVC", null); - } - else - setFooter("This question was from Miitomo"); - - // setColor(event.getSelfMember().getColor()); - }}; - - // Send embed to chat - event.replyEmbeds(embed.build()).queue(); - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/general/RiiTagCmd.java b/src/main/java/xyz/rc24/bot/commands/general/RiiTagCmd.java deleted file mode 100644 index c432c677..00000000 --- a/src/main/java/xyz/rc24/bot/commands/general/RiiTagCmd.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.general; - -import ch.qos.logback.classic.Logger; -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.Permission; -import net.dv8tion.jda.api.entities.ChannelType; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.User; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import net.dv8tion.jda.api.interactions.commands.OptionType; -import net.dv8tion.jda.api.interactions.commands.build.OptionData; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import xyz.rc24.bot.Bot; -import xyz.rc24.bot.RiiConnect24Bot; -import xyz.rc24.bot.commands.Categories; -import xyz.rc24.bot.utils.SearcherUtil; - -import java.awt.Color; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class RiiTagCmd extends SlashCommand { - private final Logger logger; - private final OkHttpClient httpClient; - private final String URL = "https://tag.rc24.xyz/%s/tag.max.png?randomizer=%f"; - - public RiiTagCmd(Bot bot) { - this.name = "riitag"; - this.help = "Gets a user's RiiTag"; - this.arguments = "[user]"; - this.aliases = new String[] { "tag" }; - this.category = Categories.GENERAL; - this.botPermissions = new Permission[] { Permission.MESSAGE_EMBED_LINKS }; - this.logger = RiiConnect24Bot.getLogger(RiiTagCmd.class); - this.httpClient = bot.getHttpClient(); - this.guildOnly = false; - - List data = new ArrayList<>(); - data.add(new OptionData(OptionType.USER, "user", "The user to grab the RiiTag of.").setRequired(true)); - this.options = data; - } - - @Override - protected void execute(SlashCommandEvent event) { - Member member = event.getOption("user").getAsMember(); - if (member == null) - return; - - User user = member.getUser(); - Request request = new Request.Builder().url(String.format(URL, user.getId(), 0D)).build(); - httpClient.newCall(request).enqueue(new Callback() { - @Override - public void onFailure(Call call, IOException e) { - /* - * if(e instanceof SocketTimeoutException) - * { - */ - event.reply("The RiiTag server did not respond.").setEphemeral(true).queue(); - /* - * return; - * } - * - * event. - * replyError("Hm, something went wrong on our end. Ask a dev to check out my console.\n" - * + - * "```" + e.getMessage() + "```"); - * logger. - * error("Something went wrong whilst checking if user {} has a RiiTag: {}", - * user.getId(), - * e.getMessage(), e); - */ - } - - @Override - public void onResponse(Call call, Response response) { - if (response.code() == 404) { - event.reply("**" + user.getAsTag() + "** does not have a RiiTag!").setEphemeral(true).queue(); - response.close(); - return; - } - - if (!(response.isSuccessful())) { - onFailure(call, new IOException("Server error: HTTP Code " + response.code())); - response.close(); - return; - } - - displayTag(event, user); - response.close(); - } - }); - } - - private void displayTag(SlashCommandEvent event, User user) { - EmbedBuilder embedBuilder = new EmbedBuilder() - .setAuthor(user.getAsTag() + "'s RiiTag", null, user.getEffectiveAvatarUrl()) - .setColor(event.getGuild() == null ? null : event.getGuild().getSelfMember().getColor()) - .setImage(String.format(URL, user.getId(), Math.random())); - - event.replyEmbeds(embedBuilder.build()).queue(); - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/general/RiiTagCommand.java b/src/main/java/xyz/rc24/bot/commands/general/RiiTagCommand.java new file mode 100644 index 00000000..6cd58b5f --- /dev/null +++ b/src/main/java/xyz/rc24/bot/commands/general/RiiTagCommand.java @@ -0,0 +1,93 @@ +/* + * MIT License + * + * Copyright (c) 2017-2020 RiiConnect24 and its contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package xyz.rc24.bot.commands.general; + +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.OptionType; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Request; +import okhttp3.Response; +import xyz.rc24.bot.Bot; +import xyz.rc24.bot.RiiConnect24Bot; +import xyz.rc24.bot.commands.Command; + +import java.io.IOException; + +public class RiiTagCommand implements Command { + + private static final String URL = "https://tag.rc24.xyz/%s/tag.max.png?randomizer=%f"; + + @Override + public void onCommand(SlashCommandInteractionEvent event) { + + User member = event.getOption("user").getAsUser(); + Request request = new Request.Builder().url(String.format(URL, member.getId(), 0D)).build(); + Bot bot = RiiConnect24Bot.getInstance(); + + bot.getHttpClient().newCall(request).enqueue(new Callback() { + + @Override + public void onFailure(Call call, IOException e) { + event.reply("The RiiTag server did not respond.").setEphemeral(true).queue(); + } + + @Override + public void onResponse(Call call, Response response) { + + if (response.code() == 404) { + event.reply(member.getAsMention() + " does not have a RiiTag!").setEphemeral(true).queue(); + response.close(); + return; + } + + if (!(response.isSuccessful())) { + onFailure(call, new IOException("Server error: HTTP Code " + response.code())); + response.close(); + return; + } + + EmbedBuilder embedBuilder = new EmbedBuilder() + .setAuthor(member.getEffectiveName() + "'s RiiTag", null, member.getEffectiveAvatarUrl()) + .setColor(event.getGuild().getSelfMember().getColor()) + .setImage(String.format(URL, member.getId(), Math.random())); + + event.replyEmbeds(embedBuilder.build()).queue(); + response.close(); + } + }); + + } + + @Override + public SlashCommandData getCommandData() { + return Commands.slash("riitag", "Gets the user's Riitag").addOption(OptionType.USER, "user", "User", true); + } + +} diff --git a/src/main/java/xyz/rc24/bot/commands/general/RuleCmd.java b/src/main/java/xyz/rc24/bot/commands/general/RuleCommand.java similarity index 81% rename from src/main/java/xyz/rc24/bot/commands/general/RuleCmd.java rename to src/main/java/xyz/rc24/bot/commands/general/RuleCommand.java index 5d120862..668f4ae6 100644 --- a/src/main/java/xyz/rc24/bot/commands/general/RuleCmd.java +++ b/src/main/java/xyz/rc24/bot/commands/general/RuleCommand.java @@ -24,45 +24,22 @@ package xyz.rc24.bot.commands.general; -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.commands.OptionType; -import net.dv8tion.jda.api.interactions.commands.build.OptionData; -import xyz.rc24.bot.commands.Categories; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import xyz.rc24.bot.commands.Command; -import java.util.ArrayList; -import java.util.List; import java.util.HashMap; import java.util.Map; /** - * @author Larsenv + * @author Larsenv, Gamebuster */ -public class RuleCmd extends SlashCommand { - public RuleCmd() { - this.name = "rule"; - this.help = "Looks up a rule in the RiiConnect24 Discord server."; - this.category = Categories.WII; - this.guildOnly = false; - - List data = new ArrayList<>(); - data.add(new OptionData(OptionType.STRING, "num", "The rule number to look up.")); - this.options = data; - } - - @Override - protected void execute(SlashCommandEvent event) { - int ruleNum = Integer.parseInt(event.getOption("num").getAsString()); - - if (ruleList.containsKey(ruleNum)) { - event.reply("**Rule " + event.getOption("num").getAsString() + "**: " + ruleList.get(ruleNum)).queue(); - } else { - event.reply("Rule not found.").setEphemeral(true).queue(); - } - } - - private final Map ruleList = new HashMap<>() { +public class RuleCommand implements Command { + + private static final Map RULES = new HashMap<>() { { put(1, "Staff members will use common sense when acting in an official capacity and may apply sanctions as they see fit, including in cases not explicitly covered by these rules - just be excellent to each other."); put(2, "Don’t harass or bother people, this includes repeated @mentions, trolling, and in Direct Messages. Don’t attack users on this server - examples of behavior that we consider to be a violation of this include racism, sexism, ableism, religious discrimination, homophobia/transphobia, or anything someone may find to be offensive - be nice! If someone is harassing you, please tell a staff member and they will take appropriate action."); @@ -82,6 +59,25 @@ protected void execute(SlashCommandEvent event) { put(34, "( ͥ° ͜ʖ ͥ°)"); put(69, "( ͥ° ͜ʖ ͥ°)"); put(420, "( ͥ° ͜ʖ ͥ°)"); + put(621, "C₅H₈NO₄Na ( ͥ° ͜ʖ ͥ°)"); } }; + + @Override + public void onCommand(SlashCommandInteractionEvent event) { + + int rule = event.getOption("index").getAsInt(); + + if (RULES.containsKey(rule)) { + event.reply("**Rule " + rule + "**: " + RULES.get(rule)).queue(); + } else { + event.reply("Rule not found.").setEphemeral(true).queue(); + } + } + + @Override + public SlashCommandData getCommandData() { + return Commands.slash("rule", "Provides information about specific rules.") + .addOption(OptionType.INTEGER, "index", "Rule Index", true); + } } diff --git a/src/main/java/xyz/rc24/bot/commands/general/SetBirthdayCmd.java b/src/main/java/xyz/rc24/bot/commands/general/SetBirthdayCmd.java deleted file mode 100644 index a2108535..00000000 --- a/src/main/java/xyz/rc24/bot/commands/general/SetBirthdayCmd.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.general; - -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import net.dv8tion.jda.api.interactions.commands.OptionType; -import net.dv8tion.jda.api.interactions.commands.build.OptionData; -import xyz.rc24.bot.Bot; -import xyz.rc24.bot.commands.Categories; - -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeParseException; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Artuto - */ - -public class SetBirthdayCmd extends SlashCommand -{ - private Bot bot; - private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM[/yyyy]"); - - public SetBirthdayCmd(Bot bot) - { - this.bot = bot; - this.name = "setbirthday"; - this.help = "Sets your birthday. Please note that this command uses the DD/MM date format."; - this.category = Categories.GENERAL; - this.guildOnly = false; - - List data = new ArrayList<>(); - data.add(new OptionData(OptionType.STRING, "date", "The birthday to set to in DD/MM format.").setRequired(true)); - this.options = data; - } - - @Override - protected void execute(SlashCommandEvent event) - { - long id = event.getMember().getIdLong(); - LocalDate dateTime = parseDate(event.getOption("date").getAsString()); - - if(dateTime == null) - { - event.reply("I couldn't parse your date.\n" + - "Try something like: `" + bot.getPrefix(event.getGuild()) + "setbirthday 25/12` (date format: DD/MM).").setEphemeral(true).queue(); - return; - } - - boolean success = bot.getBirthdayDataManager().setBirthday(id, dateTime.getDayOfMonth() + "/" + dateTime.getMonthValue()); - - if(success) - event.reply("Updated successfully!").setEphemeral(true).queue(); - else - event.reply("There was an error updating your birthday! Please contact a developer.").setEphemeral(true).queue(); - } - - private LocalDate parseDate(String args) - { - try - { - return args.endsWith("/\\d{4}/") ? LocalDate.parse(args, formatter) : LocalDate.parse(args + "/2019", formatter); - } - catch(DateTimeParseException ignored) {} - - return null; - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/tools/DefaultAddCmd.java b/src/main/java/xyz/rc24/bot/commands/tools/DefaultAddCmd.java deleted file mode 100644 index c6cbe705..00000000 --- a/src/main/java/xyz/rc24/bot/commands/tools/DefaultAddCmd.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.tools; - -import com.jagrosh.jdautilities.command.Command; -import com.jagrosh.jdautilities.command.CommandEvent; -import net.dv8tion.jda.api.Permission; -import xyz.rc24.bot.Bot; -import xyz.rc24.bot.commands.Categories; -import xyz.rc24.bot.core.entities.CodeType; -import xyz.rc24.bot.database.GuildSettingsDataManager; -import xyz.rc24.bot.utils.FormatUtil; - -/** - * @author Artuto - */ - -public class DefaultAddCmd extends Command -{ - private GuildSettingsDataManager dataManager; - - public DefaultAddCmd(Bot bot) - { - this.dataManager = bot.getGuildSettingsDataManager(); - this.name = "defaultadd"; - this.help = "Changes the default `add` command's type."; - this.category = Categories.TOOLS; - this.userPermissions = new Permission[]{Permission.MANAGE_SERVER}; - } - - @Override - protected void execute(CommandEvent event) - { - CodeType type = CodeType.fromCode(event.getArgs()); - if(type == CodeType.UNKNOWN) - { - event.replyError(FormatUtil.getCodeTypes()); - return; - } - - if(dataManager.setDefaultAddType(type, event.getGuild().getIdLong())) - event.replySuccess("Successfully set `" + type.getName() + "` as default `add` type!"); - else - event.replyError("Error whilst updating the default add type! Please contact a developer."); - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/tools/DefaultAddCommand.java b/src/main/java/xyz/rc24/bot/commands/tools/DefaultAddCommand.java new file mode 100644 index 00000000..f10633c7 --- /dev/null +++ b/src/main/java/xyz/rc24/bot/commands/tools/DefaultAddCommand.java @@ -0,0 +1,62 @@ +/* + * MIT License + * + * Copyright (c) 2017-2020 RiiConnect24 and its contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package xyz.rc24.bot.commands.tools; + +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions; +import net.dv8tion.jda.api.interactions.commands.OptionType; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import xyz.rc24.bot.Bot; +import xyz.rc24.bot.RiiConnect24Bot; +import xyz.rc24.bot.commands.Command; +import xyz.rc24.bot.core.entities.CodeType; + +/** + * @author Artuto, Gamebuster + */ +public class DefaultAddCommand implements Command { + + @Override + public void onCommand(SlashCommandInteractionEvent event) { + + Bot bot = RiiConnect24Bot.getInstance(); + CodeType newDefaultCodeType = CodeType.fromCode(event.getOption("type").getAsString()); + + if (bot.getGuildSettingsDataManager().setDefaultAddType(newDefaultCodeType, event.getGuild().getIdLong())) { + event.reply("Successfully set `" + newDefaultCodeType.getName() + "` as default `add` type!").queue(); + } else { + event.reply("Error whilst updating the default add type! Please contact a developer.").setEphemeral(true).queue(); + } + } + + @Override + public SlashCommandData getCommandData() { + return Commands.slash("defaultadd", "Set the default type for the add command") + .addOption(OptionType.STRING, "type", "Type used for new default code", true, true) + .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_SERVER)); + } +} diff --git a/src/main/java/xyz/rc24/bot/commands/tools/PrefixCmd.java b/src/main/java/xyz/rc24/bot/commands/tools/PrefixCmd.java deleted file mode 100644 index bd6bf11f..00000000 --- a/src/main/java/xyz/rc24/bot/commands/tools/PrefixCmd.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.tools; - -import com.jagrosh.jdautilities.command.Command; -import com.jagrosh.jdautilities.command.CommandEvent; -import net.dv8tion.jda.api.Permission; -import xyz.rc24.bot.commands.Categories; -import xyz.rc24.bot.core.entities.GuildSettings; -import xyz.rc24.bot.database.GuildSettingsDataManager; - -/** - * @author Artuto - */ - -public class PrefixCmd extends Command -{ - private final GuildSettingsDataManager dataManager; - - public PrefixCmd(GuildSettingsDataManager dataManager) - { - this.dataManager = dataManager; - this.name = "prefix"; - this.help = "Set and display the bot's prefixes."; - this.userPermissions = new Permission[]{Permission.MANAGE_SERVER}; - this.category = Categories.TOOLS; - } - - @Override - protected void execute(CommandEvent event) - { - GuildSettings gs = event.getClient().getSettingsFor(event.getGuild()); - String args = event.getArgs(); - - if(args.isEmpty()) - { - event.reply("ℹ The prefix in this server is: " + gs.getPrefix()); - return; - } - - if(args.length() > 5) - { - event.replyError("The prefix length may not be longer than 5 characters!"); - return; - } - - if(args.equals("none")) - { - if(dataManager.setPrefix(event.getGuild().getIdLong(), null)) - event.replySuccess("Successfully disabled the custom prefix!"); - else - event.replyError("Error whilst disabling the custom prefix! Please contact a developer."); - - return; - } - - if(gs.getPrefix().equals(args)) - { - event.replyError("This prefix is already in use!"); - return; - } - - if(dataManager.setPrefix(event.getGuild().getIdLong(), args)) - event.replySuccess("Successfully set `" + args + "` as the prefix!"); - else - event.replyError("Error whilst setting the prefix! Please contact a developer."); - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/tools/StatsCmd.java b/src/main/java/xyz/rc24/bot/commands/tools/StatsCommand.java similarity index 61% rename from src/main/java/xyz/rc24/bot/commands/tools/StatsCmd.java rename to src/main/java/xyz/rc24/bot/commands/tools/StatsCommand.java index 8fcd14a5..414a8ef1 100644 --- a/src/main/java/xyz/rc24/bot/commands/tools/StatsCmd.java +++ b/src/main/java/xyz/rc24/bot/commands/tools/StatsCommand.java @@ -24,14 +24,13 @@ package xyz.rc24.bot.commands.tools; -import com.jagrosh.jdautilities.command.Command; -import com.jagrosh.jdautilities.command.CommandEvent; import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; import okhttp3.Call; import okhttp3.Callback; -import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import org.json.JSONObject; @@ -39,76 +38,78 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import xyz.rc24.bot.Bot; -import xyz.rc24.bot.Const; -import xyz.rc24.bot.commands.Categories; +import xyz.rc24.bot.RiiConnect24Bot; +import xyz.rc24.bot.commands.Command; -import java.awt.Color; +import java.awt.*; import java.io.IOException; import java.util.Set; import java.util.TreeSet; -public class StatsCmd extends Command { - private final Logger logger = LoggerFactory.getLogger("Stats Command"); - private final OkHttpClient httpClient; +public class StatsCommand implements Command { - public StatsCmd(Bot bot) { - this.name = "stats"; - this.help = "Shows stats for the RC24 services"; - this.category = Categories.TOOLS; - this.botPermissions = new Permission[] { Permission.MESSAGE_EMBED_LINKS }; - this.ownerCommand = false; - this.guildOnly = false; - - this.httpClient = bot.getHttpClient(); - } + private static final Logger logger = LoggerFactory.getLogger(StatsCommand.class); @Override - protected void execute(CommandEvent event) { + public void onCommand(SlashCommandInteractionEvent event) { + + Bot bot = RiiConnect24Bot.getInstance(); + Request request = new Request.Builder() .url("http://164.132.44.106/stats.json") - .addHeader("User-Agent", "RC24-Bot " + Const.VERSION) + .addHeader("User-Agent", "RC24-Bot " + RiiConnect24Bot.VERSION) .build(); - httpClient.newCall(request).enqueue(new Callback() { + bot.getHttpClient().newCall(request).enqueue(new Callback() { + @Override public void onFailure(Call call, IOException e) { - event.replyError("Could not contact the Stats API! Please ask a owner to check the console. " + - "Error: ```\n" + e.getMessage() + "\n```"); + event.reply("Could not contact the Stats API! Please ask a owner to check the console. Error: ```" + e.getMessage() + "```").setEphemeral(true).queue(); logger.error("Exception while contacting the Stats API! ", e); } @Override public void onResponse(Call call, Response response) { + try (response) { - if (!(response.isSuccessful())) - throw new IOException("Unsuccessful response code: " + response.code()); - if (response.body() == null) - throw new IOException("Response body is null!"); + if (!(response.isSuccessful())) { + event.reply("An error occurred: " + response.code()).setEphemeral(true).queue(); + return; + } - EmbedBuilder eb = new EmbedBuilder(); - MessageBuilder mb = new MessageBuilder(); + if (response.body() == null) { + event.reply("An error occurred: Response body is null!").setEphemeral(true).queue(); + return; + } + EmbedBuilder eb = new EmbedBuilder(); + MessageCreateBuilder mb = new MessageCreateBuilder(); eb.setDescription(parseJSON(response)); eb.setColor(Color.decode("#29B7EB")); - mb.setContent("<:RC24:302470872201953280> Service stats of RC24:").setEmbeds(eb.build()); + mb.addEmbeds(eb.build()); + event.reply(mb.build()).queue(); - response.close(); - event.reply(mb.build()); } catch (Exception e) { - onFailure(call, e instanceof IOException ? (IOException) e : new IOException(e)); + onFailure(call, new IOException(e)); + response.close(); + } finally { response.close(); } } }); } - @SuppressWarnings("ConstantConditions") - private String parseJSON(Response response) { + @Override + public SlashCommandData getCommandData() { + return Commands.slash("stats", "Retrieve the RC24 Stats"); + } + + private static String parseJSON(Response response) { + JSONObject json = new JSONObject(new JSONTokener(response.body().byteStream())); Set keys = new TreeSet<>(json.keySet()); - StringBuilder green = new StringBuilder(); StringBuilder yellow = new StringBuilder(); StringBuilder red = new StringBuilder(); @@ -116,16 +117,10 @@ private String parseJSON(Response response) { keys.forEach(k -> { String status = json.getString(k); - switch (status) { - case "green": - green.append("+ ").append(k).append("\n"); - break; - case "yellow": - yellow.append("* ").append(k).append("\n"); - break; - default: - red.append("- ").append(k).append("\n"); + case "green" -> green.append("+ ").append(k).append("\n"); + case "yellow" -> yellow.append("* ").append(k).append("\n"); + default -> red.append("- ").append(k).append("\n"); } }); diff --git a/src/main/java/xyz/rc24/bot/commands/wii/AddCmd.java b/src/main/java/xyz/rc24/bot/commands/wii/AddCmd.java deleted file mode 100644 index 59e052ae..00000000 --- a/src/main/java/xyz/rc24/bot/commands/wii/AddCmd.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.wii; - -import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import net.dv8tion.jda.api.interactions.commands.OptionType; -import net.dv8tion.jda.api.interactions.commands.build.OptionData; -import xyz.rc24.bot.Bot; -import xyz.rc24.bot.commands.Categories; -import xyz.rc24.bot.core.BotCore; -import xyz.rc24.bot.core.entities.CodeType; -import xyz.rc24.bot.core.entities.GuildSettings; -import xyz.rc24.bot.utils.FormatUtil; -import xyz.rc24.bot.utils.SearcherUtil; - -import java.util.Map; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Artuto - */ - -public class AddCmd extends SlashCommand -{ - private final BotCore core; - - public AddCmd(Bot bot) - { - this.core = bot.getCore(); - this.name = "add"; - this.help = "Sends your friend code to another user."; - this.category = Categories.WII; - - List data = new ArrayList<>(); - data.add(new OptionData(OptionType.USER, "user", "The user you want to add.")); - this.options = data; - } - - @Override - protected void execute(SlashCommandEvent event) - { - Member member = event.getOption("user").getAsMember(); - if(member == null) - return; - - GuildSettings gs = getClient().getSettingsFor(event.getGuild()); - CodeType defaultAddType = gs.getDefaultAddType(); - - if(member.equals(event.getMember())) - { - event.reply("You can't add yourself!").setEphemeral(true).queue(); - return; - } - if(member.getUser().isBot()) - { - event.reply("You can't add bots!").setEphemeral(true).queue(); - return; - } - - Map authorTypeCodes = core.getCodesForType(defaultAddType, event.getGuild() == null ? null : event.getGuild().getSelfMember().getIdLong()); - if(authorTypeCodes.isEmpty()) - { - event.reply("**" + event.getMember().getEffectiveName() + "** has not added any friend codes!").setEphemeral(true).queue(); - return; - } - - Map targetTypeCodes = core.getCodesForType(defaultAddType, member.getUser().getIdLong()); - if(targetTypeCodes.isEmpty()) - { - event.reply("**" + member.getEffectiveName() + "** has not added any friend codes!").setEphemeral(true).queue(); - return; - } - - // Send target's code to author - event.reply(getAddMessageHeader(defaultAddType, event.getMember(), - false) + "\n\n" + FormatUtil.getCodeLayout(authorTypeCodes)) - .queue(null, (failure) -> event.reply("Hey, " + member.getAsMention() + - ": I couldn't DM you. Make sure your DMs are enabled.").setEphemeral(true)); - - // Send author's code to target - member.getUser().openPrivateChannel().queue(pc -> - pc.sendMessage(getAddMessageHeader(defaultAddType, event.getMember(), - false) + "\n\n" + FormatUtil.getCodeLayout(authorTypeCodes)) - .queue(null, (failure) -> event.reply("Hey, " + member.getAsMention() + - ": I couldn't DM you. Make sure your DMs are enabled.").setEphemeral(true))); - } - - private String getAddMessageHeader(CodeType type, Member member, boolean isCommandRunner) - { - if(!(isCommandRunner)) - return "**" + member.getEffectiveName() + "** has requested to add your " + type.getDisplayName() + " friend code(s)!"; - else - return "You have requested to add **" + member.getEffectiveName() + "**'s " + type.getDisplayName() + " friend code(s)."; - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/wii/AddCommand.java b/src/main/java/xyz/rc24/bot/commands/wii/AddCommand.java new file mode 100644 index 00000000..7199c7fe --- /dev/null +++ b/src/main/java/xyz/rc24/bot/commands/wii/AddCommand.java @@ -0,0 +1,87 @@ +/* + * MIT License + * + * Copyright (c) 2017-2020 RiiConnect24 and its contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package xyz.rc24.bot.commands.wii; + +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.OptionType; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import xyz.rc24.bot.RiiConnect24Bot; +import xyz.rc24.bot.commands.Command; +import xyz.rc24.bot.core.BotCore; +import xyz.rc24.bot.core.entities.CodeType; +import xyz.rc24.bot.core.entities.GuildSettings; +import xyz.rc24.bot.utils.FormatUtil; + +import java.util.Map; + +/** + * @author Artuto, Gamebuster + */ + +public class AddCommand implements Command { + + @Override + public void onCommand(SlashCommandInteractionEvent event) { + + BotCore botCore = RiiConnect24Bot.getInstance().getCore(); + GuildSettings guildSettings = botCore.getGuildSettings(event.getGuild().getIdLong()); + CodeType codeType = guildSettings.getDefaultAddType(); + + Member member = event.getOption("user").getAsMember(); + + if (member.getUser().isBot()) { + event.reply("You cannot add bots").setEphemeral(true).queue(); + return; + } + + Map authorTypeCodes = botCore.getCodesForType(codeType, event.getUser().getIdLong()); + + if (authorTypeCodes.isEmpty()) { + event.reply(member.getAsMention() + " does not have any friend codes added.").setEphemeral(true).queue(); + return; + } + + // Send a message to the target + member.getUser().openPrivateChannel().flatMap(privateChannel -> { + return privateChannel.sendMessage(event.getMember().getAsMention() + " has requested to add your " + codeType.getDisplayName() + " friend code(s)!\n\n" + FormatUtil.getCodeLayout(authorTypeCodes)); + }).queue(); + + Map targetTypeCodes = botCore.getCodesForType(codeType, member.getIdLong()); + + // Send a message to author + event.getUser().openPrivateChannel().flatMap(privateChannel -> { + return privateChannel.sendMessage("You have requested to add " + member.getAsMention() + "s " + codeType.getDisplayName() + " friend code(s).\n\n" + FormatUtil.getCodeLayout(targetTypeCodes)); + }).queue(); + + } + + @Override + public SlashCommandData getCommandData() { + return Commands.slash("add", "Send your friend code to another user.") + .addOption(OptionType.USER, "user", "User", true); + } +} diff --git a/src/main/java/xyz/rc24/bot/commands/wii/BlocksCmd.java b/src/main/java/xyz/rc24/bot/commands/wii/BlocksCmd.java deleted file mode 100644 index 3ff6bb8d..00000000 --- a/src/main/java/xyz/rc24/bot/commands/wii/BlocksCmd.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.wii; - -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import net.dv8tion.jda.api.interactions.commands.OptionType; -import net.dv8tion.jda.api.interactions.commands.build.OptionData; -import net.dv8tion.jda.api.Permission; -import xyz.rc24.bot.commands.Categories; - -import java.util.ArrayList; -import java.util.List; - -public class BlocksCmd extends SlashCommand -{ - public BlocksCmd() - { - this.name = "blocks"; - this.help = "Convert between Nintendo blocks and MBs."; - this.category = Categories.WII; - this.botPermissions = new Permission[]{Permission.MESSAGE_WRITE, Permission.MESSAGE_EMBED_LINKS}; - this.guildOnly = false; - - List data = new ArrayList<>(); - data.add(new OptionData(OptionType.STRING, "num", "The number of blocks.")); - this.options = data; - } - - @Override - protected void execute(SlashCommandEvent event) - { - if(event.getOption("num").getAsString().isEmpty()) - { - event.reply("\u2139 1 block is 128kb\n" + - "8 blocks are 1MB").queue(); - return; - } - - double blocks = parseNumber(event.getOption("num").getAsString()); - if(blocks < 1) - { - event.reply("Invalid number!").setEphemeral(true).queue(); - return; - } - - double mb = blocks * 128 / 1024; - event.reply("\u2139 " + blocks + " block(s) are " + mb + "MB(s)").queue(); - } - - private double parseNumber(String args) - { - try {return Double.parseDouble(args);} - catch(NumberFormatException e) {return -1.0;} - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/wii/DNS.java b/src/main/java/xyz/rc24/bot/commands/wii/BlocksCommand.java similarity index 55% rename from src/main/java/xyz/rc24/bot/commands/wii/DNS.java rename to src/main/java/xyz/rc24/bot/commands/wii/BlocksCommand.java index 26428cae..55072d98 100644 --- a/src/main/java/xyz/rc24/bot/commands/wii/DNS.java +++ b/src/main/java/xyz/rc24/bot/commands/wii/BlocksCommand.java @@ -24,37 +24,29 @@ package xyz.rc24.bot.commands.wii; -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.Permission; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.OptionMapping; import net.dv8tion.jda.api.interactions.commands.OptionType; -import net.dv8tion.jda.api.interactions.commands.build.OptionData; -import xyz.rc24.bot.commands.Categories; -import java.util.ArrayList; -import java.util.List; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import xyz.rc24.bot.commands.Command; -/** - * @author Spotlight - */ +public class BlocksCommand implements Command { -public class DNS extends SlashCommand -{ - public DNS() - { - this.name = "dns"; - this.help = "Lets you know the current DNS settings."; - this.category = Categories.WII; - this.botPermissions = new Permission[]{Permission.MESSAGE_WRITE}; - this.userPermissions = new Permission[]{Permission.MESSAGE_WRITE}; - this.guildOnly = false; + @Override + public void onCommand(SlashCommandInteractionEvent event) { + OptionMapping amountOption = event.getOption("amount"); + int blocks = amountOption == null ? 1 : amountOption.getAsInt(); + event.reply("ℹ " + blocks + " blocks are " + convertBlocks(blocks) + " MB").queue(); + } - List data = new ArrayList<>(); - this.options = data; - } + private float convertBlocks(float blocks) { + return (blocks * 128) / 1024; + } - @Override - protected void execute(SlashCommandEvent event) - { - event.reply("`167.86.108.126` should be your primary DNS.\n" + "`1.1.1.1` should be your secondary DNS.").setEphemeral(true).queue();; - } + @Override + public SlashCommandData getCommandData() { + return Commands.slash("blocks", "Convert blocks to MB") + .addOption(OptionType.NUMBER, "amount", "Amount of blocks"); + } } diff --git a/src/main/java/xyz/rc24/bot/commands/wii/CodeCmd.java b/src/main/java/xyz/rc24/bot/commands/wii/CodeCmd.java deleted file mode 100644 index 63c0fcfc..00000000 --- a/src/main/java/xyz/rc24/bot/commands/wii/CodeCmd.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.commands.wii; - -import com.jagrosh.jdautilities.command.SlashCommand; -import com.jagrosh.jdautilities.commons.waiter.EventWaiter; -import com.jagrosh.jdautilities.menu.ButtonMenu; -import com.jagrosh.jdautilities.menu.Paginator; -import net.dv8tion.jda.api.Permission; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.entities.ChannelType; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import net.dv8tion.jda.api.events.message.guild.react.GuildMessageReactionAddEvent; -import net.dv8tion.jda.api.interactions.commands.OptionType; -import net.dv8tion.jda.api.interactions.commands.build.OptionData; -import net.dv8tion.jda.api.exceptions.PermissionException; -import xyz.rc24.bot.Bot; -import xyz.rc24.bot.Const; -import xyz.rc24.bot.commands.Categories; -import xyz.rc24.bot.core.entities.CodeType; -import xyz.rc24.bot.core.entities.GuildSettings; -import xyz.rc24.bot.database.CodeDataManager; -import xyz.rc24.bot.utils.FormatUtil; -import xyz.rc24.bot.utils.SearcherUtil; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author Artuto - */ - -public class CodeCmd extends SlashCommand -{ - private final Bot bot; - private final CodeDataManager dataManager; - private final EventWaiter waiter; - - private final Pattern FULL_PATTERN = Pattern.compile("(\\w+)\\s+(.+?)\\s+((?:\\d{4}|SW)[-\\s]\\d{4}[-\\s]\\d{4}(?:[-\\s]\\d{4})?|\\w+)$", Pattern.MULTILINE); // thanks Dismissed - private final Pattern REMOVE_PATTERN = Pattern.compile("(\\w+)\\s+(.+?)$", Pattern.MULTILINE); - - public CodeCmd(Bot bot) - { - this.bot = bot; - this.dataManager = bot.getCodeDataManager(); - this.waiter = bot.waiter; - this.name = "code"; - this.help = "Manages friend codes for the user."; - this.category = Categories.WII; - this.guildOnly = false; - - List data = new ArrayList<>(); - data.add(new OptionData(OptionType.STRING, "cmd", "A valid subcommand (add, edit, remove, lookup, help).").setRequired(true)); - data.add(new OptionData(OptionType.STRING, "type", "A platform type.")); - data.add(new OptionData(OptionType.STRING, "name", "A name for the code.")); - data.add(new OptionData(OptionType.STRING, "code", "A friend code.")); - data.add(new OptionData(OptionType.USER, "user", "A user.")); - this.options = data; - } - - @Override - protected void execute(SlashCommandEvent event) - { - if (event.getOption("cmd").getAsString().equals("add")) - { - GuildSettings gs = getClient().getSettingsFor(event.getGuild()); - - CodeType type = CodeType.fromCode(event.getOption("type").getAsString()); - if(type == CodeType.UNKNOWN) - { - event.reply(FormatUtil.getCodeTypes()).setEphemeral(true).queue(); - return; - } - - Map codeTypes = bot.getCore().getCodesForType(type, event.getMember().getIdLong()); - if(codeTypes.containsKey(event.getOption("code").getAsString())) - { - event.reply("You already added this code!").setEphemeral(true).queue(); - return; - } - - if(dataManager.addCode(type, event.getMember().getIdLong(), event.getOption("code").getAsString(), event.getOption("name").getAsString())) - event.reply("Added a code for `" + event.getOption("name").getAsString() + "`").setEphemeral(true).queue(); - else - event.reply("Error whilst adding a code! Please contact a developer.").setEphemeral(true).queue(); - } - else if (event.getOption("cmd").getAsString().equals("edit")) - { - GuildSettings gs = getClient().getSettingsFor(event.getGuild()); - - CodeType type = CodeType.fromCode(event.getOption("type").getAsString()); - if(type == CodeType.UNKNOWN) - { - event.reply(FormatUtil.getCodeTypes()).setEphemeral(true).queue(); - return; - } - - Map codeTypes = bot.getCore().getCodesForType(type, event.getMember().getIdLong()); - if(!(codeTypes.containsKey(event.getOption("name").getAsString()))) - { - event.reply("A code for `" + event.getOption("name").getAsString() + "` is not registered.").setEphemeral(true).queue(); - return; - } - - if(dataManager.editCode(type, event.getMember().getIdLong(), event.getOption("code").getAsString(), event.getOption("name").getAsString())) - event.reply("Edited the code for `" + event.getOption("name").getAsString() + "`").setEphemeral(true).queue(); - else - event.reply("Error whilst editing a code! Please contact a developer.").setEphemeral(true).queue(); - } - else if (event.getOption("cmd").getAsString().equals("remove")) - { - GuildSettings gs = getClient().getSettingsFor(event.getGuild()); - - CodeType type = CodeType.fromCode(event.getOption("code").getAsString()); - if(type == CodeType.UNKNOWN) - { - event.reply(FormatUtil.getCodeTypes()).setEphemeral(true).queue(); - return; - } - - Map codeTypes = bot.getCore().getCodesForType(type, event.getMember().getIdLong()); - if(!(codeTypes.containsKey(event.getOption("name").getAsString()))) - { - event.reply("A code for `" + event.getOption("name").getAsString() + "` is not registered.").setEphemeral(true).queue(); - return; - } - - if(dataManager.removeCode(type, event.getMember().getIdLong(), event.getOption("name").getAsString())) - event.reply("Removed the code for `" + event.getOption("name").getAsString() + "`").setEphemeral(true).queue(); - else - event.reply("Error whilst removing a code! Please contact a developer.").setEphemeral(true).queue(); - } - else if (event.getOption("cmd").getAsString().equals("lookup")) - { - Member member; - - try { - member = event.getOption("user").getAsMember(); - } catch (Exception e) { - member = event.getMember(); - } - - String flag = bot.getCore().getFlag(member.getUser().getIdLong()); - boolean hasFlag = !(flag.isEmpty()); - EmbedBuilder codeEmbed = new EmbedBuilder() - .setAuthor("Profile for " + member.getEffectiveName(), - null, member.getUser().getEffectiveAvatarUrl()) - .setColor(member.getColor()); - - if(hasFlag) - codeEmbed.setTitle("Country: " + flag); - - Map> userCodes = bot.getCore().getAllCodes(member.getUser().getIdLong()); - for(Map.Entry> typeData : userCodes.entrySet()) - { - Map codes = typeData.getValue(); - if(!(codes.isEmpty())) - { - codeEmbed.addField(typeData.getKey().getFormattedName(), - FormatUtil.getCodeLayout(codes), true); - } - } - - if(codeEmbed.getFields().isEmpty()) - event.reply("**" + member.getEffectiveName() + "** has not added any codes!").setEphemeral(true).queue(); - else - event.replyEmbeds(codeEmbed.build()).queue(); - } - else if (event.getOption("cmd").getAsString().equals("help")) - { - String help = "**__Using the bot__**\n\n" + - "**Adding Wii:**\n" + "`/code add wii Wii Name Goes here 1234-5678-9012-3456`\n" + - "**Adding games:**\n `/code add game Game Name 1234-5678-9012`\n" + - "and many more types! Run `/code add` " + - "to see all supported code types right now, such as the 3DS, PlayStation 4 and Switch.\n\n" + - "**Editing codes**\n" + "`/code edit type Name 1234-5678-9012-3456`\n\n" + - "**Removing codes**\n" + "`/code remove type Name`\n\n" + - "**Looking up codes**\n" + "`/code lookup @user`\n\n" + - "**Adding a user's Wii**\n" + "`/add @user`\n" + "This will send you their wii, and then DM them your Wii/game wii."; - - - event.reply(help).queue(); - } - else { - event.reply("Please enter a valid option for the command.\n" + - "Valid subcommands: `add`, `edit`, `remove`, `lookup`, `help`.").setEphemeral(true).queue(); - } - } -} diff --git a/src/main/java/xyz/rc24/bot/commands/wii/CodeCommand.java b/src/main/java/xyz/rc24/bot/commands/wii/CodeCommand.java new file mode 100644 index 00000000..c3f776d0 --- /dev/null +++ b/src/main/java/xyz/rc24/bot/commands/wii/CodeCommand.java @@ -0,0 +1,192 @@ +/* + * MIT License + * + * Copyright (c) 2017-2020 RiiConnect24 and its contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package xyz.rc24.bot.commands.wii; + +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.OptionType; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import net.dv8tion.jda.api.interactions.commands.build.SubcommandData; +import net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData; +import xyz.rc24.bot.Bot; +import xyz.rc24.bot.RiiConnect24Bot; +import xyz.rc24.bot.commands.Command; +import xyz.rc24.bot.core.BotCore; +import xyz.rc24.bot.core.entities.CodeType; +import xyz.rc24.bot.core.entities.Flag; +import xyz.rc24.bot.database.CodeDataManager; +import xyz.rc24.bot.utils.FormatUtil; + +import java.util.Map; + +/** + * @author Gamebuster + */ + +public class CodeCommand implements Command { + + private static final Bot BOT = RiiConnect24Bot.getInstance(); + private static final BotCore CORE = RiiConnect24Bot.getInstance().getCore(); + private static final CodeDataManager CODE_MANAGER = BOT.getCodeDataManager(); + + @Override + public void onCommand(SlashCommandInteractionEvent event) { + + String subcommandGroup = event.getSubcommandGroup(); + + if (subcommandGroup == null) { + if (event.getSubcommandName().equals("lookup")) { + + User user = event.getOption("user").getAsUser(); + Flag flag = CORE.getFlag(user.getIdLong()); + boolean hasFlag = flag != null; + String name = user.getEffectiveName(); + + EmbedBuilder embed = new EmbedBuilder(); + embed.setAuthor("Profile for " + name, null, user.getEffectiveAvatarUrl()); + + if (hasFlag) embed.setTitle("Country: " + flag); + + Map> userCodes = CORE.getAllCodes(user.getIdLong()); + for (Map.Entry> typeData : userCodes.entrySet()) { + Map codes = typeData.getValue(); + if (!(codes.isEmpty())) { + embed.addField(typeData.getKey().getFormattedName(), FormatUtil.getCodeLayout(codes), true); + } + } + if (embed.getFields().isEmpty()) { + event.reply("**" + name + "** has not added any codes!").setEphemeral(true).queue(); + return; + } + + event.replyEmbeds(embed.build()).setEphemeral(true).queue(); + + } + return; + } + + switch (subcommandGroup) { + + case "add" -> { + + String subcommand = event.getSubcommandName(); + CodeType codeType = CodeType.fromCode(subcommand); + long authorId = event.getMember().getIdLong(); + Map codeTypes = CORE.getCodesForType(codeType, authorId); + String code = event.getOption("code").getAsString(); + + if (codeTypes.containsKey(code)) { + event.reply("You already added this code!").setEphemeral(true).queue(); + return; + } + + String name = event.getOption("name").getAsString(); + + if (CODE_MANAGER.addCode(codeType, authorId, code, name)) { + event.replyFormat("Added a code for %s. \n\nName:%s\nCode:`%s`", codeType.getDisplayName(), name, code).queue(); + } else { + event.reply("Error whilst adding a code! Please contact a developer.").setEphemeral(true).queue(); + } + + } + case "edit" -> { + + String subcommand = event.getSubcommandName(); + CodeType codeType = CodeType.fromCode(subcommand); + long authorId = event.getMember().getIdLong(); + Map codeTypes = CORE.getCodesForType(codeType, authorId); + String code = event.getOption("code").getAsString(); + String name = event.getOption("name").getAsString(); + + if (!(codeTypes.containsKey(name))) { + event.reply("A code for `" + name + "` is not registered.").setEphemeral(true).queue(); + return; + } + + if (CODE_MANAGER.editCode(codeType, authorId, code, name)) { + event.reply("Edited the code for `" + name + "`").setEphemeral(true).queue(); + } else { + event.reply("Error whilst editing a code! Please contact a developer.").setEphemeral(true).queue(); + } + + } + + case "remove" -> { + + String subcommand = event.getSubcommandName(); + CodeType codeType = CodeType.fromCode(subcommand); + long authorId = event.getMember().getIdLong(); + Map codeTypes = CORE.getCodesForType(codeType, authorId); + String name = event.getOption("name").getAsString(); + + if (!(codeTypes.containsKey(name))) { + event.reply("A code for `" + name + "` is not registered.").setEphemeral(true).queue(); + return; + } + + if (CODE_MANAGER.removeCode(codeType, authorId, name)) { + event.reply("Removed the code for `" + name + "`").setEphemeral(true).queue(); + } else { + event.reply("Error whilst removing a code! Please contact a developer.").setEphemeral(true).queue(); + } + + } + } + } + + @Override + public SlashCommandData getCommandData() { + + SubcommandGroupData subcommandGroupAdd = new SubcommandGroupData("add", "Add a code"); + SubcommandGroupData subcommandGroupEdit = new SubcommandGroupData("edit", "Edit a code"); + + for (CodeType codeType : CodeType.values()) { + if (codeType != null) { + subcommandGroupAdd.addSubcommands(new SubcommandData(codeType.getName(), codeType.getDisplayName()) + .addOption(OptionType.STRING, "name", "Name of the " + codeType.getDisplayName(), true) + .addOption(OptionType.STRING, "code", "Code of the " + codeType.getDisplayName(), true)); + subcommandGroupEdit.addSubcommands(new SubcommandData(codeType.getName(), codeType.getDisplayName()) + .addOption(OptionType.STRING, "name", "Name of the " + codeType.getDisplayName(), true) + .addOption(OptionType.STRING, "code", "Code of the " + codeType.getDisplayName(), true)); + } + } + + SubcommandGroupData subcommandGroupRemove = new SubcommandGroupData("remove", "Remove a code"); + for (CodeType codeType : CodeType.values()) { + if (codeType != null) { + subcommandGroupRemove.addSubcommands(new SubcommandData(codeType.getName(), codeType.getDisplayName()) + .addOption(OptionType.STRING, "name", "Name of the " + codeType.getDisplayName(), true)); + } + } + + SubcommandData subcommandLookup = new SubcommandData("lookup", "Look up an user's codes") + .addOption(OptionType.USER, "user", "User", true); + + return Commands.slash("code", "Manages your friend codes").addSubcommandGroups(subcommandGroupAdd, subcommandGroupRemove, subcommandGroupEdit).addSubcommands(subcommandLookup); + } + +} diff --git a/src/main/java/xyz/rc24/bot/commands/wii/WiiWare.java b/src/main/java/xyz/rc24/bot/commands/wii/DNSCommand.java similarity index 59% rename from src/main/java/xyz/rc24/bot/commands/wii/WiiWare.java rename to src/main/java/xyz/rc24/bot/commands/wii/DNSCommand.java index 90663808..ca9d0ee1 100644 --- a/src/main/java/xyz/rc24/bot/commands/wii/WiiWare.java +++ b/src/main/java/xyz/rc24/bot/commands/wii/DNSCommand.java @@ -24,30 +24,27 @@ package xyz.rc24.bot.commands.wii; -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import net.dv8tion.jda.api.Permission; -import xyz.rc24.bot.commands.Categories; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import xyz.rc24.bot.commands.Command; /** - * @author Artuto + * @author Gamebuster */ -public class WiiWare extends SlashCommand -{ - public WiiWare() - { - this.name = "wiiware"; - this.help = "Lets you know the URL to the WiiWare patcher."; - this.category = Categories.WII; - this.botPermissions = new Permission[]{Permission.MESSAGE_WRITE}; - this.userPermissions = new Permission[]{Permission.MESSAGE_WRITE}; - this.guildOnly = false; - } +public class DNSCommand implements Command { + + private static final String PRIMARY_DNS = "167.86.108.126"; + private static final String SECONDARY_DNS = "1.1.1.1"; - @Override - protected void execute(SlashCommandEvent event) - { - event.reply("Check out the patcher here: https://github.com/RiiConnect24/auto-wiiware-patcher/releases").queue(); - } + @Override + public void onCommand(SlashCommandInteractionEvent event) { + event.replyFormat("`%s` should be your primary DNS.\n`%s` should be your secondary DNS.", PRIMARY_DNS, SECONDARY_DNS).queue(); + } + + @Override + public SlashCommandData getCommandData() { + return Commands.slash("dns", "Lets you know the current DNS settings required to use RiiConnect24."); + } } diff --git a/src/main/java/xyz/rc24/bot/commands/wii/ErrorInfoCmd.java b/src/main/java/xyz/rc24/bot/commands/wii/ErrorInfoCommand.java similarity index 59% rename from src/main/java/xyz/rc24/bot/commands/wii/ErrorInfoCmd.java rename to src/main/java/xyz/rc24/bot/commands/wii/ErrorInfoCommand.java index dfbf75b5..fd27d301 100644 --- a/src/main/java/xyz/rc24/bot/commands/wii/ErrorInfoCmd.java +++ b/src/main/java/xyz/rc24/bot/commands/wii/ErrorInfoCommand.java @@ -24,33 +24,26 @@ package xyz.rc24.bot.commands.wii; -import ch.qos.logback.classic.Logger; import com.google.gson.Gson; import com.google.gson.annotations.SerializedName; -import com.jagrosh.jdautilities.command.SlashCommand; import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.commands.OptionType; +import net.dv8tion.jda.api.interactions.commands.build.Commands; import net.dv8tion.jda.api.interactions.commands.build.OptionData; -import net.dv8tion.jda.api.Permission; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import okhttp3.*; import org.jetbrains.annotations.NotNull; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; -import xyz.rc24.bot.Bot; +import org.slf4j.Logger; import xyz.rc24.bot.RiiConnect24Bot; -import xyz.rc24.bot.commands.Categories; +import xyz.rc24.bot.commands.Command; -import java.awt.Color; +import java.awt.*; import java.io.IOException; import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; @@ -59,92 +52,84 @@ /** * Looks up errors using the Wiimmfi API. * - * @author Spotlight, Artuto + * @author Spotlight, Artuto, Gamebuster */ -public class ErrorInfoCmd extends SlashCommand -{ - private final boolean debug; - private final OkHttpClient httpClient; - - private final Pattern CHANNEL = Pattern.compile("(NEWS|FORE)0{4}\\d{2}", Pattern.CASE_INSENSITIVE); - private final Pattern CHANNEL_CODE = Pattern.compile("0{4}\\d{2}"); - - private final Pattern CODE = Pattern.compile("\\d{1,6}"); - - private final Gson gson = new Gson(); - private final Logger logger = RiiConnect24Bot.getLogger(ErrorInfoCmd.class); - - public ErrorInfoCmd(Bot bot) - { - this.debug = bot.getConfig().isDebug(); - this.httpClient = bot.getHttpClient(); - this.name = "error"; - this.help = "Looks up errors using the Wiimmfi API."; - this.category = Categories.WII; - this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS}; - this.guildOnly = false; - - List data = new ArrayList<>(); - data.add(new OptionData(OptionType.STRING, "code", "The error code.")); - this.options = data; - } +public class ErrorInfoCommand implements Command { + + private static final boolean debug = RiiConnect24Bot.getInstance().getConfig().isDebug(); + private static final OkHttpClient httpClient = RiiConnect24Bot.getInstance().getHttpClient(); + private static final Pattern CHANNEL = Pattern.compile("(NEWS|FORE)0{4}\\d{2}", Pattern.CASE_INSENSITIVE); + private static final Pattern CHANNEL_CODE = Pattern.compile("0{4}\\d{2}"); + private static final Pattern CODE = Pattern.compile("\\d{1,6}"); + private static final Gson gson = new Gson(); + private static final Logger logger = RiiConnect24Bot.getLogger(ErrorInfoCommand.class); @Override - protected void execute(SlashCommandEvent event) - { - Matcher channelCheck = CHANNEL.matcher(event.getOption("code").getAsString()); + public void onCommand(SlashCommandInteractionEvent event) { + + String code = event.getOption("code").getAsString(); + Matcher channelCheck = CHANNEL.matcher(code); // Check for Fore/News - if(channelCheck.find()) - { + if (channelCheck.find()) { + // First match will be the type, then second our actual code. - int code; - try - { + int codeNum; + try { + // Make sure the code's actually a code. Matcher codeCheck = CHANNEL_CODE.matcher(channelCheck.group()); - if(!(codeCheck.find())) - throw new NumberFormatException(); + if (!(codeCheck.find())) { + event.reply("Invalid error code provided").setEphemeral(true).queue(); + return; + } - code = Integer.parseInt(codeCheck.group(0)); - if(channelErrors.get(code) == null) - throw new NumberFormatException(); - } - catch(NumberFormatException ignored) - { - event.reply("Could not find the specified app error code.").queue(); + codeNum = Integer.parseInt(codeCheck.group(0)); + + if (channelErrors.get(codeNum) == null) { + event.reply("Invalid error code provided").setEphemeral(true).queue(); + return; + } + + } catch (NumberFormatException e) { + event.reply("Could not find the specified app error code.").setEphemeral(true).queue(); return; } - EmbedBuilder builder = new EmbedBuilder(); - builder.setTitle("Here's information about your error:"); - builder.setDescription(channelErrors.get(code)); - builder.setColor(Color.decode("#D32F2F")); - builder.setFooter("All information provided by RC24 Developers.", null); - event.replyEmbeds(builder.build()).setEphemeral(true).queue(); - } - else - { - int code; - try - { + String title = "Here's information about your error:"; + String description = channelErrors.get(codeNum); + String footer = "All information provided by RC24 Developers."; + + EmbedBuilder builder = new EmbedBuilder(); + builder.setTitle(title); + builder.setDescription(description); + builder.setColor(0xD32F2F); + builder.setFooter(footer, null); + event.replyEmbeds(builder.build()).queue(); + + } else { + + int codeNum; + try { + // Validate if it is a number. - Matcher codeCheck = CODE.matcher(event.getOption("code").getAsString()); - if(!(codeCheck.find())) - throw new NumberFormatException(); - - code = Integer.parseInt(codeCheck.group(0)); - if(code == 0) - { + Matcher codeCheck = CODE.matcher(code); + if (!(codeCheck.find())) { + event.reply("Invalid error code provided").setEphemeral(true).queue(); + return; + } + + codeNum = Integer.parseInt(codeCheck.group(0)); + if (codeNum == 0) { // 0 returns an empty array (see https://forum.wii-homebrew.com/index.php/Thread/57051-Wiimmfi-Error-API-has-an-error/?postID=680936) // We'll just treat it as an error. - throw new NumberFormatException(); - } - } - catch(NumberFormatException ignored) - { - event.reply("Enter a valid error code!").setEphemeral(true).queue(); + event.reply("Invalid error code provided").setEphemeral(true).queue(); + return; + } + + } catch (NumberFormatException e) { + event.reply("Could not find the specified app error code.").setEphemeral(true).queue(); return; } @@ -152,92 +137,99 @@ protected void execute(SlashCommandEvent event) String method = (debug ? "t=" : "e=") + code; String url = "https://wiimmfi.de/error?" + method + "&m=json"; - if(debug) - logger.info("Sending request to '{}'", url); + if (debug) logger.info("Sending request to '{}'", url); Request request = new Request.Builder().url(url).build(); - httpClient.newCall(request).enqueue(new Callback() - { + httpClient.newCall(request).enqueue(new Callback() { + @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) - { - event.reply("Hm, something went wrong on our end. Check Wiimmfi's website is up?").setEphemeral(true).queue();; - logger.error("Something went wrong whilst checking error code '" + code + - "' with Wiimmfi: {}", e.getMessage(), e); + public void onFailure(@NotNull Call call, @NotNull IOException e) { + event.reply("Hm, something went wrong on our end. Check Wiimmfi's website is up?").setEphemeral(true).queue(); + logger.error("Something went wrong whilst checking error code '{}' with Wiimmfi: {}", code, e.getMessage(), e); } @Override - public void onResponse(@NotNull Call call, @NotNull Response response) - { - if(!(response.isSuccessful())) - { + public void onResponse(@NotNull Call call, @NotNull Response response) { + + if (!(response.isSuccessful())) { onFailure(call, new IOException("Not success response code: " + response.code())); response.close(); return; } - success(event, response); - response.close(); - } - }); - } - } + try (response) { - @SuppressWarnings("ConstantConditions") // Response body can't be null at this point of the execution - private void success(@NotNull SlashCommandEvent event, @NotNull Response response) - { - JSONFormat json = gson.fromJson(new InputStreamReader(response.body().byteStream()), JSONFormat[].class)[0]; - if(!(json.found == 1)) - { - event.reply("Could not find the specified error from Wiimmfi.").setEphemeral(true).queue();; - return; - } + String description; + JSONFormat json = gson.fromJson(new InputStreamReader(response.body().byteStream()), JSONFormat[].class)[0]; + boolean success = json.found == 1; + EmbedBuilder embed = new EmbedBuilder(); - StringBuilder infoBuilder = new StringBuilder(); - for(InfoListFormat format : json.infolists) - { - String htmlToMarkdown = format.info; - Document infoSegment = Jsoup.parseBodyFragment(htmlToMarkdown); - - // Replace links with markdown format - for(Element hRef : infoSegment.select("a[href]")) - { - // So, we have to transform & back to &. - // It's funny, the same issue happened with Nokogiri and Ruby. - String realOuterHTML = hRef.outerHtml(); - realOuterHTML = realOuterHTML.replace("&", "&"); - htmlToMarkdown = htmlToMarkdown.replace(realOuterHTML, "[" + hRef.text() + "](" + hRef.attr("href") + ")"); - } + if (!success) { + embed.setColor(Color.RED); + embed.setDescription("Could not find the specified error from Wiimmfi."); + return; + } else { - // Parse again to handle updates - infoSegment = Jsoup.parseBodyFragment(htmlToMarkdown); - for(Element bold : infoSegment.select("b")) - htmlToMarkdown = htmlToMarkdown.replace(bold.outerHtml(), "**" + bold.text() + "**"); + StringBuilder infoBuilder = new StringBuilder(); - // ...and parse, once more. - infoSegment = Jsoup.parseBodyFragment(htmlToMarkdown); - for(Element italics : infoSegment.select("i")) - htmlToMarkdown = htmlToMarkdown.replace(italics.outerHtml(), "*" + italics.text() + "*"); + for (InfoListFormat format : json.infolists) { - infoBuilder.append(format.type).append(" for error ").append(format.name).append(": ").append(htmlToMarkdown).append("\n"); - } + String htmlToMarkdown = format.info; + Document infoSegment = Jsoup.parseBodyFragment(htmlToMarkdown); + + // Replace links with Markdown format + for (Element hRef : infoSegment.select("a[href]")) { + // So, we have to transform & back to &. + // It's funny, the same issue happened with Nokogiri and Ruby. + String realOuterHTML = hRef.outerHtml(); + realOuterHTML = realOuterHTML.replace("&", "&"); + htmlToMarkdown = htmlToMarkdown.replace(realOuterHTML, "[" + hRef.text() + "](" + hRef.attr("href") + ")"); + } + + // Parse again to handle updates + infoSegment = Jsoup.parseBodyFragment(htmlToMarkdown); + for (Element bold : infoSegment.select("b")) + htmlToMarkdown = htmlToMarkdown.replace(bold.outerHtml(), "**" + bold.text() + "**"); + + // ...and parse, once more. + infoSegment = Jsoup.parseBodyFragment(htmlToMarkdown); + for (Element italics : infoSegment.select("i")) + htmlToMarkdown = htmlToMarkdown.replace(italics.outerHtml(), "*" + italics.text() + "*"); + + infoBuilder.append(format.type).append(" for error ").append(format.name).append(": ").append(htmlToMarkdown).append("\n"); + } - // Check for dev note - if(codeNotes.containsKey(json.error) && !codeNotes.containsKey(json.error)) - infoBuilder.append("Note from RiiConnect24: ").append(codeNotes.get(json.error)); + // Check for dev note + if (codeNotes.containsKey(json.error) && !codeNotes.containsKey(json.error)) + infoBuilder.append("Note from RiiConnect24: ").append(codeNotes.get(json.error)); - EmbedBuilder builder = new EmbedBuilder(); - builder.setTitle("Here's information about your error:"); - builder.setDescription(infoBuilder.toString()); - builder.setColor(Color.decode("#D32F2F")); - builder.setFooter("All information is from Wiimmfi unless noted.", null); + String title = "Here's information about your error:"; + description = infoBuilder.toString(); + String footer = "All information is from Wiimmfi unless noted."; + embed.setTitle(title); + embed.setDescription(description); + embed.setColor(Color.decode("#D32F2F")); + embed.setFooter(footer, null); + event.replyEmbeds(embed.build()).queue(); + } - event.replyEmbeds(builder.build()).queue(); - response.close(); + } finally { + response.close(); + } + + response.close(); + } + }); + } } - private class JSONFormat - { + @Override + public SlashCommandData getCommandData() { + return Commands.slash("error", "Provides information about Wii error codes using the Wiimmfi API.") + .addOptions(new OptionData(OptionType.STRING, "code", "Error Code", true)); + } + + private static final class JSONFormat { @SerializedName("error") int error; @SerializedName("found") @@ -246,8 +238,7 @@ private class JSONFormat InfoListFormat[] infolists; } - private class InfoListFormat - { + private static final class InfoListFormat { @SerializedName("type") String type; @SerializedName("name") @@ -256,8 +247,7 @@ private class InfoListFormat String info; } - private final Map channelErrors = new HashMap<>() - {{ + private static final Map channelErrors = new HashMap<>() {{ put(1, "Can't open the VFF. Follow https://wii.guide/deleting-vffs to fix it."); put(2, "Seems to happen when there is a problem with one of the files on the NAND. " + "If you're getting it after fixing NEWS/FORE000006, do a connection test to fix it."); put(3, "VFF file corrupted. Follow https://wii.guide/deleting-vffs to fix it."); @@ -267,8 +257,7 @@ private class InfoListFormat put(99, "Other error. Follow https://wii.guide/deleting-vffs to potentially fix it."); }}; - private final Map codeNotes = new HashMap<>() - {{ + private static final Map codeNotes = new HashMap<>() {{ put(101409, "If you are getting this error while doing something with Wii Mail, check if you patched the nwc24msg.cfg correctly using the Mail-Patcher. https://bit.ly/2QUrsyD"); put(102032, "This error shouldn't happen anymore as we have implemented the challenge response that prevents the error from happening."); put(102409, "If you are getting this error while doing something with Wii Mail, check if you patched the nwc24msg.cfg correctly using the Mail-Patcher. https://bit.ly/2QUrsyD"); @@ -305,4 +294,5 @@ private class InfoListFormat put(52031, "Try changing your router's settings to use 802.11 b/g/n. If that doesn't work, try the suggestions found on Nintendo's site. https://bit.ly/2OoC0c2"); put(52032, "Try changing your router's settings to use 802.11 b/g/n. If that doesn't work, try the suggestions found on Nintendo's site. https://bit.ly/2OoC0c2"); }}; + } diff --git a/src/main/java/xyz/rc24/bot/commands/Categories.java b/src/main/java/xyz/rc24/bot/commands/wii/WadsCommand.java similarity index 62% rename from src/main/java/xyz/rc24/bot/commands/Categories.java rename to src/main/java/xyz/rc24/bot/commands/wii/WadsCommand.java index 375bbc68..97851528 100644 --- a/src/main/java/xyz/rc24/bot/commands/Categories.java +++ b/src/main/java/xyz/rc24/bot/commands/wii/WadsCommand.java @@ -22,20 +22,22 @@ * SOFTWARE. */ -package xyz.rc24.bot.commands; +package xyz.rc24.bot.commands.wii; -import com.jagrosh.jdautilities.command.Command.Category; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import xyz.rc24.bot.commands.Command; -/** - * Command categories - * - * @author Artuto - */ +public class WadsCommand implements Command { + + @Override + public void onCommand(SlashCommandInteractionEvent event) { + event.reply("Check out the patcher here: https://github.com/RiiConnect24/RiiConnect24-Patcher/releases/latest").queue(); + } -public class Categories -{ - public static final Category ADMIN = new Category("Bot Administration"); - public static final Category GENERAL = new Category("General"); - public static final Category TOOLS = new Category("Tools"); - public static final Category WII = new Category("Wii-related"); -} \ No newline at end of file + @Override + public SlashCommandData getCommandData() { + return Commands.slash("wads", "Lets you know the URL to the RiiConnect24 Patcher."); + } +} diff --git a/src/main/java/xyz/rc24/bot/commands/wii/WadsCmd.java b/src/main/java/xyz/rc24/bot/commands/wii/WiiWareCommand.java similarity index 65% rename from src/main/java/xyz/rc24/bot/commands/wii/WadsCmd.java rename to src/main/java/xyz/rc24/bot/commands/wii/WiiWareCommand.java index ac3f9bc7..1c808572 100644 --- a/src/main/java/xyz/rc24/bot/commands/wii/WadsCmd.java +++ b/src/main/java/xyz/rc24/bot/commands/wii/WiiWareCommand.java @@ -24,27 +24,20 @@ package xyz.rc24.bot.commands.wii; -import com.jagrosh.jdautilities.command.SlashCommand; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import xyz.rc24.bot.commands.Categories; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import xyz.rc24.bot.commands.Command; -/** - * @author Artuto - */ +public class WiiWareCommand implements Command { -public class WadsCmd extends SlashCommand -{ - public WadsCmd() - { - this.name = "wads"; - this.help = "Lets you know the URL to the RiiConnect24 Patcher."; - this.category = Categories.WII; - this.guildOnly = false; - } + @Override + public void onCommand(SlashCommandInteractionEvent event) { + event.reply("Check out the patcher here: https://github.com/RiiConnect24/auto-wiiware-patcher/releases").queue(); + } - @Override - protected void execute(SlashCommandEvent event) - { - event.reply("Check out the patcher here: https://github.com/RiiConnect24/RiiConnect24-Patcher/releases/latest").queue(); - } + @Override + public SlashCommandData getCommandData() { + return Commands.slash("wiiware", "Lets you know the URL to the WiiWare patcher."); + } } diff --git a/src/main/java/xyz/rc24/bot/core/BotCore.java b/src/main/java/xyz/rc24/bot/core/BotCore.java index 9c80a5a5..893b7d42 100644 --- a/src/main/java/xyz/rc24/bot/core/BotCore.java +++ b/src/main/java/xyz/rc24/bot/core/BotCore.java @@ -26,6 +26,7 @@ import net.dv8tion.jda.api.entities.Guild; import xyz.rc24.bot.core.entities.CodeType; +import xyz.rc24.bot.core.entities.Flag; import xyz.rc24.bot.core.entities.GuildSettings; import java.util.Map; @@ -41,5 +42,5 @@ public interface BotCore Map getCodesForType(CodeType type, long user); - String getFlag(long user); + Flag getFlag(long user); } diff --git a/src/main/java/xyz/rc24/bot/core/entities/CodeType.java b/src/main/java/xyz/rc24/bot/core/entities/CodeType.java index 90751e0b..7494fb03 100644 --- a/src/main/java/xyz/rc24/bot/core/entities/CodeType.java +++ b/src/main/java/xyz/rc24/bot/core/entities/CodeType.java @@ -37,9 +37,7 @@ public enum CodeType PSN(2, "psn", "PlayStation Network", "545097818319224832", "**PlayStation Network ID**", "psn"), SWITCH(3, "switch", "Switch", "287652338791874560", "**Switch**", "switch"), THREEDS(4, "threeds", "3DS", "287651327763283968", "**3DS**", "3ds"), - WII(5, "wii", "Wii", "259081748007223296", "**Wii**", "wii"), - - UNKNOWN(-1, null, null, null, null, null); + WII(5, "wii", "Wii", "259081748007223296", "**Wii**", "wii"); private final int id; private final String column, displayName, emote, formattedName, name; @@ -92,7 +90,7 @@ public static CodeType fromCode(String code) return type; } - return UNKNOWN; + return null; } public static CodeType fromEmote(String emote) @@ -103,7 +101,7 @@ public static CodeType fromEmote(String emote) return type; } - return UNKNOWN; + return null; } public static CodeType fromId(int id) @@ -114,6 +112,6 @@ public static CodeType fromId(int id) return type; } - return UNKNOWN; + return null; } } diff --git a/src/main/java/xyz/rc24/bot/core/entities/Flag.java b/src/main/java/xyz/rc24/bot/core/entities/Flag.java index 4b1cbcd8..d108d8e7 100644 --- a/src/main/java/xyz/rc24/bot/core/entities/Flag.java +++ b/src/main/java/xyz/rc24/bot/core/entities/Flag.java @@ -25,10 +25,8 @@ package xyz.rc24.bot.core.entities; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -public enum Flag -{ +public enum Flag { AFGHANISTAN("\uD83C\uDDE6\uD83C\uDDEB", "Afghanistan"), ALAND_ISLANDS("\uD83C\uDDE6\uD83C\uDDFD", "Aland Islands"), ALBANIA("\uD83C\uDDE6\uD83C\uDDF1", "Albania"), @@ -292,39 +290,44 @@ public enum Flag WESTERN_SAHARA("\uD83C\uDDEA\uD83C\uDDED", "Western Sahara"), YEMEN("\uD83C\uDDFE\uD83C\uDDEA", "Yemen"), ZAMBIA("\uD83C\uDDFF\uD83C\uDDF2", "Zambia"), - ZIMBABWE("\uD83C\uDDFF\uD83C\uDDFC", "Zimbabwe"), - - UNKNOWN(null, null); + ZIMBABWE("\uD83C\uDDFF\uD83C\uDDFC", "Zimbabwe"); private final String emote, name; - Flag(String emote, String name) - { + Flag(String emote, String name) { this.emote = emote; this.name = name; } - @Nullable - public String getEmote() - { + public String getEmote() { return emote; } - @Nullable - public String getName() - { + public String getName() { return name; } - @NotNull - public static Flag fromName(@NotNull String name) - { - for(Flag flag : values()) - { - if(!(flag.getName() == null) && name.toLowerCase().equals(flag.getName().toLowerCase())) + public static Flag fromEmoji(String emote) { + if (emote != null) { + for (Flag flag : values()) { + if (emote.equals(flag.emote)) { + return flag; + } + } + } + return null; + } + + public static Flag fromName(@NotNull String name) { + for (Flag flag : values()) { + if (!(flag.getName() == null) && name.toLowerCase().equals(flag.getName().toLowerCase())) return flag; } - return UNKNOWN; + return null; + } + + public String toString() { + return emote + " " + name; } } diff --git a/src/main/java/xyz/rc24/bot/core/entities/impl/BotCoreImpl.java b/src/main/java/xyz/rc24/bot/core/entities/impl/BotCoreImpl.java index 8ee30c63..71019955 100644 --- a/src/main/java/xyz/rc24/bot/core/entities/impl/BotCoreImpl.java +++ b/src/main/java/xyz/rc24/bot/core/entities/impl/BotCoreImpl.java @@ -32,6 +32,7 @@ import xyz.rc24.bot.core.SimpleCacheBuilder; import xyz.rc24.bot.core.entities.CodeType; import xyz.rc24.bot.core.entities.EntityBuilder; +import xyz.rc24.bot.core.entities.Flag; import xyz.rc24.bot.core.entities.GuildSettings; import java.util.Collections; @@ -111,17 +112,17 @@ public Map getCodesForType(CodeType type, long user) } @Override - public String getFlag(long user) + public Flag getFlag(long user) { try { - return flagCache.get(user, () -> bot.getCodeDataManager().getFlag(user)); + return Flag.fromName(flagCache.get(user, () -> bot.getCodeDataManager().getFlag(user))); } catch(ExecutionException e) { RiiConnect24Bot.getLogger().error("Error whilst getting flag for User {}: {}", user, e.getMessage(), e); - return ""; + return null; } } diff --git a/src/main/java/xyz/rc24/bot/core/entities/impl/GuildSettingsImpl.java b/src/main/java/xyz/rc24/bot/core/entities/impl/GuildSettingsImpl.java index d5308d6b..387cdf38 100644 --- a/src/main/java/xyz/rc24/bot/core/entities/impl/GuildSettingsImpl.java +++ b/src/main/java/xyz/rc24/bot/core/entities/impl/GuildSettingsImpl.java @@ -24,7 +24,6 @@ package xyz.rc24.bot.core.entities.impl; -import com.jagrosh.jdautilities.command.GuildSettingsProvider; import xyz.rc24.bot.RiiConnect24Bot; import xyz.rc24.bot.core.entities.CodeType; import xyz.rc24.bot.core.entities.GuildSettings; @@ -33,7 +32,7 @@ import java.util.Collection; import java.util.Collections; -public class GuildSettingsImpl implements GuildSettings, GuildSettingsProvider +public class GuildSettingsImpl implements GuildSettings { private CodeType defaultAddType; private long guildId; @@ -65,7 +64,6 @@ public String getPrefix() } @Nullable - @Override public Collection getPrefixes() { return Collections.singleton(getPrefix()); diff --git a/src/main/java/xyz/rc24/bot/database/CodeDataManager.java b/src/main/java/xyz/rc24/bot/database/CodeDataManager.java index b69386bf..2c72d787 100644 --- a/src/main/java/xyz/rc24/bot/database/CodeDataManager.java +++ b/src/main/java/xyz/rc24/bot/database/CodeDataManager.java @@ -64,7 +64,7 @@ public Map> getAllCodes(long user) for(CodeType type : CodeType.values()) { - if(type == CodeType.UNKNOWN) + if(type == null) continue; Map typeMap = gson.fromJson(row.getString(type.getColumn(), ""), Map.class); @@ -115,7 +115,7 @@ public boolean removeCode(CodeType type, long id, String name) public String getFlag(long user) { - Optional optRow = db.getRow("SELECT * FROM codes WHERE user_id = ?", user); + Optional optRow = db.getRow("SELECT flag FROM codes WHERE user_id = ?", user); return optRow.map(dbRow -> dbRow.getString("flag")).orElse(""); } diff --git a/src/main/java/xyz/rc24/bot/database/Database.java b/src/main/java/xyz/rc24/bot/database/Database.java index cbb00c3e..07022ad2 100644 --- a/src/main/java/xyz/rc24/bot/database/Database.java +++ b/src/main/java/xyz/rc24/bot/database/Database.java @@ -24,10 +24,11 @@ package xyz.rc24.bot.database; -import ch.qos.logback.classic.Logger; import co.aikar.idb.DB; import co.aikar.idb.DbRow; import org.intellij.lang.annotations.Language; +import org.slf4j.Logger; + import xyz.rc24.bot.RiiConnect24Bot; import java.util.List; diff --git a/src/main/java/xyz/rc24/bot/database/GuildSettingsDataManager.java b/src/main/java/xyz/rc24/bot/database/GuildSettingsDataManager.java index 206c53e6..a8468ac0 100644 --- a/src/main/java/xyz/rc24/bot/database/GuildSettingsDataManager.java +++ b/src/main/java/xyz/rc24/bot/database/GuildSettingsDataManager.java @@ -25,7 +25,6 @@ package xyz.rc24.bot.database; import co.aikar.idb.DbRow; -import com.jagrosh.jdautilities.command.GuildSettingsManager; import net.dv8tion.jda.api.entities.Guild; import xyz.rc24.bot.Bot; import xyz.rc24.bot.RiiConnect24Bot; @@ -45,8 +44,7 @@ * @author Artuto */ -public class GuildSettingsDataManager implements GuildSettingsManager -{ +public class GuildSettingsDataManager { private Bot bot; private final EntityBuilder entityBuilder; @@ -58,14 +56,12 @@ public GuildSettingsDataManager(Bot bot) this.entityBuilder = ((BotCoreImpl) bot.getCore()).getEntityBuilder(); } - @Override public void init() { this.bot = RiiConnect24Bot.getInstance(); } @Nullable - @Override public GuildSettings getSettings(Guild guild) { return getSettings(guild.getIdLong()); @@ -80,8 +76,6 @@ public GuildSettings getGuildSettings(long id) public boolean setDefaultAddType(CodeType type, long id) { - ((GuildSettingsImpl) Objects.requireNonNull(getSettings(id))).setDefaultAddType(type); - return db.doInsert("INSERT INTO settings (guild_id, default_add)" + "VALUES(?, ?) ON DUPLICATE KEY UPDATE default_add = ?", id, type.getId(), type.getId()); } diff --git a/src/main/java/xyz/rc24/bot/listeners/DataDogStatsListener.java b/src/main/java/xyz/rc24/bot/listeners/DataDogStatsListener.java index b7a21750..3d281706 100644 --- a/src/main/java/xyz/rc24/bot/listeners/DataDogStatsListener.java +++ b/src/main/java/xyz/rc24/bot/listeners/DataDogStatsListener.java @@ -24,38 +24,26 @@ package xyz.rc24.bot.listeners; -import com.jagrosh.jdautilities.command.Command; -import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.jdautilities.command.CommandListener; import com.timgroup.statsd.StatsDClient; import net.dv8tion.jda.api.events.guild.GuildJoinEvent; import net.dv8tion.jda.api.events.guild.GuildLeaveEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; -public class DataDogStatsListener extends ListenerAdapter implements CommandListener -{ +public class DataDogStatsListener extends ListenerAdapter { private final StatsDClient statsd; - public DataDogStatsListener(StatsDClient statsd) - { + public DataDogStatsListener(StatsDClient statsd) { this.statsd = statsd; } @Override - public void onGuildJoin(GuildJoinEvent event) - { + public void onGuildJoin(GuildJoinEvent event) { statsd.recordGaugeValue("guilds", event.getJDA().getGuildCache().size()); } @Override - public void onGuildLeave(GuildLeaveEvent event) - { + public void onGuildLeave(GuildLeaveEvent event) { statsd.recordGaugeValue("guilds", event.getJDA().getGuildCache().size()); } - @Override - public void onCommand(CommandEvent event, Command command) - { - statsd.incrementCounter("commands"); - } } diff --git a/src/main/java/xyz/rc24/bot/listeners/StopRaidingUsForFucksSakeListener.java b/src/main/java/xyz/rc24/bot/listeners/RaidListener.java similarity index 87% rename from src/main/java/xyz/rc24/bot/listeners/StopRaidingUsForFucksSakeListener.java rename to src/main/java/xyz/rc24/bot/listeners/RaidListener.java index 55e43742..759dfa76 100644 --- a/src/main/java/xyz/rc24/bot/listeners/StopRaidingUsForFucksSakeListener.java +++ b/src/main/java/xyz/rc24/bot/listeners/RaidListener.java @@ -33,6 +33,7 @@ import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.TimeUnit; /** * Seriously, stop. @@ -40,12 +41,12 @@ * @author Artuto */ -public class StopRaidingUsForFucksSakeListener extends ListenerAdapter +public class RaidListener extends ListenerAdapter { private boolean enabled; private final List allowed = new ArrayList<>(); - public StopRaidingUsForFucksSakeListener(boolean enabled) + public RaidListener(boolean enabled) { this.enabled = enabled; } @@ -76,16 +77,15 @@ public void onGuildMemberJoin(GuildMemberJoinEvent event) "Cheers,\n" + "RiiConnect24 Staff"; - member.getUser().openPrivateChannel().queue(pc -> pc.sendMessage(dm) - .queue(s -> ban(member), e -> ban(member))); + member.getUser().openPrivateChannel().queue(pc -> pc.sendMessage(dm).queue(s -> ban(member), e -> ban(member))); } catch(Exception ignored) {} } private void ban(Member member) { - // We set double reason because one is AuditLog reason and other ban reason (really dumb #Discord) - member.ban(1, "[AutoBan]").reason("[AutoBan]").queue(null, e -> {}); + //not sure if it shows up in the audit log... we will need to check + member.ban(1, TimeUnit.DAYS).reason("[AutoBan]").queue(); allowed.add(member.getUser().getIdLong()); } diff --git a/src/main/java/xyz/rc24/bot/managers/BirthdayManager.java b/src/main/java/xyz/rc24/bot/managers/BirthdayManager.java index c6270dc9..d0c4c032 100644 --- a/src/main/java/xyz/rc24/bot/managers/BirthdayManager.java +++ b/src/main/java/xyz/rc24/bot/managers/BirthdayManager.java @@ -24,21 +24,21 @@ package xyz.rc24.bot.managers; -import ch.qos.logback.classic.Logger; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.TextChannel; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import org.slf4j.Logger; import xyz.rc24.bot.RiiConnect24Bot; import xyz.rc24.bot.database.BirthdayDataManager; -import java.awt.Color; +import java.awt.*; import java.time.LocalDate; import java.time.OffsetDateTime; import java.time.ZoneId; import java.util.List; -import static xyz.rc24.bot.Const.ERROR_E; +import static xyz.rc24.bot.RiiConnect24Bot.ERROR_E; /** * Manager for birthdays. diff --git a/src/main/java/xyz/rc24/bot/managers/PollManager.java b/src/main/java/xyz/rc24/bot/managers/PollManager.java index 8041c5f7..25832546 100644 --- a/src/main/java/xyz/rc24/bot/managers/PollManager.java +++ b/src/main/java/xyz/rc24/bot/managers/PollManager.java @@ -49,30 +49,28 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -public class PollManager -{ +public class PollManager { private final Set current; private final List polls; private final Random random; private final ScheduledExecutorService threadPool; - public PollManager() throws IOException - { + public PollManager() throws IOException { File miitomoFile = new File("miitomo_questions.yml"); File usFile = new File("polls_049.yml"); File ukFile = new File("polls_110.yml"); File worldFile = new File("polls_world.yml"); - if(!(miitomoFile.exists())) + if (!(miitomoFile.exists())) downloadFile(MIITOMO_FILE, miitomoFile); - if(!(usFile.exists())) + if (!(usFile.exists())) downloadFile(US_FILE, usFile); - if(!(ukFile.exists())) + if (!(ukFile.exists())) downloadFile(UK_FILE, ukFile); - if(!(worldFile.exists())) + if (!(worldFile.exists())) downloadFile(WORLD_FILE, worldFile); Yaml yaml = new Yaml(); @@ -90,34 +88,28 @@ public PollManager() throws IOException this.threadPool = Executors.newScheduledThreadPool(2); } - public Poll getRandomPoll() - { + public Poll getRandomPoll() { return polls.get(random.nextInt(polls.size())); } - public void trackId(long id) - { + public void trackId(long id) { current.add(id); threadPool.schedule(() -> unTrackId(id), 10, TimeUnit.MINUTES); } - public void unTrackId(long id) - { + public void unTrackId(long id) { current.remove(id); } - public boolean isTracked(long id) - { + public boolean isTracked(long id) { return current.contains(id); } - public ScheduledExecutorService getThreadPool() - { + public ScheduledExecutorService getThreadPool() { return threadPool; } - private void downloadFile(String downloadUrl, File file) throws IOException - { + private void downloadFile(String downloadUrl, File file) throws IOException { URL url = new URL(downloadUrl); ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream()); FileOutputStream fileOutputStream = new FileOutputStream(file); @@ -127,16 +119,13 @@ private void downloadFile(String downloadUrl, File file) throws IOException @SuppressWarnings("unchecked") private void populateList(List> miitomo, List> us, - List> uk, List> world) - { - for(Map data : miitomo) - { + List> uk, List> world) { + for (Map data : miitomo) { Map section = (Map) data.get("question"); polls.add(new MiitomoPoll((String) section.get("english"))); } - for(Map data : us) - { + for (Map data : us) { Map section = (Map) data.get("poll"); polls.add(new USPollImpl( getPart(section, "question"), @@ -144,8 +133,7 @@ private void populateList(List> miitomo, List data : uk) - { + for (Map data : uk) { Map section = (Map) data.get("poll"); polls.add(new UKPollImpl( getPart(section, "question"), @@ -153,8 +141,7 @@ private void populateList(List> miitomo, List data : world) - { + for (Map data : world) { Map section = (Map) data.get("poll"); polls.add(new WorldPollImpl( getPart(section, "question"), @@ -164,8 +151,7 @@ private void populateList(List> miitomo, List poll, String key) - { + private String getPart(Map poll, String key) { return (String) ((Map) poll.get(key)).get("english"); } @@ -177,4 +163,5 @@ private String getPart(Map poll, String key) "_data/votes/results_049.yml"; private final String WORLD_FILE = "https://raw.githubusercontent.com/RiiConnect24/Site/master/" + "_data/votes/results_world.yml"; + } diff --git a/src/main/java/xyz/rc24/bot/utils/FinderUtil.java b/src/main/java/xyz/rc24/bot/utils/FinderUtil.java deleted file mode 100644 index 431c0e49..00000000 --- a/src/main/java/xyz/rc24/bot/utils/FinderUtil.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.utils; - -import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.exceptions.ErrorResponseException; - -import java.util.Collections; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; -import static net.dv8tion.jda.api.entities.Message.MentionType.USER; - -public class FinderUtil -{ - private static final Pattern ID = Pattern.compile("(\\d+)"); - - public static List findMembers(String args, Guild guild) - { - // First try with an ID - long id = parseId(ID, args); - if(!(id == 0)) - return retrieveMember(id, guild); - - // Then go for a mention - id = parseId(USER.getPattern(), args); - if(!(id == 0)) - return retrieveMember(id, guild); - - // Then just search for the name - return retrieveMembers(args, guild); - } - - private static List retrieveMember(long id, Guild guild) - { - try {return Collections.singletonList(guild.retrieveMemberById(id).complete());} - catch(ErrorResponseException ignored) {return emptyList();} - } - - private static List retrieveMembers(String name, Guild guild) - { - List members = guild.retrieveMembersByPrefix(removeDiscriminator(name), 6).get(); - String discriminator = splitDiscriminator(name); - - if(!(discriminator == null)) - { - for(Member member : members) - { - if(member.getUser().getDiscriminator().equals(discriminator)) - return singletonList(member); - } - } - - return members; - } - - private static long parseId(Pattern pattern, String arg) - { - Matcher matcher = pattern.matcher(arg); - - if(matcher.matches()) - return Long.parseLong(matcher.group(1)); - - return 0; - } - - private static String removeDiscriminator(String name) - { - int index = name.indexOf("#"); - - if(!(index == -1)) - return name.substring(0, index - 1); - - return name; - } - - private static String splitDiscriminator(String name) - { - String discriminator = null; - int index = name.indexOf("#"); - - if(!(index == -1)) - discriminator = name.substring(index + 1); - - return discriminator; - } -} diff --git a/src/main/java/xyz/rc24/bot/utils/FormatUtil.java b/src/main/java/xyz/rc24/bot/utils/FormatUtil.java index d5307aa7..4953d1b2 100644 --- a/src/main/java/xyz/rc24/bot/utils/FormatUtil.java +++ b/src/main/java/xyz/rc24/bot/utils/FormatUtil.java @@ -24,12 +24,8 @@ package xyz.rc24.bot.utils; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.TextChannel; -import net.dv8tion.jda.api.entities.User; import xyz.rc24.bot.core.entities.CodeType; -import java.util.List; import java.util.Map; /** @@ -38,59 +34,13 @@ public class FormatUtil { - public static String listOfMembers(List list, String query) - { - StringBuilder out = new StringBuilder("Multiple members found matching \"" + query + "\":"); - for(int i = 0; i < 6 && i < list.size(); i++) - { - out.append("\n - ").append(list.get(i).getUser().getName()).append("#") - .append(list.get(i).getUser().getDiscriminator()).append(" (ID:") - .append(list.get(i).getUser().getId()).append(")"); - } - - if(list.size() > 6) - out.append("\n**And ").append(list.size() - 6).append(" more...**"); - - return out.toString(); - } - - public static String listOfTcChannels(List list, String query) - { - StringBuilder out = new StringBuilder("Multiple text channels found matching \"" + query + "\":"); - for(int i = 0; i < 6 && i < list.size(); i++) - { - out.append("\n - ").append(list.get(i).getName()).append(" (ID:") - .append(list.get(i).getId()).append(")"); - } - - if(list.size() > 6) - out.append("\n**And ").append(list.size() - 6).append(" more...**"); - - return out.toString(); - } - - public static String listOfUsers(List list, String query) - { - StringBuilder out = new StringBuilder("Multiple users found matching \"" + query + "\":"); - for(int i = 0; i < 6 && i < list.size(); i++) - { - out.append("\n - ").append(list.get(i).getName()).append("#") - .append(list.get(i).getDiscriminator()).append(" (ID:") - .append(list.get(i).getId()).append(")"); - } - - if(list.size() > 6) - out.append("\n**And ").append(list.size() - 6).append(" more...**"); - - return out.toString(); - } public static String getCodeTypes() { StringBuilder response = new StringBuilder("Invalid type! Valid types:\n"); for(CodeType type : CodeType.values()) { - if(type == CodeType.UNKNOWN) + if(type == null) continue; response.append("`").append(type.getName()).append("`, "); @@ -110,14 +60,4 @@ public static String getCodeLayout(Map codes) return codesString.toString(); } - public static String getCodeLayout(String name, String code) - { - return "`" + name + "`:\n" + code; - } - - public static String sanitize(String msg) - { - return msg.replace("@everyone", "@\u0435veryone") - .replace("@here", "@h\u0435re"); - } } diff --git a/src/main/java/xyz/rc24/bot/utils/SearcherUtil.java b/src/main/java/xyz/rc24/bot/utils/SearcherUtil.java deleted file mode 100644 index 6f4aaf41..00000000 --- a/src/main/java/xyz/rc24/bot/utils/SearcherUtil.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017-2020 RiiConnect24 and its contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xyz.rc24.bot.utils; - -import com.jagrosh.jdautilities.command.CommandEvent; -import net.dv8tion.jda.api.entities.Member; - -import java.util.List; - -/** - * @author Artuto - */ - -public class SearcherUtil -{ - public static Member findMember(CommandEvent event, String args) - { - if(args.isEmpty()) - return event.getMember(); - - List found = FinderUtil.findMembers(args, event.getGuild()); - if(found.isEmpty()) - { - event.replyWarning("No members found matching \"" + args + "\""); - return null; - } - else if(found.size() > 1) - { - event.replyWarning(FormatUtil.listOfMembers(found, args)); - return null; - } - - return found.get(0); - } -} diff --git a/src/main/resources/birthdays.sql b/src/main/resources/birthdays.sql index 01a448d5..64097ece 100644 --- a/src/main/resources/birthdays.sql +++ b/src/main/resources/birthdays.sql @@ -24,11 +24,8 @@ create table birthdays ( - user_id bigint not null, + user_id bigint not null primary key, day varchar(5) null, constraint birthdays_user_id_uindex unique (user_id) -); - -alter table birthdays - add primary key (user_id); \ No newline at end of file +); \ No newline at end of file diff --git a/src/main/resources/codes.sql b/src/main/resources/codes.sql index 32743f17..c724bf90 100644 --- a/src/main/resources/codes.sql +++ b/src/main/resources/codes.sql @@ -24,13 +24,14 @@ create table codes ( - user_id bigint not null, + user_id bigint not null primary key, games mediumtext null, nnid mediumtext null, switch mediumtext null, threeds mediumtext null, wii mediumtext null, psn mediumtext null, + flag mediumtext null, constraint codes_user_id_uindex unique (user_id) ); diff --git a/src/main/resources/settings.sql b/src/main/resources/settings.sql index a2cd11ef..c79f45ed 100644 --- a/src/main/resources/settings.sql +++ b/src/main/resources/settings.sql @@ -24,7 +24,7 @@ create table settings ( - guild_id bigint not null, + guild_id bigint not null primary key, modlog_id bigint null, serverlog_id bigint null, birthdays_id bigint null, @@ -32,7 +32,4 @@ create table settings prefixes text null, constraint settings_guild_id_uindex unique (guild_id) -); - -alter table settings - add primary key (guild_id); \ No newline at end of file +); \ No newline at end of file