From a93499cfb8580c8ae4e6814f16dbb162a7d2a113 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 4 Aug 2023 21:17:52 +0200 Subject: [PATCH 001/103] fix: fixed build.yml Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index d7453ff..e7199da 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -1,7 +1,7 @@ on: [ push ] jobs: build_and_publish: - runs-on: gradle + runs-on: docker steps: - name: Setup Gradle uses: gradle/gradle-build-action@v2 From 7f2e74ff6c7ee729964131b956e449887ac2ec32 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 4 Aug 2023 21:22:29 +0200 Subject: [PATCH 002/103] fix: fixed build.yml? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index e7199da..73cc3e1 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -3,8 +3,6 @@ jobs: build_and_publish: runs-on: docker steps: - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - name: Clean Caches run: | rm -f .gradle/caches/modules-2/modules-2.lock From 38832e1c0d268f931975c864a31a7aa6caebda61 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 4 Aug 2023 21:23:16 +0200 Subject: [PATCH 003/103] fix: fixed build.yml?? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 73cc3e1..dac3297 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -8,6 +8,6 @@ jobs: rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ - name: Run shadowJar - run: ./gradlew shadowJar + run: gradle shadowJar - name: Run publish - run: ./gradlew publish + run: gradle publish From 2bfc327ceb443009095faf4dc3f755311dfd5b83 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 4 Aug 2023 21:25:46 +0200 Subject: [PATCH 004/103] fix: fixed build.yml??? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index dac3297..e56b61c 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -7,6 +7,8 @@ jobs: run: | rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ + - name: Checkout project sources + uses: actions/checkout@v3 - name: Run shadowJar run: gradle shadowJar - name: Run publish From cd84d026086e13f71169f5a02837b125d9d6ab8d Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 4 Aug 2023 21:28:10 +0200 Subject: [PATCH 005/103] fix: fixed build.yml???? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index e56b61c..91503c7 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -2,13 +2,13 @@ on: [ push ] jobs: build_and_publish: runs-on: docker + container: + image: gradle steps: - name: Clean Caches run: | rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ - - name: Checkout project sources - uses: actions/checkout@v3 - name: Run shadowJar run: gradle shadowJar - name: Run publish From 04fa9ad59a1dcaddf7cf8e12a9f87600d4910fb9 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 4 Aug 2023 21:30:17 +0200 Subject: [PATCH 006/103] fix: fixed build.yml????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 91503c7..b410aaa 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -9,6 +9,8 @@ jobs: run: | rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ + - name: Get Repo + uses: actions/checkout@v2 - name: Run shadowJar run: gradle shadowJar - name: Run publish From a2436cb002a66fa417481a3690b99d0263e0af78 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 4 Aug 2023 21:32:45 +0200 Subject: [PATCH 007/103] fix: fixed build.yml?????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index b410aaa..0c856f5 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -9,8 +9,12 @@ jobs: run: | rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ - - name: Get Repo - uses: actions/checkout@v2 + - name: Export Gradle User Home + uses: export GRADLE_USER_HOME=`pwd`/.gradle + - name: Checkout project sources + uses: actions/checkout@v3 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 - name: Run shadowJar run: gradle shadowJar - name: Run publish From c4b00aa9a507305961d186b82d16601c86b018d9 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 01:40:41 +0200 Subject: [PATCH 008/103] fix: fixed build.yml??????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 0c856f5..a9f000d 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -5,14 +5,14 @@ jobs: container: image: gradle steps: + - name: Checkout project sources + uses: actions/checkout@v3 - name: Clean Caches run: | rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ - name: Export Gradle User Home uses: export GRADLE_USER_HOME=`pwd`/.gradle - - name: Checkout project sources - uses: actions/checkout@v3 - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Run shadowJar From 9273b4b168ec14a2915a4a99f9ce4e8bcf83303d Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 01:55:59 +0200 Subject: [PATCH 009/103] fix: fixed build.yml???????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 59 +++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index a9f000d..696ff35 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -1,21 +1,46 @@ on: [ push ] jobs: - build_and_publish: - runs-on: docker - container: - image: gradle + build: + name: Build + runs-on: ubuntu-latest + steps: - - name: Checkout project sources - uses: actions/checkout@v3 - - name: Clean Caches + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: 11 + + - name: Build with Gradle run: | - rm -f .gradle/caches/modules-2/modules-2.lock - rm -fr .gradle/caches/*/plugin-resolution/ - - name: Export Gradle User Home - uses: export GRADLE_USER_HOME=`pwd`/.gradle - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - name: Run shadowJar - run: gradle shadowJar - - name: Run publish - run: gradle publish + ./gradlew clean + ./gradlew shadowJar + env: + GRADLE_OPTS: "-Dorg.gradle.daemon=false" + GRADLE_USER_HOME: ${{ github.workspace }}/.gradle + GIT_SUBMODULE_STRATEGY: recursive + working-directory: ${{ github.workspace }} + + publish: + name: Publish + needs: build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: 11 + + - name: Publish with Gradle + run: | + ./gradlew publish + env: + GRADLE_USER_HOME: ${{ github.workspace }}/.gradle + GIT_SUBMODULE_STRATEGY: recursive + working-directory: ${{ github.workspace }} From eb7ac71dd542c5d18364e6fb932c20d4d51ec081 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 01:57:02 +0200 Subject: [PATCH 010/103] fix: fixed build.yml????????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 696ff35..05cd079 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -2,7 +2,7 @@ on: [ push ] jobs: build: name: Build - runs-on: ubuntu-latest + runs-on: docker steps: - name: Checkout code @@ -26,7 +26,7 @@ jobs: publish: name: Publish needs: build - runs-on: ubuntu-latest + runs-on: docker steps: - name: Checkout code From f3497f9a2b21fcffe70b7f2f62858bc98f7e14eb Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 02:00:07 +0200 Subject: [PATCH 011/103] fix: fixed build.yml?????????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 50 +++++++++++------------------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 05cd079..99a562c 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -1,46 +1,26 @@ on: [ push ] jobs: - build: - name: Build + build_and_publish: runs-on: docker - + container: + image: gradle steps: - - name: Checkout code + - name: Checkout project sources uses: actions/checkout@v2 - - name: Set up JDK - uses: actions/setup-java@v2 - with: - java-version: 11 - - - name: Build with Gradle + - name: Clean Caches run: | - ./gradlew clean - ./gradlew shadowJar + rm -f .gradle/caches/modules-2/modules-2.lock + rm -fr .gradle/caches/*/plugin-resolution/ + + - name: Setup Gradle User Home + run: export GRADLE_USER_HOME=`pwd`/.gradle + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + with: + args: shadowJar publish env: GRADLE_OPTS: "-Dorg.gradle.daemon=false" - GRADLE_USER_HOME: ${{ github.workspace }}/.gradle GIT_SUBMODULE_STRATEGY: recursive working-directory: ${{ github.workspace }} - - publish: - name: Publish - needs: build - runs-on: docker - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up JDK - uses: actions/setup-java@v2 - with: - java-version: 11 - - - name: Publish with Gradle - run: | - ./gradlew publish - env: - GRADLE_USER_HOME: ${{ github.workspace }}/.gradle - GIT_SUBMODULE_STRATEGY: recursive - working-directory: ${{ github.workspace }} From 02d95b7d12f6f741012c7a88bd3f4f4df433e2cf Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 02:15:48 +0200 Subject: [PATCH 012/103] fix: fixed build.yml??????????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 99a562c..3220fa3 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -4,23 +4,19 @@ jobs: runs-on: docker container: image: gradle + uses: git.moonleay.net/DiscordBots/liljudd/actions/checkout@v3 steps: - - name: Checkout project sources - uses: actions/checkout@v2 - - name: Clean Caches run: | - rm -f .gradle/caches/modules-2/modules-2.lock + rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ - - - name: Setup Gradle User Home - run: export GRADLE_USER_HOME=`pwd`/.gradle - + - name: Export Gradle User Home + uses: export GRADLE_USER_HOME=`pwd`/.gradle + - name: Checkout project sources + uses: actions/checkout@v3 - name: Setup Gradle uses: gradle/gradle-build-action@v2 - with: - args: shadowJar publish - env: - GRADLE_OPTS: "-Dorg.gradle.daemon=false" - GIT_SUBMODULE_STRATEGY: recursive - working-directory: ${{ github.workspace }} + - name: Run shadowJar + run: gradle shadowJar + - name: Run publish + run: gradle publish From e344c9bd3aad461d109b1f95ca77199deb12960a Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 02:17:47 +0200 Subject: [PATCH 013/103] fix: fixed build.yml???????????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 3220fa3..8c0099d 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -4,14 +4,16 @@ jobs: runs-on: docker container: image: gradle - uses: git.moonleay.net/DiscordBots/liljudd/actions/checkout@v3 + uses: steps: + - name: Checkout project sources + uses: git.moonleay.net/DiscordBots/liljudd/actions/checkout@v3 + - name: Export Gradle User Home + uses: export GRADLE_USER_HOME=`pwd`/.gradle - name: Clean Caches run: | rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ - - name: Export Gradle User Home - uses: export GRADLE_USER_HOME=`pwd`/.gradle - name: Checkout project sources uses: actions/checkout@v3 - name: Setup Gradle From 7dbae9a3309ba52586519b70fb194b885d5c6f8f Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 02:18:42 +0200 Subject: [PATCH 014/103] fix: fixed build.yml????????????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 8c0099d..5208e58 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -7,7 +7,7 @@ jobs: uses: steps: - name: Checkout project sources - uses: git.moonleay.net/DiscordBots/liljudd/actions/checkout@v3 + uses: git.moonleay.net/DiscordBots/liljudd.git - name: Export Gradle User Home uses: export GRADLE_USER_HOME=`pwd`/.gradle - name: Clean Caches From 9d68e9aebb8db2a9378b95a9d1bbeefbdd816db3 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 02:19:40 +0200 Subject: [PATCH 015/103] fix: fixed build.yml?????????????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 5208e58..f81ca95 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -7,15 +7,13 @@ jobs: uses: steps: - name: Checkout project sources - uses: git.moonleay.net/DiscordBots/liljudd.git + uses: DiscordBots/liljudd/actions/checkout@v3 - name: Export Gradle User Home uses: export GRADLE_USER_HOME=`pwd`/.gradle - name: Clean Caches run: | rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ - - name: Checkout project sources - uses: actions/checkout@v3 - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Run shadowJar From 4cc3fae4ab887f247edd79d79799de6e207abeec Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 02:20:17 +0200 Subject: [PATCH 016/103] fix: fixed build.yml??????????????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index f81ca95..40a4cef 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -7,7 +7,7 @@ jobs: uses: steps: - name: Checkout project sources - uses: DiscordBots/liljudd/actions/checkout@v3 + uses: DiscordBots/liljudd/actions/checkout@v2 - name: Export Gradle User Home uses: export GRADLE_USER_HOME=`pwd`/.gradle - name: Clean Caches From 6b391f2e4dc89c0fdf78aaa9c59459ef1db92800 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 02:23:20 +0200 Subject: [PATCH 017/103] fix: fixed build.yml???????????????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 40a4cef..4ae7650 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -7,7 +7,7 @@ jobs: uses: steps: - name: Checkout project sources - uses: DiscordBots/liljudd/actions/checkout@v2 + uses: DiscordBots/liljudd/actions/ - name: Export Gradle User Home uses: export GRADLE_USER_HOME=`pwd`/.gradle - name: Clean Caches From d9cedb702b2fa95f220f9c9e9e2f7e8eb63e669a Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 02:25:08 +0200 Subject: [PATCH 018/103] fix: fixed build.yml????????????????? Signed-off-by: moonleay --- .forgejo/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 4ae7650..40a4cef 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -7,7 +7,7 @@ jobs: uses: steps: - name: Checkout project sources - uses: DiscordBots/liljudd/actions/ + uses: DiscordBots/liljudd/actions/checkout@v2 - name: Export Gradle User Home uses: export GRADLE_USER_HOME=`pwd`/.gradle - name: Clean Caches From 7d15ef910baabcdcaf139eccefe8d50af035c200 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 02:39:59 +0200 Subject: [PATCH 019/103] feat moved action.yml Signed-off-by: moonleay --- .forgejo/workflows/build.yml => action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename .forgejo/workflows/build.yml => action.yml (84%) diff --git a/.forgejo/workflows/build.yml b/action.yml similarity index 84% rename from .forgejo/workflows/build.yml rename to action.yml index 40a4cef..9636e60 100644 --- a/.forgejo/workflows/build.yml +++ b/action.yml @@ -7,13 +7,15 @@ jobs: uses: steps: - name: Checkout project sources - uses: DiscordBots/liljudd/actions/checkout@v2 + uses: actions/checkout@v3 - name: Export Gradle User Home uses: export GRADLE_USER_HOME=`pwd`/.gradle - name: Clean Caches run: | rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ + - name: Checkout project sources + uses: actions/checkout@v3 - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Run shadowJar From 6b0c5058ab705da93a125d37b5cb7356be16b3b5 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 02:41:04 +0200 Subject: [PATCH 020/103] feat moved action.yml Signed-off-by: moonleay --- action.yml => .forgejo/workflows/action.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename action.yml => .forgejo/workflows/action.yml (100%) diff --git a/action.yml b/.forgejo/workflows/action.yml similarity index 100% rename from action.yml rename to .forgejo/workflows/action.yml From 90f9dd15c9dad4c5efec7a4c312a739c4b131293 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 18:01:12 +0200 Subject: [PATCH 021/103] fix> update ci Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 9636e60..43f3b5a 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -4,20 +4,13 @@ jobs: runs-on: docker container: image: gradle - uses: steps: - - name: Checkout project sources - uses: actions/checkout@v3 - - name: Export Gradle User Home - uses: export GRADLE_USER_HOME=`pwd`/.gradle + - name: Checkout + uses: actions/checkout@v2 - name: Clean Caches run: | rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ - - name: Checkout project sources - uses: actions/checkout@v3 - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - name: Run shadowJar run: gradle shadowJar - name: Run publish From e215f556e7a5751c33d0197220a1eb210459529d Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 18:27:00 +0200 Subject: [PATCH 022/103] fix> update ci Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 43f3b5a..5162746 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -1,3 +1,4 @@ +#file: noinspection YAMLSchemaValidation on: [ push ] jobs: build_and_publish: @@ -6,7 +7,7 @@ jobs: image: gradle steps: - name: Checkout - uses: actions/checkout@v2 + uses: DiscordBots/liljudd@master - name: Clean Caches run: | rm -f .gradle/caches/modules-2/modules-2.lock From 0928d84b9a4d1d898c8461fc8a8955207f6ace33 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 18:36:08 +0200 Subject: [PATCH 023/103] fix> update ci Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 5162746..92865a0 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -3,8 +3,6 @@ on: [ push ] jobs: build_and_publish: runs-on: docker - container: - image: gradle steps: - name: Checkout uses: DiscordBots/liljudd@master From bf8bc013d938d519fa7e4bb4a7d25e3109e4b357 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 18:36:48 +0200 Subject: [PATCH 024/103] fix> update ci Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 92865a0..b72e1de 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -2,7 +2,6 @@ on: [ push ] jobs: build_and_publish: - runs-on: docker steps: - name: Checkout uses: DiscordBots/liljudd@master From 149ce7d5c65f45030bca9b6eeb2fa44607429f09 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 18:54:14 +0200 Subject: [PATCH 025/103] fix> update ci Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index b72e1de..43f3b5a 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -1,10 +1,12 @@ -#file: noinspection YAMLSchemaValidation on: [ push ] jobs: build_and_publish: + runs-on: docker + container: + image: gradle steps: - name: Checkout - uses: DiscordBots/liljudd@master + uses: actions/checkout@v2 - name: Clean Caches run: | rm -f .gradle/caches/modules-2/modules-2.lock From c4233a7b6b3bd4ec667bfc8dc4f1ebc85e747dd8 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 5 Aug 2023 19:04:47 +0200 Subject: [PATCH 026/103] fix> update ci Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 43f3b5a..dc16848 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -5,12 +5,17 @@ jobs: container: image: gradle steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Clean Caches - run: | - rm -f .gradle/caches/modules-2/modules-2.lock - rm -fr .gradle/caches/*/plugin-resolution/ + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build and Package JAR with Gradle + uses: docker://gradle:latest # Use the official Gradle Docker image + with: + args: shadowJar + - name: Clean Caches + run: | + rm -f .gradle/caches/modules-2/modules-2.lock + rm -fr .gradle/caches/*/plugin-resolution/ - name: Run shadowJar run: gradle shadowJar - name: Run publish From 619be853536e5db037f6f257697f44e06d2accbf Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 12 Aug 2023 13:47:55 +0200 Subject: [PATCH 027/103] Update .forgejo/workflows/action.yml Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index dc16848..5c46be0 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -4,7 +4,6 @@ jobs: runs-on: docker container: image: gradle - steps: steps: - name: Checkout code uses: actions/checkout@v2 From 08b6601663bd78037e774919551ac73c5306daad Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 12 Aug 2023 14:02:50 +0200 Subject: [PATCH 028/103] Update .forgejo/workflows/action.yml Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 5c46be0..5fd6afa 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -5,17 +5,15 @@ jobs: container: image: gradle steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Build and Package JAR with Gradle - uses: docker://gradle:latest # Use the official Gradle Docker image - with: - args: shadowJar + - name: Checkout project sources + uses: actions/checkout@v3 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 - name: Clean Caches run: | rm -f .gradle/caches/modules-2/modules-2.lock rm -fr .gradle/caches/*/plugin-resolution/ - name: Run shadowJar - run: gradle shadowJar + run: ./gradle shadowJar - name: Run publish - run: gradle publish + run: ./gradle publish From a75a70b6890711db2c4e940c0367f5951ee19602 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 12 Aug 2023 14:04:55 +0200 Subject: [PATCH 029/103] Update .forgejo/workflows/action.yml Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 5fd6afa..9fef42b 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -1,4 +1,6 @@ -on: [ push ] +name: ci +on: + - push jobs: build_and_publish: runs-on: docker From 1e65e609e1ce09955110fbbfb83de323fa1ae6fc Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 12 Aug 2023 14:06:37 +0200 Subject: [PATCH 030/103] Update .forgejo/workflows/action.yml Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 9fef42b..951b879 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -3,7 +3,7 @@ on: - push jobs: build_and_publish: - runs-on: docker + runs-on: ubuntu-latest container: image: gradle steps: From fc6824cd5e6fb6da106030b2643d46f7ad520f23 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 12 Aug 2023 14:09:21 +0200 Subject: [PATCH 031/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 951b879..42dd6c9 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -4,18 +4,16 @@ on: jobs: build_and_publish: runs-on: ubuntu-latest - container: - image: gradle - steps: - - name: Checkout project sources - uses: actions/checkout@v3 - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - name: Clean Caches - run: | - rm -f .gradle/caches/modules-2/modules-2.lock - rm -fr .gradle/caches/*/plugin-resolution/ + steps: + - name: Checkout project sources + uses: actions/checkout@v3 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - name: Clean Caches + run: | + rm -f .gradle/caches/modules-2/modules-2.lock + rm -fr .gradle/caches/*/plugin-resolution/ - name: Run shadowJar - run: ./gradle shadowJar + run: ./gradle shadowJar - name: Run publish - run: ./gradle publish + run: ./gradle publish From a45d4ae26df19073acc33c51a861b9312c3835d3 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 12 Aug 2023 14:09:39 +0200 Subject: [PATCH 032/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 42dd6c9..933b5e6 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -9,10 +9,6 @@ jobs: uses: actions/checkout@v3 - name: Setup Gradle uses: gradle/gradle-build-action@v2 - - name: Clean Caches - run: | - rm -f .gradle/caches/modules-2/modules-2.lock - rm -fr .gradle/caches/*/plugin-resolution/ - name: Run shadowJar run: ./gradle shadowJar - name: Run publish From 9847192074c637e28a5780c4884071900a9beea5 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 12 Aug 2023 14:10:43 +0200 Subject: [PATCH 033/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 933b5e6..5487e97 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -10,6 +10,6 @@ jobs: - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Run shadowJar - run: ./gradle shadowJar + run: gradle shadowJar - name: Run publish - run: ./gradle publish + run: gradle publish From cf1fed51c317c385070ce019ac7f382381dbd484 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 12 Aug 2023 14:12:10 +0200 Subject: [PATCH 034/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 5487e97..464a266 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -1,15 +1,15 @@ -name: ci -on: - - push +name: Build Gradle project + +on: + push: + jobs: - build_and_publish: + build-gradle-project: runs-on: ubuntu-latest steps: - - name: Checkout project sources - uses: actions/checkout@v3 - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - name: Run shadowJar - run: gradle shadowJar - - name: Run publish - run: gradle publish + - name: Checkout project sources + uses: actions/checkout@v3 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - name: Run build with Gradle Wrapper + run: ./gradlew shadowJar \ No newline at end of file From 9c1842d4f7beb1a6c20865c46d9cca72e8664b3b Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 18 Aug 2023 08:53:44 +0200 Subject: [PATCH 035/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 464a266..315846d 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -7,6 +7,8 @@ jobs: build-gradle-project: runs-on: ubuntu-latest steps: + - name: install prerequisits + run: apt install openjdk-17-jdk - name: Checkout project sources uses: actions/checkout@v3 - name: Setup Gradle From 3018918bffdab605b293fdbcd1d6f2717da662a4 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 18 Aug 2023 08:55:04 +0200 Subject: [PATCH 036/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 315846d..21b5ec5 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -8,7 +8,9 @@ jobs: runs-on: ubuntu-latest steps: - name: install prerequisits - run: apt install openjdk-17-jdk + run: apt update + run: apt upgrade + run: apt install openjdk17-jdk - name: Checkout project sources uses: actions/checkout@v3 - name: Setup Gradle From 81d248bfb7f238a6451b07d2a245f64528956e7e Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 18 Aug 2023 08:56:42 +0200 Subject: [PATCH 037/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 21b5ec5..550e23c 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -7,9 +7,11 @@ jobs: build-gradle-project: runs-on: ubuntu-latest steps: - - name: install prerequisits + - name: apt 1 run: apt update + - name: apt 2 run: apt upgrade + - name: install prerequisits run: apt install openjdk17-jdk - name: Checkout project sources uses: actions/checkout@v3 From 937541cf6154e20f62bdb6dcb1302d34aa33820f Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 18 Aug 2023 09:00:23 +0200 Subject: [PATCH 038/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 550e23c..b0b615e 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -9,8 +9,6 @@ jobs: steps: - name: apt 1 run: apt update - - name: apt 2 - run: apt upgrade - name: install prerequisits run: apt install openjdk17-jdk - name: Checkout project sources From c6380213265cf2305823087aa2311471fc39cc7d Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 18 Aug 2023 09:20:31 +0200 Subject: [PATCH 039/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index b0b615e..1f60834 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -10,7 +10,7 @@ jobs: - name: apt 1 run: apt update - name: install prerequisits - run: apt install openjdk17-jdk + run: apt install openjdk-17-jdk - name: Checkout project sources uses: actions/checkout@v3 - name: Setup Gradle From 9305118f4a18955c3f9ce56e3023afbf044f9deb Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 18 Aug 2023 11:13:03 +0200 Subject: [PATCH 040/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 1f60834..8c3b7fe 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -9,8 +9,10 @@ jobs: steps: - name: apt 1 run: apt update + - name: apt 2 + run: apt upgrade -y - name: install prerequisits - run: apt install openjdk-17-jdk + run: apt install openjdk-17-jdk -y - name: Checkout project sources uses: actions/checkout@v3 - name: Setup Gradle From 91e4dfde604927eaf507e23737fd0e36f2740f6e Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 18 Aug 2023 11:16:47 +0200 Subject: [PATCH 041/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 8c3b7fe..31b147b 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -12,7 +12,7 @@ jobs: - name: apt 2 run: apt upgrade -y - name: install prerequisits - run: apt install openjdk-17-jdk -y + run: apt install openjdk-17-jdk ca-certificates-java ssl-cert openssl ca-certificates -y - name: Checkout project sources uses: actions/checkout@v3 - name: Setup Gradle From 7bf0f8d56eeb76956ec9fecce938ebadf6b15e0b Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 18 Aug 2023 11:24:48 +0200 Subject: [PATCH 042/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 31b147b..626125f 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -17,5 +17,7 @@ jobs: uses: actions/checkout@v3 - name: Setup Gradle uses: gradle/gradle-build-action@v2 - - name: Run build with Gradle Wrapper - run: ./gradlew shadowJar \ No newline at end of file + - uses: actions/upload-artifact@v3 + with: + name: artifact + path: build/libs/ \ No newline at end of file From 9f28aecd5791c09d830c85554fa8101c0a11ffac Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 18 Aug 2023 11:25:30 +0200 Subject: [PATCH 043/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 626125f..a9783bd 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -18,6 +18,6 @@ jobs: - name: Setup Gradle uses: gradle/gradle-build-action@v2 - uses: actions/upload-artifact@v3 - with: - name: artifact - path: build/libs/ \ No newline at end of file + with: + name: artifact + path: build/libs/ \ No newline at end of file From 862206e1d52f6d105ed6e9fbe1c7570e3b861a9f Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 18 Aug 2023 11:40:51 +0200 Subject: [PATCH 044/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index a9783bd..a4d741b 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -17,6 +17,8 @@ jobs: uses: actions/checkout@v3 - name: Setup Gradle uses: gradle/gradle-build-action@v2 + - name: Run build with Gradle Wrapper + run: ./gradlew shadowJar - uses: actions/upload-artifact@v3 with: name: artifact From 500ad1a9123f4ae55ced2a9f532ef2a16e328235 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 18 Aug 2023 11:44:43 +0200 Subject: [PATCH 045/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index a4d741b..d9e4272 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -21,5 +21,5 @@ jobs: run: ./gradlew shadowJar - uses: actions/upload-artifact@v3 with: - name: artifact + name: lilJudd.jar path: build/libs/ \ No newline at end of file From b2587470862e25e3738e84310960cba82acb5078 Mon Sep 17 00:00:00 2001 From: moonleay Date: Wed, 6 Sep 2023 21:59:41 +0200 Subject: [PATCH 046/103] chore: improved imports Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/Bot.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt index be764de..1c6e337 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt @@ -35,10 +35,7 @@ import net.moonleay.botendo.build.BuildConstants import net.moonleay.lilJudd.buttons.component.EditButtonManager import net.moonleay.lilJudd.data.CredentialManager import net.moonleay.lilJudd.data.DB -import net.moonleay.lilJudd.extensions.FeatureManageExtension -import net.moonleay.lilJudd.extensions.MatchExtension -import net.moonleay.lilJudd.extensions.SendPlannerExtension -import net.moonleay.lilJudd.extensions.VersionExtension +import net.moonleay.lilJudd.extensions.* import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.features.MatchManager import net.moonleay.lilJudd.features.TimeManager @@ -103,7 +100,7 @@ object Bot { add(::FeatureManageExtension) add(::SendPlannerExtension) add(::MatchExtension) - //add(::UpdateRolesExtension) // This command is only for debugging purposes + add(::UpdateRolesExtension) // This command is only for debugging purposes //add(::TestExtension) // See comment in TestExtension.kt } From 925398db650de3680cf566ddf9bb976f0c3b735e Mon Sep 17 00:00:00 2001 From: moonleay Date: Wed, 6 Sep 2023 22:03:50 +0200 Subject: [PATCH 047/103] fix: fixed weekstamp Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt index 0ac7b1b..9acbc33 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt @@ -94,6 +94,7 @@ object TimeManager : IFeature { if (Bot.bot.kordRef.getChannel(ch) == null) continue // TODO: Check if the channel is valid in another shard val c = Bot.bot.kordRef.getChannelOf(ch)!! + msgStr = "" if (roleMap != null && roleMap.keys.contains(ch) && roleMap[ch] != null) { c.createMessage { this.content = @@ -152,7 +153,7 @@ object TimeManager : IFeature { TimePlanningMessages.insert { it[TimePlanningMessages.serverid] = c.data.guildId.value.toString() it[TimePlanningMessages.channelid] = c.id.value.toString() - it[TimePlanningMessages.weekstamp] = TimeUtil.getWeekStamp().toOffsetDateTime().toString() + it[TimePlanningMessages.weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000).toString() it[TimePlanningMessages.messageids] = msgStr } get TimePlanningMessages.id } From d10f8901c98b2ca14607c700d8a38134c3d84706 Mon Sep 17 00:00:00 2001 From: moonleay Date: Wed, 6 Sep 2023 22:05:29 +0200 Subject: [PATCH 048/103] fix: fixed AvailabilityManager Signed-off-by: moonleay --- .../moonleay/lilJudd/features/AvailabilityManager.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index 1359f50..2a980dc 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -96,8 +96,8 @@ object AvailabilityManager : IFeature { } val roleData = roleMap[data.channelid] // Get the role data if (roleData == null) { - Logger.out("Role for this channel does not exist") - return + Logger.out("Role for channel ${data.channelid} does not exist") + continue // this took way to long to find out that this was the issue } val g = Bot.bot.kordRef.getGuildOrThrow(Snowflake(data.serverid)) // Get all members with the role @@ -106,9 +106,11 @@ object AvailabilityManager : IFeature { } mce.collect { memberchunkevent -> memberchunkevent.members.forEach { - Logger.out("Checking member ${it.id.value}") - if (it.roleIds.contains(Snowflake(roleData.hastimeroleid))) + Logger.out("Checking member ${it.id.value} (${it.username})") + if (it.roleIds.contains(Snowflake(roleData.hastimeroleid))) { it.removeRole(Snowflake(roleData.hastimeroleid)) + Logger.out("Removed role from ${it.username}") // Removed the role + } } } From f552ea4faaa0560fbc24e8bd577ed7c920c529bb Mon Sep 17 00:00:00 2001 From: moonleay Date: Wed, 6 Sep 2023 22:06:14 +0200 Subject: [PATCH 049/103] chore: improved readability Signed-off-by: moonleay --- .../moonleay/lilJudd/extensions/SendPlannerExtension.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt index 2a56745..c02294e 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt @@ -107,10 +107,10 @@ class SendPlannerExtension : Extension() { // Save the message ids transaction { TimePlanningMessages.insert { - it[serverid] = c.data.guildId.value.toString() - it[channelid] = c.id.value.toString() - it[weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000).toString() - it[messageids] = msgStr + it[TimePlanningMessages.serverid] = c.data.guildId.value.toString() + it[TimePlanningMessages.channelid] = c.id.value.toString() + it[TimePlanningMessages.weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000).toString() + it[TimePlanningMessages.messageids] = msgStr } get TimePlanningMessages.id } Logger.out("Finished with ${c.data.guildId.value}") From a3c1344f1adfec7b775abd1c949c4ce48972644c Mon Sep 17 00:00:00 2001 From: moonleay Date: Wed, 6 Sep 2023 22:09:59 +0200 Subject: [PATCH 050/103] feat: Roles now update on button press Signed-off-by: moonleay --- .../lilJudd/buttons/timeplanner/IsAvailableEditButton.kt | 2 ++ .../lilJudd/buttons/timeplanner/MaybeAvailableEditButton.kt | 2 ++ .../lilJudd/buttons/timeplanner/NotAvailableEditButton.kt | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/IsAvailableEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/IsAvailableEditButton.kt index 2acfe55..6140d4d 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/IsAvailableEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/IsAvailableEditButton.kt @@ -27,6 +27,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton +import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.util.EmbedUtil class IsAvailableEditButton : IEditButton { @@ -62,5 +63,6 @@ class IsAvailableEditButton : IEditButton { } } } + AvailabilityManager.runThread() } } diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/MaybeAvailableEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/MaybeAvailableEditButton.kt index 3696a54..c3eaec2 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/MaybeAvailableEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/MaybeAvailableEditButton.kt @@ -27,6 +27,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton +import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.util.EmbedUtil class MaybeAvailableEditButton : IEditButton { @@ -62,5 +63,6 @@ class MaybeAvailableEditButton : IEditButton { } } } + AvailabilityManager.runThread() } } diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/NotAvailableEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/NotAvailableEditButton.kt index 698993f..b56db11 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/NotAvailableEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/NotAvailableEditButton.kt @@ -27,6 +27,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton +import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.util.EmbedUtil class NotAvailableEditButton : IEditButton { @@ -62,5 +63,6 @@ class NotAvailableEditButton : IEditButton { } } } + AvailabilityManager.runThread() } } From 18cd26c45681001527dbb6446a5e5f4677db48c6 Mon Sep 17 00:00:00 2001 From: moonleay Date: Wed, 6 Sep 2023 22:10:17 +0200 Subject: [PATCH 051/103] chore: bump version Signed-off-by: moonleay --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index f62ca80..3292b17 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,7 @@ val ownerID = 372703841151614976L group = "net.moonleay.liljudd" version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } - ?: "2.4.2" + ?: "2.4.3" val kordver = "1.5.6" val coroutinesver = "1.1.0" From 165e1d342c591890cab456c4134f7f97f38fe903 Mon Sep 17 00:00:00 2001 From: moonleay Date: Mon, 11 Sep 2023 12:44:34 +0200 Subject: [PATCH 052/103] feat: improved getAClonedEmbed function, added an equivalent using a EmbedBuilder Signed-off-by: moonleay --- .../net/moonleay/lilJudd/util/MessageUtil.kt | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt index dc0a34a..0e34571 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt @@ -71,11 +71,33 @@ object MessageUtil { } } - ///Get a cloned embedded message, missing only the fields - fun getAClonedEmbedd(e: Embed): EmbedBuilder { + ///Get a cloned embedded message + fun getAClonedEmbed(e: Embed): EmbedBuilder { val ebb = EmbedBuilder() ebb.color = e.color ebb.title = e.title + e.fields.forEach { + val fb = EmbedBuilder.Field() + fb.name = it.name + fb.value = it.value + fb.inline = it.inline + ebb.fields.add(fb) + } + ebb.description = e.description + return ebb + } + + fun getAClonedEmbed(e: EmbedBuilder): EmbedBuilder { + val ebb = EmbedBuilder() + ebb.color = e.color + ebb.title = e.title + e.fields.forEach { + val fb = EmbedBuilder.Field() + fb.name = it.name + fb.value = it.value + fb.inline = it.inline + ebb.fields.add(fb) + } ebb.description = e.description return ebb } From f7b701de20c7c525c6cac1ce31e559a0b5c3336a Mon Sep 17 00:00:00 2001 From: moonleay Date: Mon, 11 Sep 2023 12:45:51 +0200 Subject: [PATCH 053/103] feat: improved replaceXWithYinValuesAtTable function, edited MatchButtons Signed-off-by: moonleay --- .../net/moonleay/lilJudd/util/EmbedUtil.kt | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/EmbedUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/EmbedUtil.kt index d367709..e9dbbaf 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/util/EmbedUtil.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/util/EmbedUtil.kt @@ -41,17 +41,26 @@ object EmbedUtil { fun getMatchButtons(): ActionRowBuilder { val ar = ActionRowBuilder() ar.interactionButton(ButtonStyle.Success, "public.edit.btn.matchmanagement.accept") { - this.label = "Sign me up!" + this.label = "I'm in!" } - ar.interactionButton(ButtonStyle.Danger, "public.edit.btn.matchmanagement.cancel") { - this.label = "Cancel" + ar.interactionButton(ButtonStyle.Danger, "public.edit.btn.matchmanagement.decline") { + this.label = "I'm out!" } + /* + ar.interactionButton(ButtonStyle.Secondary, "public.edit.btn.matchmanagement.cancel") { + this.label = "Cancel this match..." + } */ return ar } fun replaceXWithYinValuesAtTable(x: String, y: String, e: Embed, table: Int): EmbedBuilder { - val ebb = MessageUtil.getAClonedEmbedd(e) - for ((i, f) in e.fields.withIndex()) { + return replaceXWithYinValuesAtTable(x, y, MessageUtil.getAClonedEmbed(e), table) + } + + fun replaceXWithYinValuesAtTable(x: String, y: String, ebb: EmbedBuilder, table: Int): EmbedBuilder { + val ebbb = MessageUtil.getAClonedEmbed(ebb) + ebbb.fields = mutableListOf() + for ((i, f) in ebb.fields.withIndex()) { val fb = EmbedBuilder.Field() fb.name = f.name if (i == table - 1) { @@ -66,9 +75,9 @@ object EmbedUtil { } else fb.value = f.value fb.inline = true - ebb.fields.add(fb) + ebbb.fields.add(fb) } - return ebb + return ebbb } fun getAllUsersInTheFirstXTables(amountOfTables: Int, e: Embed): List { @@ -87,8 +96,13 @@ object EmbedUtil { } fun addXToValuesAtTable(x: String, e: Embed, table: Int): EmbedBuilder { - val ebb = MessageUtil.getAClonedEmbedd(e) - for ((i, f) in e.fields.withIndex()) { + return addXToValuesAtTable(x, MessageUtil.getAClonedEmbed(e), table) + } + + fun addXToValuesAtTable(x: String, ebb: EmbedBuilder, table: Int): EmbedBuilder { + val ebbb = MessageUtil.getAClonedEmbed(ebb) + ebbb.fields = mutableListOf() + ebb.fields.forEachIndexed { i, f -> val fb = EmbedBuilder.Field() fb.name = f.name if (i == table - 1) @@ -105,9 +119,9 @@ object EmbedUtil { } fb.inline = true - ebb.fields.add(fb) + ebbb.fields.add(fb) } - return ebb + return ebbb } } From 9400a214031cef2396eb7b6375894541cdfeae14 Mon Sep 17 00:00:00 2001 From: moonleay Date: Mon, 11 Sep 2023 12:46:33 +0200 Subject: [PATCH 054/103] feat: added Unavailable to MatchExtension table Signed-off-by: moonleay --- .../kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt index be28081..4eb1db0 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt @@ -67,6 +67,7 @@ class MatchExtension : Extension() { "Registered by ${m.mention}", mapOf( "Signed up" to listOf(), + "Unavailable" to listOf(), ) ) ) @@ -120,7 +121,7 @@ class MatchExtension : Extension() { MatchJob( jobString, tableID.value, - "${args.matchType.readableName}_Vs_${opponent}_[${tableID.value}]-${gID}_${cID}" + "${args.matchType.readableName}_Vs_${opponent}_[${tableID.value}]-${gID}_${cID}", ) ) } From 308da651054250d9baaa5e59f257b4869840d714 Mon Sep 17 00:00:00 2001 From: moonleay Date: Mon, 11 Sep 2023 12:47:06 +0200 Subject: [PATCH 055/103] feat: improved function of AcceptEditButton Signed-off-by: moonleay --- .../buttons/matchplanner/AcceptEditButton.kt | 119 ++++++++++++++++++ .../matchplanner/SignMeUpEditButton.kt | 94 -------------- 2 files changed, 119 insertions(+), 94 deletions(-) create mode 100644 src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt delete mode 100644 src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/SignMeUpEditButton.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt new file mode 100644 index 0000000..c9f33e7 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt @@ -0,0 +1,119 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.buttons.matchplanner + +import dev.kord.common.entity.Snowflake +import dev.kord.core.behavior.edit +import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior +import dev.kord.core.entity.Guild +import dev.kord.core.entity.User +import dev.kord.core.entity.channel.MessageChannel +import dev.kord.core.entity.interaction.ButtonInteraction +import dev.kord.rest.builder.message.modify.embed +import net.moonleay.lilJudd.Bot +import net.moonleay.lilJudd.buttons.component.IEditButton +import net.moonleay.lilJudd.data.entry.MatchPlanningDataData +import net.moonleay.lilJudd.data.tables.MatchPlanningData +import net.moonleay.lilJudd.util.EmbedUtil +import net.moonleay.lilJudd.util.Logger +import net.moonleay.lilJudd.util.MessageUtil +import org.jetbrains.exposed.sql.and +import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.transactions.transaction + +class AcceptEditButton() : IEditButton { + override val id: String = "public.edit.btn.matchmanagement.accept" + + override suspend fun onInteraction( + interaction: ButtonInteraction, + response: PublicMessageInteractionResponseBehavior, + guild: Guild, + user: User + ) { + val m = interaction.message + val eb = MessageUtil.getAClonedEmbed(m.embeds[0]) + var shouldEditButton = false + lateinit var mpdd: MatchPlanningDataData + var found = false + transaction { + for (pnr in MatchPlanningData.select { + MatchPlanningData.messageid eq (interaction.message.id.value.toString()) and ( + MatchPlanningData.serverid eq (guild.id.value.toString())) and ( + MatchPlanningData.channelid eq (interaction.channelId.value.toString())) + }) { + mpdd = MatchPlanningDataData( + pnr[MatchPlanningData.id].value, + pnr[MatchPlanningData.serverid], + pnr[MatchPlanningData.channelid], + pnr[MatchPlanningData.matchtype], + pnr[MatchPlanningData.registererid], + pnr[MatchPlanningData.roleid], + pnr[MatchPlanningData.opponentName], + pnr[MatchPlanningData.messageid], + pnr[MatchPlanningData.timestamp], + pnr[MatchPlanningData.jobstr] + ) + found = true + } + } + if (!found || mpdd == null) { + return + } + val role = guild.getRoleOrNull(Snowflake(mpdd.roleid)) ?: return + val member = interaction.user.asMember(guild.id) ?: return + // do the checks and update + if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) { + if (member.roleIds.contains(Snowflake(mpdd.roleid))) { + Logger.out("Removing role from ${member.username}") + member.removeRole(role.id) + } + // remove the user from the 1st list in the embed + Logger.out("Removing ${user.username} from the 1st list in the embed") + eb.fields = EmbedUtil.replaceXWithYinValuesAtTable(user.id.value.toString(), "", eb, 1).fields + shouldEditButton = true + } + if (m.embeds[0].fields[1].value.contains(user.id.value.toString())) { + Logger.out("Removing ${user.username} from the 2nd list in the embed") + eb.fields = EmbedUtil.replaceXWithYinValuesAtTable(user.id.value.toString(), "", eb, 2).fields + shouldEditButton = true + } + if (!m.embeds[0].fields[0].value.contains(user.id.value.toString())) { + if (!member.roleIds.contains(Snowflake(mpdd.roleid))) { + Logger.out("Adding role to ${member.username}") + member.addRole(role.id) + } + //Add the user to the list in the embed + Logger.out("Adding ${user.username} to the 1st list in the embed") + eb.fields = EmbedUtil.addXToValuesAtTable(user.id.value.toString(), eb, 1).fields + shouldEditButton = true + } + if (shouldEditButton) { + // update the message + Bot.bot.kordRef.getChannelOf(interaction.channelId)!!.getMessage(m.id).edit { + this.embed { + this.color = eb.color + this.title = eb.title + this.description = eb.description + this.fields = eb.fields + this.footer = eb.footer + } + } + } + } +} diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/SignMeUpEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/SignMeUpEditButton.kt deleted file mode 100644 index fa47749..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/SignMeUpEditButton.kt +++ /dev/null @@ -1,94 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.buttons.matchplanner - -import dev.kord.common.entity.Snowflake -import dev.kord.core.behavior.edit -import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior -import dev.kord.core.entity.Guild -import dev.kord.core.entity.User -import dev.kord.core.entity.channel.MessageChannel -import dev.kord.core.entity.interaction.ButtonInteraction -import dev.kord.rest.builder.message.modify.embed -import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.buttons.component.IEditButton -import net.moonleay.lilJudd.data.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.tables.MatchPlanningData -import net.moonleay.lilJudd.util.EmbedUtil -import org.jetbrains.exposed.sql.and -import org.jetbrains.exposed.sql.select -import org.jetbrains.exposed.sql.transactions.transaction - -class SignMeUpEditButton() : IEditButton { - override val id: String = "public.edit.btn.matchmanagement.accept" - - override suspend fun onInteraction( - interaction: ButtonInteraction, - response: PublicMessageInteractionResponseBehavior, - guild: Guild, - user: User - ) { - val m = interaction.message - if (!m.embeds[0].fields[0].value.contains(user.id.value.toString())) { - lateinit var mpdd: MatchPlanningDataData - var found = false - transaction { - for (pnr in MatchPlanningData.select { - MatchPlanningData.messageid eq (interaction.message.id.value.toString()) and ( - MatchPlanningData.serverid eq (guild.id.value.toString())) and ( - MatchPlanningData.channelid eq (interaction.channelId.value.toString())) - }) { - mpdd = MatchPlanningDataData( - pnr[MatchPlanningData.id].value, - pnr[MatchPlanningData.serverid], - pnr[MatchPlanningData.channelid], - pnr[MatchPlanningData.matchtype], - pnr[MatchPlanningData.registererid], - pnr[MatchPlanningData.roleid], - pnr[MatchPlanningData.opponentName], - pnr[MatchPlanningData.messageid], - pnr[MatchPlanningData.timestamp], - pnr[MatchPlanningData.jobstr] - ) - found = true - } - } - if (!found || mpdd == null) { - return - } - val role = guild.getRoleOrNull(Snowflake(mpdd.roleid)) ?: return - val member = interaction.user.asMember(guild.id) - if (!member.roleIds.contains(Snowflake(mpdd.roleid))) { - member.addRole(role.id) - } - - //Add the user to the list in the embed - Bot.bot.kordRef.getChannelOf(interaction.channelId)!!.getMessage(m.id).edit { - this.embed { - val temp = EmbedUtil.addXToValuesAtTable(user.id.value.toString(), m.embeds[0], 1) - this.color = temp.color - this.title = temp.title - this.description = temp.description - this.fields = temp.fields - this.footer = temp.footer - } - } - } - } -} From 63fb1c0c8f6ba95829517b52c6e3f2689c1b7fa8 Mon Sep 17 00:00:00 2001 From: moonleay Date: Mon, 11 Sep 2023 12:47:31 +0200 Subject: [PATCH 056/103] feat: added DeclineEditButton Signed-off-by: moonleay --- .../buttons/component/EditButtonManager.kt | 8 +- .../buttons/matchplanner/DeclineEditButton.kt | 119 ++++++++++++++++++ 2 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/component/EditButtonManager.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/component/EditButtonManager.kt index 070f25a..f0df57f 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/component/EditButtonManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/component/EditButtonManager.kt @@ -18,8 +18,9 @@ package net.moonleay.lilJudd.buttons.component +import net.moonleay.lilJudd.buttons.matchplanner.AcceptEditButton import net.moonleay.lilJudd.buttons.matchplanner.CancelEditButton -import net.moonleay.lilJudd.buttons.matchplanner.SignMeUpEditButton +import net.moonleay.lilJudd.buttons.matchplanner.DeclineEditButton import net.moonleay.lilJudd.buttons.timeplanner.IsAvailableEditButton import net.moonleay.lilJudd.buttons.timeplanner.MaybeAvailableEditButton import net.moonleay.lilJudd.buttons.timeplanner.NotAvailableEditButton @@ -29,7 +30,8 @@ object EditButtonManager { IsAvailableEditButton(), MaybeAvailableEditButton(), NotAvailableEditButton(), - SignMeUpEditButton(), - CancelEditButton() + AcceptEditButton(), + CancelEditButton(), + DeclineEditButton(), ) } diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt new file mode 100644 index 0000000..67b193e --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt @@ -0,0 +1,119 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.buttons.matchplanner + +import dev.kord.common.entity.Snowflake +import dev.kord.core.behavior.edit +import dev.kord.core.behavior.interaction.response.PublicMessageInteractionResponseBehavior +import dev.kord.core.entity.Guild +import dev.kord.core.entity.User +import dev.kord.core.entity.channel.MessageChannel +import dev.kord.core.entity.interaction.ButtonInteraction +import dev.kord.rest.builder.message.modify.embed +import net.moonleay.lilJudd.Bot +import net.moonleay.lilJudd.buttons.component.IEditButton +import net.moonleay.lilJudd.data.entry.MatchPlanningDataData +import net.moonleay.lilJudd.data.tables.MatchPlanningData +import net.moonleay.lilJudd.util.EmbedUtil +import net.moonleay.lilJudd.util.Logger +import net.moonleay.lilJudd.util.MessageUtil +import org.jetbrains.exposed.sql.and +import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.transactions.transaction + +class DeclineEditButton : IEditButton { + override val id: String = "public.edit.btn.matchmanagement.decline" + + override suspend fun onInteraction( + interaction: ButtonInteraction, + response: PublicMessageInteractionResponseBehavior, + guild: Guild, + user: User + ) { + val m = interaction.message + val eb = MessageUtil.getAClonedEmbed(m.embeds[0]) + var shouldEditButton = false + lateinit var mpdd: MatchPlanningDataData + var found = false + transaction { + for (pnr in MatchPlanningData.select { + MatchPlanningData.messageid eq (interaction.message.id.value.toString()) and ( + MatchPlanningData.serverid eq (guild.id.value.toString())) and ( + MatchPlanningData.channelid eq (interaction.channelId.value.toString())) + }) { + mpdd = MatchPlanningDataData( + pnr[MatchPlanningData.id].value, + pnr[MatchPlanningData.serverid], + pnr[MatchPlanningData.channelid], + pnr[MatchPlanningData.matchtype], + pnr[MatchPlanningData.registererid], + pnr[MatchPlanningData.roleid], + pnr[MatchPlanningData.opponentName], + pnr[MatchPlanningData.messageid], + pnr[MatchPlanningData.timestamp], + pnr[MatchPlanningData.jobstr] + ) + found = true + } + } + if (!found || mpdd == null) { + return + } + val role = guild.getRoleOrNull(Snowflake(mpdd.roleid)) ?: return + val member = interaction.user.asMember(guild.id) ?: return + if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) { + if (member.roleIds.contains(Snowflake(mpdd.roleid))) { + Logger.out("Removing role from ${member.username}") + member.removeRole(role.id) + } + // remove the user from the 1st list in the embed + Logger.out("Removing ${user.username} from the 1st list in the embed") + eb.fields = EmbedUtil.replaceXWithYinValuesAtTable(user.id.value.toString(), "", eb, 1).fields + shouldEditButton = true + } + if (!m.embeds[0].fields[1].value.contains(user.id.value.toString())) { + if (member.roleIds.contains(Snowflake(mpdd.roleid))) { + Logger.out("Removing role from ${member.username}") + member.removeRole(role.id) + } + // Add the user to the list in the embed + Logger.out("Adding ${user.username} to the 2nd list in the embed") + eb.fields = EmbedUtil.addXToValuesAtTable(user.id.value.toString(), eb, 2).fields + shouldEditButton = true + } + if (m.embeds[0].fields[1].value.contains(user.id.value.toString())) { + // Remove the user from all tables + Logger.out("Removing ${user.username} from the 2nd list in the embed") + eb.fields = EmbedUtil.replaceXWithYinValuesAtTable(user.id.value.toString(), "", eb, 2).fields + shouldEditButton = true + } + if (shouldEditButton) { + // update the message + Bot.bot.kordRef.getChannelOf(interaction.channelId)!!.getMessage(m.id).edit { + this.embed { + this.color = eb.color + this.title = eb.title + this.description = eb.description + this.fields = eb.fields + this.footer = eb.footer + } + } + } + } +} From d97511eb8b8dc842a9bf875e78985c6bb169c30e Mon Sep 17 00:00:00 2001 From: moonleay Date: Mon, 11 Sep 2023 12:48:33 +0200 Subject: [PATCH 057/103] chore: bump version Signed-off-by: moonleay --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3292b17..fed49e9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,7 @@ val ownerID = 372703841151614976L group = "net.moonleay.liljudd" version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } - ?: "2.4.3" + ?: "2.5.0" val kordver = "1.5.6" val coroutinesver = "1.1.0" From 1424e31e2a5d63a1c8763fec1223c59e0211e2aa Mon Sep 17 00:00:00 2001 From: moonleay Date: Mon, 11 Sep 2023 13:35:17 +0200 Subject: [PATCH 058/103] chore: moved to proper data types in columns Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/Bot.kt | 3 +++ .../buttons/matchplanner/AcceptEditButton.kt | 8 +++---- .../buttons/matchplanner/CancelEditButton.kt | 8 +++---- .../buttons/matchplanner/DeclineEditButton.kt | 8 +++---- .../kotlin/net/moonleay/lilJudd/data/DB.kt | 20 ++++++++++++++++ .../data/entry/MatchPlanningDataData.kt | 12 +++++----- .../data/entry/PlanningNotifierRolesData.kt | 8 +++---- .../data/entry/TimePlanningMessagesData.kt | 6 ++--- .../lilJudd/data/tables/MatchPlanningData.kt | 17 ++++++------- .../data/tables/PlanningNotifierRoles.kt | 13 +++++----- .../data/tables/TimePlanningChannels.kt | 10 ++++---- .../data/tables/TimePlanningMessages.kt | 11 +++++---- .../extensions/FeatureManageExtension.kt | 4 ++-- .../lilJudd/extensions/MatchExtension.kt | 24 +++++++++---------- .../extensions/SendPlannerExtension.kt | 6 ++--- .../lilJudd/features/AvailabilityManager.kt | 16 ++++++------- .../moonleay/lilJudd/features/MatchManager.kt | 8 +++---- .../moonleay/lilJudd/features/TimeManager.kt | 14 +++++------ .../lilJudd/features/component/IFeature.kt | 8 +++---- .../net/moonleay/lilJudd/jobs/MatchJob.kt | 2 +- 20 files changed, 117 insertions(+), 89 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt index 1c6e337..6f6d47f 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt @@ -76,6 +76,9 @@ object Bot { CredentialManager.dbPassword ) + // Make sure the database is up-to-date + DB.register() + // Register all the jobs jobs.addAll( listOf( diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt index c9f33e7..55765ee 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt @@ -53,12 +53,12 @@ class AcceptEditButton() : IEditButton { var found = false transaction { for (pnr in MatchPlanningData.select { - MatchPlanningData.messageid eq (interaction.message.id.value.toString()) and ( - MatchPlanningData.serverid eq (guild.id.value.toString())) and ( - MatchPlanningData.channelid eq (interaction.channelId.value.toString())) + MatchPlanningData.messageid eq (interaction.message.id.value.toLong()) and ( + MatchPlanningData.serverid eq (guild.id.value.toLong())) and ( + MatchPlanningData.channelid eq (interaction.channelId.value.toLong())) }) { mpdd = MatchPlanningDataData( - pnr[MatchPlanningData.id].value, + pnr[MatchPlanningData.id], pnr[MatchPlanningData.serverid], pnr[MatchPlanningData.channelid], pnr[MatchPlanningData.matchtype], diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt index 3925cd3..4f70ab7 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt @@ -50,12 +50,12 @@ class CancelEditButton : IEditButton { var found = false transaction { for (pnr in MatchPlanningData.select { - MatchPlanningData.messageid eq (interaction.message.id.value.toString()) and ( - MatchPlanningData.serverid eq (guild.id.value.toString())) and ( - MatchPlanningData.channelid eq (interaction.channelId.value.toString())) + MatchPlanningData.messageid eq (interaction.message.id.value.toLong()) and ( + MatchPlanningData.serverid eq (guild.id.value.toLong())) and ( + MatchPlanningData.channelid eq (interaction.channelId.value.toLong())) }) { mpdd = MatchPlanningDataData( - pnr[MatchPlanningData.id].value, + pnr[MatchPlanningData.id], pnr[MatchPlanningData.serverid], pnr[MatchPlanningData.channelid], pnr[MatchPlanningData.matchtype], diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt index 67b193e..3d0e0bd 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt @@ -53,12 +53,12 @@ class DeclineEditButton : IEditButton { var found = false transaction { for (pnr in MatchPlanningData.select { - MatchPlanningData.messageid eq (interaction.message.id.value.toString()) and ( - MatchPlanningData.serverid eq (guild.id.value.toString())) and ( - MatchPlanningData.channelid eq (interaction.channelId.value.toString())) + MatchPlanningData.messageid eq (interaction.message.id.value.toLong()) and ( + MatchPlanningData.serverid eq (guild.id.value.toLong())) and ( + MatchPlanningData.channelid eq (interaction.channelId.value.toLong())) }) { mpdd = MatchPlanningDataData( - pnr[MatchPlanningData.id].value, + pnr[MatchPlanningData.id], pnr[MatchPlanningData.serverid], pnr[MatchPlanningData.channelid], pnr[MatchPlanningData.matchtype], diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt b/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt index b1ff4b7..f0711de 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt @@ -19,9 +19,16 @@ package net.moonleay.lilJudd.data +import net.moonleay.lilJudd.data.tables.MatchPlanningData +import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles +import net.moonleay.lilJudd.data.tables.TimePlanningChannels +import net.moonleay.lilJudd.data.tables.TimePlanningMessages import org.jetbrains.exposed.sql.Database +import org.jetbrains.exposed.sql.SchemaUtils +import org.jetbrains.exposed.sql.transactions.transaction object DB { + private var connected = false //Connect to the provided DB; trows errors, if the DB is not avalible. fun connect(dbDomain: String, dbName: String, dbUser: String, dbPasswd: String) { Database.connect( @@ -30,5 +37,18 @@ object DB { user = dbUser, password = dbPasswd ) + connected = true + } + + fun register() { + if (!connected) + return + // Register tables here + transaction { + SchemaUtils.create(TimePlanningChannels) + SchemaUtils.create(TimePlanningMessages) + SchemaUtils.create(MatchPlanningData) + SchemaUtils.create(PlanningNotifierRoles) + } } } diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt index ca0bd32..451278e 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt @@ -20,13 +20,13 @@ package net.moonleay.lilJudd.data.entry data class MatchPlanningDataData( val id: Int, - val serverid: String, - val channelid: String, + val serverid: Long, + val channelid: Long, val matchtype: String, - val registererid: String, - val roleid: String, + val registererid: Long, + val roleid: Long, val opponentname: String, - val messageid: String, - val timestamp: String, + val messageid: Long, + val timestamp: Long, val jobstr: String ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt index 8cba107..fc15729 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt @@ -19,8 +19,8 @@ package net.moonleay.lilJudd.data.entry data class PlanningNotifierRolesData( - val serverID: String, // The id of the server - val channelId: String, // The id of the channel - val hastimeroleid: String, // The id of the role that has time today - val wantstobenotifid: String // The id of the role that wants to be notified + val serverID: Long, // The id of the server + val channelId: Long, // The id of the channel + val hastimeroleid: Long, // The id of the role that has time today + val wantstobenotifid: Long // The id of the role that wants to be notified ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt index 3da4ba8..c4de368 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt @@ -19,8 +19,8 @@ package net.moonleay.lilJudd.data.entry data class TimePlanningMessagesData( - val serverid: String, // The discord server id - val channelid: String, // The discord channel id - val weekstamp: String, // The timestamp of the monday of the week at 4am UTC + val serverid: Long, // The discord server id + val channelid: Long, // The discord channel id + val weekstamp: Long, // The timestamp of the monday of the week at 4am UTC val messageids: String // IDs are in the following format: "{weekdayNr}:{id};{weekdayNr}:{id};[etc.]" ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/tables/MatchPlanningData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/tables/MatchPlanningData.kt index 2de3ece..e2e8afa 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/tables/MatchPlanningData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/tables/MatchPlanningData.kt @@ -18,16 +18,17 @@ package net.moonleay.lilJudd.data.tables -import org.jetbrains.exposed.dao.id.IntIdTable +import org.jetbrains.exposed.sql.Table -object MatchPlanningData : IntIdTable() { - var serverid = varchar("serverid", 50) - var channelid = varchar("channelid", 50) +object MatchPlanningData : Table(name = "new_matchplanning_data") { + var id = integer("id").autoIncrement() + var serverid = long("serverid") + var channelid = long("channelid") var matchtype = varchar("matchtype", 50) - var registererid = varchar("registererid", 50) - var roleid = varchar("roleid", 50) + var registererid = long("registererid") + var roleid = long("roleid") var opponentName = varchar("opponentname", 100) - var messageid = varchar("messageid", 50) - var timestamp = varchar("timestamp", 50) + var messageid = long("messageid") + var timestamp = long("timestamp") var jobstr = varchar("jobstr", 50) } diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/tables/PlanningNotifierRoles.kt b/src/main/kotlin/net/moonleay/lilJudd/data/tables/PlanningNotifierRoles.kt index d8d3b9d..e2fc9e0 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/tables/PlanningNotifierRoles.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/tables/PlanningNotifierRoles.kt @@ -18,11 +18,12 @@ package net.moonleay.lilJudd.data.tables -import org.jetbrains.exposed.dao.id.IntIdTable +import org.jetbrains.exposed.sql.Table -object PlanningNotifierRoles : IntIdTable() { - var serverid = varchar("serverid", 50) - var channelid = varchar("channelid", 50) - var hastimeroleid = varchar("hastimeroleid", 50) - var wantstobenotifiedid = varchar("wantstobenotifiedid", 50) +object PlanningNotifierRoles : Table(name = "new_planningnotifier_roles") { + var id = integer("id").autoIncrement() + var serverid = long("serverid") + var channelid = long("channelid") + var hastimeroleid = long("hastimeroleid") + var wantstobenotifiedid = long("wantstobenotifiedid") } diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningChannels.kt b/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningChannels.kt index a746aa1..a521838 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningChannels.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningChannels.kt @@ -18,9 +18,11 @@ package net.moonleay.lilJudd.data.tables -import org.jetbrains.exposed.dao.id.IntIdTable +import org.jetbrains.exposed.sql.Table -object TimePlanningChannels : IntIdTable() { - var serverid = varchar("serverid", 50) - val channelid = varchar("channelid", 50) + +object TimePlanningChannels : Table(name = "new_timeplanning_channels") { + var id = integer("id").autoIncrement() + var serverid = long("serverid") + val channelid = long("channelid") } diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningMessages.kt b/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningMessages.kt index 7498edb..8f8a01b 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningMessages.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningMessages.kt @@ -18,11 +18,12 @@ package net.moonleay.lilJudd.data.tables -import org.jetbrains.exposed.dao.id.IntIdTable +import org.jetbrains.exposed.sql.Table -object TimePlanningMessages : IntIdTable() { - var serverid = varchar("serverid", 50) - var channelid = varchar("channelid", 50) - var weekstamp = varchar("weekstamp", 50) +object TimePlanningMessages : Table(name = "new_timeplanning_messages") { + var id = integer("id").autoIncrement() + var serverid = long("serverid") + var channelid = long("channelid") + var weekstamp = long("weekstamp") var messageids = varchar("messageids", 200) } diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt index 48f68e9..eac08c6 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt @@ -60,8 +60,8 @@ class FeatureManageExtension : Extension() { } return@action } - val gID = this.guild!!.id.toString() - val cID = this.arguments.channel.id.toString() + val gID = this.guild!!.id.value.toLong() + val cID = this.arguments.channel.id.value.toLong() val channel = this.arguments.channel val args = this.arguments Logger.out("${args.feature.readableName} ${args.setStatus.readableName} ${channel.data.name.value}") diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt index 4eb1db0..3be70f7 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt @@ -36,9 +36,9 @@ import net.moonleay.lilJudd.jobs.component.JobManager import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.MessageUtil import net.moonleay.lilJudd.util.TimeUtil -import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.transactions.transaction +import kotlin.properties.Delegates class MatchExtension : Extension() { @@ -54,8 +54,8 @@ class MatchExtension : Extension() { this.action { val args = this.arguments val m = this.member!! - val gID = this.guild!!.id.value.toString() - val cID = this.channel.id.value.toString() + val gID = this.guild!!.id.value + val cID = this.channel.id.value val opponent = args.opponent ?: "?" val msg = this.respond { this.embeds.add( @@ -100,17 +100,17 @@ class MatchExtension : Extension() { } return@action } - lateinit var tableID: EntityID + var tableID by Delegates.notNull() transaction { tableID = MatchPlanningData.insert { - it[MatchPlanningData.serverid] = gID - it[MatchPlanningData.channelid] = cID - it[MatchPlanningData.messageid] = msg.id.value.toString() + it[MatchPlanningData.serverid] = gID.toLong() + it[MatchPlanningData.channelid] = cID.toLong() + it[MatchPlanningData.messageid] = msg.id.value.toLong() it[MatchPlanningData.matchtype] = args.matchType.readableName - it[MatchPlanningData.roleid] = role.id.value.toString() - it[MatchPlanningData.registererid] = m.id.value.toString() + it[MatchPlanningData.roleid] = role.id.value.toLong() + it[MatchPlanningData.registererid] = m.id.value.toLong() it[MatchPlanningData.opponentName] = opponent - it[MatchPlanningData.timestamp] = (zdt.toEpochSecond() * 1000).toString() + it[MatchPlanningData.timestamp] = (zdt.toEpochSecond() * 1000) it[MatchPlanningData.jobstr] = jobString } get MatchPlanningData.id } @@ -120,8 +120,8 @@ class MatchExtension : Extension() { JobManager.addJob( MatchJob( jobString, - tableID.value, - "${args.matchType.readableName}_Vs_${opponent}_[${tableID.value}]-${gID}_${cID}", + tableID, + "${args.matchType.readableName}_Vs_${opponent}_[${tableID}]-${gID}_${cID}", ) ) } diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt index c02294e..0e53f7b 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt @@ -107,9 +107,9 @@ class SendPlannerExtension : Extension() { // Save the message ids transaction { TimePlanningMessages.insert { - it[TimePlanningMessages.serverid] = c.data.guildId.value.toString() - it[TimePlanningMessages.channelid] = c.id.value.toString() - it[TimePlanningMessages.weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000).toString() + it[TimePlanningMessages.serverid] = c.data.guildId.value?.value!!.toLong() + it[TimePlanningMessages.channelid] = c.id.value.toLong() + it[TimePlanningMessages.weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000) it[TimePlanningMessages.messageids] = msgStr } get TimePlanningMessages.id } diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index 2a980dc..d9fff00 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -56,11 +56,11 @@ object AvailabilityManager : IFeature { // ChannelID, Data val messageMap = mutableMapOf() // ChannelID, Data - val roleMap = mutableMapOf() + val roleMap = mutableMapOf() transaction { for (pnr in TimePlanningMessages.select { - TimePlanningMessages.weekstamp eq (TimeUtil.getWeekStamp().toEpochSecond() * 1000).toString() + TimePlanningMessages.weekstamp eq (TimeUtil.getWeekStamp().toEpochSecond() * 1000) }) { messageMap[Snowflake(pnr[TimePlanningMessages.channelid])] = TimePlanningMessagesData( @@ -169,8 +169,8 @@ object AvailabilityManager : IFeature { override suspend fun enable( u: UserBehavior, - gID: String, - cID: String, + gID: Long, + cID: Long, ch: Channel, args: FeatureManageExtension.FeatureManagerArgs ): EmbedBuilder { @@ -187,13 +187,13 @@ object AvailabilityManager : IFeature { this.name = "available [${ch.data.name.value}]" this.mentionable = true } - val htr = hasTimeRole.id.toString() + val htr = hasTimeRole.id.value.toLong() val wantsNotifsRole = Bot.bot.kordRef.getGuildOrThrow(Snowflake(gID)).createRole { this.name = "notifications [${ch.data.name.value}]" this.mentionable = true } - val wnr = wantsNotifsRole.id.toString() + val wnr = wantsNotifsRole.id.value.toLong() // Save the role ids to db transaction { @@ -224,8 +224,8 @@ object AvailabilityManager : IFeature { override suspend fun disable( u: UserBehavior, - gID: String, - cID: String, + gID: Long, + cID: Long, ch: Channel, args: FeatureManageExtension.FeatureManagerArgs ): EmbedBuilder { diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt index a92ad6a..1591545 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt @@ -38,7 +38,7 @@ object MatchManager { MatchPlanningData.selectAll().forEach { dataList.add( MatchPlanningDataData( - it[MatchPlanningData.id].value, + it[MatchPlanningData.id], it[MatchPlanningData.serverid], it[MatchPlanningData.channelid], it[MatchPlanningData.matchtype], @@ -79,9 +79,9 @@ object MatchManager { Logger.out("Registered job for match ${data.id}...") } - private suspend fun removeRoleFromGuild(gid: String, rid: String): Boolean { - val guild = Bot.bot.kordRef.getGuildOrNull(Snowflake(gid.toLong())) ?: return false - val role = guild.getRoleOrNull(Snowflake(rid.toLong())) ?: return false + private suspend fun removeRoleFromGuild(gid: Long, rid: Long): Boolean { + val guild = Bot.bot.kordRef.getGuildOrNull(Snowflake(gid)) ?: return false + val role = guild.getRoleOrNull(Snowflake(rid)) ?: return false role.delete() return true } diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt index 9acbc33..2058c11 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt @@ -151,9 +151,9 @@ object TimeManager : IFeature { // Save the message ids transaction { TimePlanningMessages.insert { - it[TimePlanningMessages.serverid] = c.data.guildId.value.toString() - it[TimePlanningMessages.channelid] = c.id.value.toString() - it[TimePlanningMessages.weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000).toString() + it[TimePlanningMessages.serverid] = c.data.guildId.value?.value!!.toLong() + it[TimePlanningMessages.channelid] = c.id.value.toLong() + it[TimePlanningMessages.weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000) it[TimePlanningMessages.messageids] = msgStr } get TimePlanningMessages.id } @@ -164,8 +164,8 @@ object TimeManager : IFeature { override suspend fun enable( u: UserBehavior, - gID: String, - cID: String, + gID: Long, + cID: Long, ch: Channel, args: FeatureManageExtension.FeatureManagerArgs ): EmbedBuilder { @@ -200,8 +200,8 @@ object TimeManager : IFeature { override suspend fun disable( u: UserBehavior, - gID: String, - cID: String, + gID: Long, + cID: Long, ch: Channel, args: FeatureManageExtension.FeatureManagerArgs ): EmbedBuilder { diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/component/IFeature.kt b/src/main/kotlin/net/moonleay/lilJudd/features/component/IFeature.kt index aa27536..1145797 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/component/IFeature.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/component/IFeature.kt @@ -29,16 +29,16 @@ interface IFeature { suspend fun enable( u: UserBehavior, - gID: String, - cID: String, + gID: Long, + cID: Long, ch: Channel, args: FeatureManageExtension.FeatureManagerArgs ): EmbedBuilder suspend fun disable( u: UserBehavior, - gID: String, - cID: String, + gID: Long, + cID: Long, ch: Channel, args: FeatureManageExtension.FeatureManagerArgs ): EmbedBuilder diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt index 394758a..89b33e4 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt @@ -54,7 +54,7 @@ class MatchJob( MatchPlanningData.id eq (tableId) }) { mpdd = MatchPlanningDataData( - pnr[MatchPlanningData.id].value, + pnr[MatchPlanningData.id], pnr[MatchPlanningData.serverid], pnr[MatchPlanningData.channelid], pnr[MatchPlanningData.matchtype], From 990387fed2dacf80d289c39f808fb79f0a734844 Mon Sep 17 00:00:00 2001 From: moonleay Date: Mon, 11 Sep 2023 14:26:43 +0200 Subject: [PATCH 059/103] chore: bump version Signed-off-by: moonleay --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index fed49e9..0bc0943 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,7 @@ val ownerID = 372703841151614976L group = "net.moonleay.liljudd" version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } - ?: "2.5.0" + ?: "2.5.1" val kordver = "1.5.6" val coroutinesver = "1.1.0" From de1d8cd3a675e2484127caf38e8de7b45f243249 Mon Sep 17 00:00:00 2001 From: moonleay Date: Mon, 11 Sep 2023 14:46:40 +0200 Subject: [PATCH 060/103] fix: fixed grammar Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/data/DB.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt b/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt index f0711de..f02009e 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt @@ -29,7 +29,8 @@ import org.jetbrains.exposed.sql.transactions.transaction object DB { private var connected = false - //Connect to the provided DB; trows errors, if the DB is not avalible. + + //Connect to the provided DB; trows errors, if the DB is not available. fun connect(dbDomain: String, dbName: String, dbUser: String, dbPasswd: String) { Database.connect( "jdbc:postgresql://$dbDomain/$dbName", From 7e0c8e5a9f749ebcd3d6b79b79edbcb1967f4916 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 07:44:43 +0200 Subject: [PATCH 061/103] feat: moved update logic into "updateInChannel" function, updated the function in Timeplanner buttons Signed-off-by: moonleay --- .../timeplanner/IsAvailableEditButton.kt | 2 +- .../timeplanner/MaybeAvailableEditButton.kt | 2 +- .../timeplanner/NotAvailableEditButton.kt | 2 +- .../lilJudd/features/AvailabilityManager.kt | 168 ++++++++++++------ 4 files changed, 114 insertions(+), 60 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/IsAvailableEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/IsAvailableEditButton.kt index 6140d4d..9dbae16 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/IsAvailableEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/IsAvailableEditButton.kt @@ -63,6 +63,6 @@ class IsAvailableEditButton : IEditButton { } } } - AvailabilityManager.runThread() + AvailabilityManager.updateInChannel(interaction.channelId) } } diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/MaybeAvailableEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/MaybeAvailableEditButton.kt index c3eaec2..01cf792 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/MaybeAvailableEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/MaybeAvailableEditButton.kt @@ -63,6 +63,6 @@ class MaybeAvailableEditButton : IEditButton { } } } - AvailabilityManager.runThread() + AvailabilityManager.updateInChannel(interaction.channelId) } } diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/NotAvailableEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/NotAvailableEditButton.kt index b56db11..ade9557 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/NotAvailableEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/timeplanner/NotAvailableEditButton.kt @@ -63,6 +63,6 @@ class NotAvailableEditButton : IEditButton { } } } - AvailabilityManager.runThread() + AvailabilityManager.updateInChannel(interaction.channelId) } } diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index d9fff00..f414967 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -81,15 +81,10 @@ object AvailabilityManager : IFeature { } } - val weekday = ZonedDateTime.now().dayOfWeek // The current week day - val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() * 1000 // The current week time stamp - Logger.out("It is week ${weekStamp} and day ${weekday}/${TimeUtil.getDayOfMonthInt(weekday)} of the week.") for (snf in messageMap.keys) { // snf = Snowflake val data = messageMap[snf]!! // this is the data of the table if (Bot.bot.kordRef.getChannel(Snowflake(data.channelid)) == null) continue // This channel does not exist anymore. - val c = - Bot.bot.kordRef.getChannelOf(Snowflake(data.channelid))!! // Get the channel as MessageChannel if (roleMap.isEmpty()) { Logger.out("No saved roles. Canceling.") return @@ -99,62 +94,121 @@ object AvailabilityManager : IFeature { Logger.out("Role for channel ${data.channelid} does not exist") continue // this took way to long to find out that this was the issue } - val g = Bot.bot.kordRef.getGuildOrThrow(Snowflake(data.serverid)) - // Get all members with the role - val mce = g.requestMembers { - this.requestAllMembers() - } - mce.collect { memberchunkevent -> - memberchunkevent.members.forEach { - Logger.out("Checking member ${it.id.value} (${it.username})") - if (it.roleIds.contains(Snowflake(roleData.hastimeroleid))) { - it.removeRole(Snowflake(roleData.hastimeroleid)) - Logger.out("Removed role from ${it.username}") // Removed the role - } - } - } - - Logger.out("Got through all members") - // This stores the ids of the messages. - // The format is weekdaNR:ID - // The last entry (nr 8) is empty, so we can ignore it - val messageIdSplit = data.messageids.split(";").subList(0, 7) - for (mid in messageIdSplit) { - Logger.out("Checking id $mid") - if (!mid.startsWith((TimeUtil.getDayOfMonthInt(weekday) - 1).toString(), true)) - continue // This is not the right message, check the next one - val idFiltered = mid.split(":")[1] // This is the target message id - val message = c.getMessageOrNull(Snowflake(idFiltered)) // Get the message from the channel - if (message == null) { - Logger.out("Could not find message.") - break // This message does not exist anymore. Nothing we can do about that. - } - if (message.data.embeds.isEmpty()) { - Logger.out("There are no embeds.") - break // There are no embeds or there are not enough embeds - } - val targets = EmbedUtil.getAllUsersInTheFirstXTables(2, message.embeds[0]) - for (tid in targets) { - Logger.out("Checking id $tid") - if (Bot.bot.kordRef.getGuildOrNull(Snowflake(data.serverid))!! - .getMemberOrNull(Snowflake(tid)) == null - ) - continue // This member does not exist anymore. - val member = Bot.bot.kordRef.getGuildOrThrow(Snowflake(data.serverid)) - .getMember(Snowflake(tid)) // Get the member - if (member.roleIds.contains(Snowflake(roleData.hastimeroleid))) - continue // This member already has the role - member.addRole(Snowflake(roleData.hastimeroleid)) // Add the role - Logger.out("Added role to ${member.username}") - } - Logger.out("Done with message. Moving on...") - // We found the right message. We don't need to check the others. - break - } + this.updateInChannel(snf, data, roleData) } Logger.out("Done! Until tomorrow! <3 ") } + suspend fun updateInChannel(snf: Snowflake) { + lateinit var data: TimePlanningMessagesData + lateinit var roleData: PlanningNotifierRolesData + var found1 = false + var found2 = false + for (pnr in TimePlanningMessages.select { + TimePlanningMessages.weekstamp eq (TimeUtil.getWeekStamp() + .toEpochSecond() * 1000) and (TimePlanningMessages.channelid eq (snf.value.toLong())) + }) { + data = + TimePlanningMessagesData( + pnr[TimePlanningMessages.serverid], + pnr[TimePlanningMessages.channelid], + pnr[TimePlanningMessages.weekstamp], + pnr[TimePlanningMessages.messageids] + ) + found1 = true + } + for (pnr in PlanningNotifierRoles.select { + PlanningNotifierRoles.channelid eq (snf.value.toLong()) + }) { + roleData = + PlanningNotifierRolesData( + pnr[PlanningNotifierRoles.serverid], + pnr[PlanningNotifierRoles.channelid], + pnr[PlanningNotifierRoles.hastimeroleid], + pnr[PlanningNotifierRoles.wantstobenotifiedid] + ) + found2 = true + } + if (!found1 || !found2) { + Logger.out("Could not find data for channel ${snf.value}") + return + } + if (Bot.bot.kordRef.getChannel(Snowflake(data.channelid)) == null) + return // This channel does not exist anymore. + if (roleData == null) { + Logger.out("Role for channel ${data.channelid} does not exist") + return // this took way to long to find out that this was the issue + } + updateInChannel(snf, data, roleData) + } + + @OptIn(PrivilegedIntent::class) + suspend fun updateInChannel(snf: Snowflake, tpmd: TimePlanningMessagesData, pnrd: PlanningNotifierRolesData) { + if (Bot.bot.kordRef.getChannel(Snowflake(tpmd.channelid)) == null) + return // This channel does not exist anymore. + val c = + Bot.bot.kordRef.getChannelOf(Snowflake(tpmd.channelid))!! // Get the channel as MessageChannel + if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverid)) == null) { + Logger.out("Guild not found.") + return + } + val weekday = ZonedDateTime.now().dayOfWeek // The current week day + val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() * 1000 // The current week time stamp + Logger.out("It is week ${weekStamp} and day ${weekday}/${TimeUtil.getDayOfMonthInt(weekday)} of the week.") + val g = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverid)) + // Get all members with the role + val mce = g.requestMembers { + this.requestAllMembers() + } + mce.collect { memberchunkevent -> + memberchunkevent.members.forEach { + Logger.out("Checking member ${it.id.value} (${it.username})") + if (it.roleIds.contains(Snowflake(pnrd.hastimeroleid))) { + it.removeRole(Snowflake(pnrd.hastimeroleid)) + Logger.out("Removed role from ${it.username}") // Removed the role + } + } + } + + Logger.out("Got through all members") + // This stores the ids of the messages. + // The format is weekdaNR:ID + // The last entry (nr 8) is empty, so we can ignore it + val messageIdSplit = tpmd.messageids.split(";").subList(0, 7) + for (mid in messageIdSplit) { + Logger.out("Checking id $mid") + if (!mid.startsWith((TimeUtil.getDayOfMonthInt(weekday) - 1).toString(), true)) + continue// This is not the right message, check the next one + val idFiltered = mid.split(":")[1] // This is the target message id + val message = c.getMessageOrNull(Snowflake(idFiltered)) // Get the message from the channel + if (message == null) { + Logger.out("Could not find message.") + return // This message does not exist anymore. Nothing we can do about that. + } + if (message.data.embeds.isEmpty()) { + Logger.out("There are no embeds.") + return // There are no embeds or there are not enough embeds + } + val targets = EmbedUtil.getAllUsersInTheFirstXTables(2, message.embeds[0]) + for (tid in targets) { + Logger.out("Checking id $tid") + if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverid))!! + .getMemberOrNull(Snowflake(tid)) == null + ) + continue// This member does not exist anymore. + val member = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverid)) + .getMember(Snowflake(tid)) // Get the member + if (member.roleIds.contains(Snowflake(pnrd.hastimeroleid))) + continue // This member already has the role + member.addRole(Snowflake(pnrd.hastimeroleid)) // Add the role + Logger.out("Added role to ${member.username}") + } + Logger.out("Done with message. Moving on...") + // We found the right message. We don't need to check the others. + break + } + } + override val feat: FeatureEnum get() = FeatureEnum.PLANNINGROLES From 3d1f2c7d8f46d55bfbf157701b3b5d0f162e969b Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 07:46:07 +0200 Subject: [PATCH 062/103] chore: bump version Signed-off-by: moonleay --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0bc0943..7844542 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,7 @@ val ownerID = 372703841151614976L group = "net.moonleay.liljudd" version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } - ?: "2.5.1" + ?: "2.5.3" val kordver = "1.5.6" val coroutinesver = "1.1.0" From 8a77b275dca5d74ef5fb1cc7ac7714a1c212f1c1 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 09:41:27 +0200 Subject: [PATCH 063/103] feat: Bot now skips Bot Users Signed-off-by: moonleay --- .../moonleay/lilJudd/features/AvailabilityManager.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index f414967..a6b2d3a 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -18,6 +18,7 @@ package net.moonleay.lilJudd.features +import com.kotlindiscord.kord.extensions.utils.isNullOrBot import dev.inmo.krontab.buildSchedule import dev.inmo.krontab.doInfinity import dev.kord.common.Color @@ -162,11 +163,14 @@ object AvailabilityManager : IFeature { } mce.collect { memberchunkevent -> memberchunkevent.members.forEach { - Logger.out("Checking member ${it.id.value} (${it.username})") - if (it.roleIds.contains(Snowflake(pnrd.hastimeroleid))) { - it.removeRole(Snowflake(pnrd.hastimeroleid)) - Logger.out("Removed role from ${it.username}") // Removed the role + if (!it.isNullOrBot()) { // Check if the member is a bot + Logger.out("Checking member ${it.id.value} (${it.username})") + if (it.roleIds.contains(Snowflake(pnrd.hastimeroleid))) { + it.removeRole(Snowflake(pnrd.hastimeroleid)) + Logger.out("Removed role from ${it.username}") // Removed the role + } } + // I cant use continue here, because it does not work with .forEach } } From 99964d79814b5af9e2630f2a4cb8d602214ee98d Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 09:41:43 +0200 Subject: [PATCH 064/103] !feat: removed TestExtension.kt Signed-off-by: moonleay --- .../lilJudd/extensions/TestExtension.kt | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 src/main/kotlin/net/moonleay/lilJudd/extensions/TestExtension.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/TestExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/TestExtension.kt deleted file mode 100644 index 90cda76..0000000 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/TestExtension.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * lilJudd - * Copyright (C) 2023 moonleay - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.moonleay.lilJudd.extensions - -import com.kotlindiscord.kord.extensions.extensions.Extension -import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand -import com.kotlindiscord.kord.extensions.types.respond -import dev.kord.common.Color -import dev.kord.rest.builder.message.create.actionRow -import net.moonleay.lilJudd.util.EmbedUtil -import net.moonleay.lilJudd.util.MessageUtil - -/* This extension has no proper use. - It is used in testing to test stuff, without having to wait for certain events to trigger. */ -class TestExtension : Extension() { - override val name = "test" - override val allowApplicationCommandInDMs: Boolean - get() = false - - override suspend fun setup() { - publicSlashCommand { - name = "test" - description = "Test game" - this.action { - this.respond { - this.embeds.add( - MessageUtil.getEmbedWithTable( - Color(0X4C4645), - "", - "MONDAY, 22.05.2023", - mapOf( - "Is available" to listOf(), - "May be available" to listOf(), - "Is not available" to listOf() - ) - ) - ) - - this.actionRow { - this.components.addAll(EmbedUtil.getTimePlannerButtons().components) - } - } - } - } - } -} From 39fb3ba7d69e586e83589fba3ac692a45be6a480 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 09:42:08 +0200 Subject: [PATCH 065/103] chore: updated SendPlannerExtension documentation Signed-off-by: moonleay --- .../net/moonleay/lilJudd/extensions/SendPlannerExtension.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt index 0e53f7b..d4b8808 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt @@ -47,13 +47,13 @@ class SendPlannerExtension : Extension() { override suspend fun setup() { publicSlashCommand() { name = "sendplanner" - description = "Send the planner for the current and x next weeks" + description = "Send the planner for the current week" this.action { if (!this.member!!.asMember(this.guild!!.id) .hasPermission(Permission.Administrator) ) { val res = this.respond { - this.content = "no." + this.content = "You need to be an administrator to use this command." } res.delete() return@action From 36f931b9193701a32d18ebbfae5533441cebd869 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 09:43:36 +0200 Subject: [PATCH 066/103] feat: improved UpdateRolesExtension chore: updated UpdateRolesExtension Documentation Signed-off-by: moonleay --- .../net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt index 109e3c7..65d5430 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt @@ -42,7 +42,7 @@ class UpdateRolesExtension : Extension() { .hasPermission(Permission.Administrator) ) { val res = this.respond { - this.content = "no." + this.content = "You need to be an administrator to use this command." } res.delete() return@action @@ -55,7 +55,7 @@ class UpdateRolesExtension : Extension() { // -- below here is the code of the cronjob -- Logger.out("Starting to update roles...") - AvailabilityManager.runThread() + AvailabilityManager.updateInChannel(this.channel.id) } } } From af15f7eb739f2eef5424298a1cdb9e2f5742e6e5 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 09:46:19 +0200 Subject: [PATCH 067/103] chore: removed unused open modifier in IEditButton Signed-off-by: moonleay --- .../net/moonleay/lilJudd/buttons/component/IEditButton.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/component/IEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/component/IEditButton.kt index 84e8a5b..0fbe64e 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/component/IEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/component/IEditButton.kt @@ -26,7 +26,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction interface IEditButton { val id: String - open suspend fun onInteraction( + suspend fun onInteraction( interaction: ButtonInteraction, response: PublicMessageInteractionResponseBehavior, guild: Guild, From dcdb5c6e562873b375f3cd035b7f753ee3475839 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 12:27:53 +0200 Subject: [PATCH 068/103] feat: added EmbedColor Signed-off-by: moonleay --- .../net/moonleay/lilJudd/util/EmbedColor.kt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/kotlin/net/moonleay/lilJudd/util/EmbedColor.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/EmbedColor.kt b/src/main/kotlin/net/moonleay/lilJudd/util/EmbedColor.kt new file mode 100644 index 0000000..cb3e983 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/util/EmbedColor.kt @@ -0,0 +1,28 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.util + +import dev.kord.common.Color + +enum class EmbedColor(val color: Color) { + ERROR(Color(0xE0311A)), + WARNING(Color(0xFFA500)), + SUCCESS(Color(0x52E01A)), + INFO(Color(0x4C4645)), +} From 8d14597a38f3e1c4383de37ac984971c9da3f1c2 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 12:34:27 +0200 Subject: [PATCH 069/103] feat: make embed helper functions use EmbedColor instead of color Signed-off-by: moonleay --- .../net/moonleay/lilJudd/util/MessageUtil.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt index 0e34571..6dfb545 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt @@ -22,7 +22,6 @@ import com.kotlindiscord.kord.extensions.commands.Arguments import com.kotlindiscord.kord.extensions.commands.application.slash.PublicSlashCommandContext import com.kotlindiscord.kord.extensions.components.forms.ModalForm import com.kotlindiscord.kord.extensions.types.respond -import dev.kord.common.Color import dev.kord.core.entity.Embed import dev.kord.rest.builder.message.EmbedBuilder import java.time.LocalDateTime @@ -34,7 +33,7 @@ object MessageUtil { ///Send an embedded message as a reply suspend fun sendEmbedForPublicSlashCommand( ctx: PublicSlashCommandContext, - color: Color, + color: EmbedColor, title: String, description: String ) { @@ -53,7 +52,7 @@ object MessageUtil { ///Send an embedded message with an image as a reply suspend fun sendEmbedForPublicSlashCommandWithImage( ctx: PublicSlashCommandContext, - color: Color, + color: EmbedColor, title: String, description: String, thumbnailUrl: String @@ -103,7 +102,7 @@ object MessageUtil { } fun getEmbedWithTableWithFooter( - color: Color, + color: EmbedColor, title: String, description: String, values: Map>?, @@ -117,7 +116,7 @@ object MessageUtil { ///Get an embedded msg with image, title and description fun getEmbedWithTable( - color: Color, + color: EmbedColor, title: String, description: String, values: Map>? @@ -140,20 +139,20 @@ object MessageUtil { ///Get an embedded msg with title and description fun getEmbedSmall( - color: Color, + color: EmbedColor, title: String, description: String ): EmbedBuilder { val ebb = EmbedBuilder() ebb.title = title ebb.description = description - ebb.color = color + ebb.color = color.color return ebb } ///Get an embedded msg with title, description and a src fun getEmbed( - color: Color, + color: EmbedColor, title: String, description: String, source: String @@ -167,7 +166,7 @@ object MessageUtil { ///Get an embedded msg with image, title, description and a src fun getEmbedWithImage( - color: Color, + color: EmbedColor, title: String, description: String, source: String, From caa5d49baddaebb268e74c329333b10a1cddc324 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 12:36:19 +0200 Subject: [PATCH 070/103] fix!: Changed all colors to EmbedColor Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/Bot.kt | 9 +++--- .../extensions/FeatureManageExtension.kt | 6 ++-- .../lilJudd/extensions/MatchExtension.kt | 6 ++-- .../extensions/SendPlannerExtension.kt | 10 ++----- .../extensions/UpdateRolesExtension.kt | 29 ++++++++++++++----- .../lilJudd/extensions/VersionExtension.kt | 4 +-- .../lilJudd/features/AvailabilityManager.kt | 14 ++++----- .../moonleay/lilJudd/features/TimeManager.kt | 20 +++++-------- 8 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt index 6f6d47f..64e0314 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt @@ -19,7 +19,6 @@ package net.moonleay.lilJudd import com.kotlindiscord.kord.extensions.ExtensibleBot -import dev.kord.common.Color import dev.kord.common.entity.PresenceStatus import dev.kord.core.behavior.interaction.response.respond import dev.kord.core.event.gateway.ReadyEvent @@ -39,6 +38,7 @@ import net.moonleay.lilJudd.extensions.* import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.features.MatchManager import net.moonleay.lilJudd.features.TimeManager +import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.MessageUtil import kotlin.system.exitProcess @@ -146,9 +146,10 @@ object Bot { response.respond { this.embeds = mutableListOf( MessageUtil.getEmbed( - Color(0xE0311A), - "Error", - "Could not find button with id \"${inter.componentId}\".\nPlease report this.", + EmbedColor.ERROR, + "404: Not Found", + "Could not find button with id \"${inter.componentId}\"." + + "\nPlease report this.", u.asUser().username + "#" + u.asUser().discriminator ) ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt index eac08c6..e09786c 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/FeatureManageExtension.kt @@ -25,11 +25,11 @@ import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.types.respond import com.kotlindiscord.kord.extensions.utils.hasPermission -import dev.kord.common.Color import dev.kord.common.entity.Permission import net.moonleay.lilJudd.extensions.component.EnableOrDisable import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.FeatureManager +import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.MessageUtil @@ -51,7 +51,7 @@ class FeatureManageExtension : Extension() { this.respond { embeds.add( MessageUtil.getEmbed( - Color(0xE0311A), + EmbedColor.ERROR, "403: Forbidden", "You cannot edit features, as you don't have the Administrator permission.", u.asUser().username + "#" + u.asUser().discriminator @@ -70,7 +70,7 @@ class FeatureManageExtension : Extension() { this.respond { this.embeds.add( MessageUtil.getEmbed( - Color(0xE0311A), + EmbedColor.ERROR, "404: Not Found", "The feature you are trying to edit does not exist.", u.asUser().username + "#" + u.asUser().discriminator diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt index 3be70f7..40787d4 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt @@ -25,7 +25,6 @@ import com.kotlindiscord.kord.extensions.commands.converters.impl.string import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.types.respond -import dev.kord.common.Color import dev.kord.core.behavior.channel.createMessage import dev.kord.core.behavior.createRole import dev.kord.rest.builder.message.create.actionRow @@ -33,6 +32,7 @@ import net.moonleay.lilJudd.data.tables.MatchPlanningData import net.moonleay.lilJudd.extensions.component.MatchTypes import net.moonleay.lilJudd.jobs.MatchJob import net.moonleay.lilJudd.jobs.component.JobManager +import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.MessageUtil import net.moonleay.lilJudd.util.TimeUtil @@ -60,7 +60,7 @@ class MatchExtension : Extension() { val msg = this.respond { this.embeds.add( MessageUtil.getEmbedWithTable( - Color(0X4C4645), + EmbedColor.INFO, args.matchType.readableName, "***Vs. $opponent***\n" + "At ${args.timeStamp}\n" + @@ -90,7 +90,7 @@ class MatchExtension : Extension() { this.channel.createMessage { this.embeds.add( MessageUtil.getEmbed( - Color(0xE0311A), + EmbedColor.ERROR, "500: Internal Error", "Could not find created role.\n" + "It seems, that said role could not be created.", diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt index d4b8808..fd293d9 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt @@ -22,16 +22,12 @@ import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.types.respond import com.kotlindiscord.kord.extensions.utils.hasPermission -import dev.kord.common.Color import dev.kord.common.entity.Permission import dev.kord.core.behavior.channel.createMessage import dev.kord.rest.builder.message.create.actionRow import kotlinx.coroutines.delay import net.moonleay.lilJudd.data.tables.TimePlanningMessages -import net.moonleay.lilJudd.util.EmbedUtil -import net.moonleay.lilJudd.util.Logger -import net.moonleay.lilJudd.util.MessageUtil -import net.moonleay.lilJudd.util.TimeUtil +import net.moonleay.lilJudd.util.* import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.transactions.transaction import java.time.ZoneId @@ -71,7 +67,7 @@ class SendPlannerExtension : Extension() { c.createMessage { this.embeds.add( MessageUtil.getEmbed( - Color(0X4C4645), + EmbedColor.INFO, "Time Planning Feature", "Do you have time on the following Days?", "Automated Message" @@ -83,7 +79,7 @@ class SendPlannerExtension : Extension() { val msg = c.createMessage { this.embeds.add( MessageUtil.getEmbedWithTable( - Color(0X4C4645), + EmbedColor.INFO, "", "${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday", mapOf( diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt index 65d5430..be6ba80 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt @@ -23,16 +23,16 @@ import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.types.respond import com.kotlindiscord.kord.extensions.utils.hasPermission import dev.kord.common.entity.Permission -import dev.kord.gateway.PrivilegedIntent import net.moonleay.lilJudd.features.AvailabilityManager +import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.Logger +import net.moonleay.lilJudd.util.MessageUtil class UpdateRolesExtension : Extension() { override val name = "updateroles" override val allowApplicationCommandInDMs: Boolean get() = false - @OptIn(PrivilegedIntent::class) override suspend fun setup() { publicSlashCommand() { name = "updateroles" @@ -41,17 +41,30 @@ class UpdateRolesExtension : Extension() { if (!this.member!!.asMember(this.guild!!.id) .hasPermission(Permission.Administrator) ) { - val res = this.respond { - this.content = "You need to be an administrator to use this command." + this.respond { + this.embeds.add( + MessageUtil.getEmbed( + EmbedColor.ERROR, + "403: Forbidden", + "You need to be an administrator to use this command.", + user.asUser().username + "#" + user.asUser().discriminator + ) + ) } - res.delete() return@action } - val res = this.respond { - this.content = "OK." + this.respond { + this.embeds.add( + MessageUtil.getEmbed( + EmbedColor.SUCCESS, + "200: Success", + "Updating roles.\n" + + "This may take a while, please be patient.", + user.asUser().username + "#" + user.asUser().discriminator + ) + ) } - // -- below here is the code of the cronjob -- Logger.out("Starting to update roles...") diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/VersionExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/VersionExtension.kt index c116c02..3554f72 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/VersionExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/VersionExtension.kt @@ -20,8 +20,8 @@ package net.moonleay.lilJudd.extensions import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand -import dev.kord.common.Color import net.moonleay.botendo.build.BuildConstants +import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.MessageUtil class VersionExtension : Extension() { @@ -33,7 +33,7 @@ class VersionExtension : Extension() { this.action { MessageUtil.sendEmbedForPublicSlashCommand( this, - Color(0x52E01A), + EmbedColor.INFO, "Lil' Judd", "Lil' Judd ***v." + BuildConstants.version + "***\n" + "Kord-Extensions ***v." + BuildConstants.kordVersion + "***\n" + diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index a6b2d3a..f883347 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -21,7 +21,6 @@ package net.moonleay.lilJudd.features import com.kotlindiscord.kord.extensions.utils.isNullOrBot import dev.inmo.krontab.buildSchedule import dev.inmo.krontab.doInfinity -import dev.kord.common.Color import dev.kord.common.entity.Snowflake import dev.kord.core.behavior.UserBehavior import dev.kord.core.behavior.createRole @@ -38,10 +37,7 @@ import net.moonleay.lilJudd.data.tables.TimePlanningMessages import net.moonleay.lilJudd.extensions.FeatureManageExtension import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.IFeature -import net.moonleay.lilJudd.util.EmbedUtil -import net.moonleay.lilJudd.util.Logger -import net.moonleay.lilJudd.util.MessageUtil -import net.moonleay.lilJudd.util.TimeUtil +import net.moonleay.lilJudd.util.* import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.transactions.transaction @@ -264,7 +260,7 @@ object AvailabilityManager : IFeature { } return MessageUtil.getEmbed( - Color(0x52E01A), + EmbedColor.SUCCESS, "200: Success", "The feature was enabled in channel ${args.channel.data.name.value} with roles ${hasTimeRole.mention} & ${wantsNotifsRole.mention}.", u.asUser().username + "#" + u.asUser().discriminator @@ -273,7 +269,7 @@ object AvailabilityManager : IFeature { // They exist, do not add them return MessageUtil.getEmbed( - Color(0xE0311A), + EmbedColor.ERROR, "403: Forbidden", "The feature is already enabled in this channel.", u.asUser().username + "#" + u.asUser().discriminator @@ -318,7 +314,7 @@ object AvailabilityManager : IFeature { } } return MessageUtil.getEmbed( - Color(0x52E019), + EmbedColor.SUCCESS, "200: Success", "The feature was disabled.", u.asUser().username + "#" + u.asUser().discriminator @@ -326,7 +322,7 @@ object AvailabilityManager : IFeature { } // not in db, do nothing return MessageUtil.getEmbed( - Color(0xE0311A), + EmbedColor.ERROR, "403: Forbidden", "The feature is already disabled in this channel.", u.asUser().username + "#" + u.asUser().discriminator diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt index 2058c11..677520d 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt @@ -20,7 +20,6 @@ package net.moonleay.lilJudd.features import dev.inmo.krontab.buildSchedule import dev.inmo.krontab.doInfinity -import dev.kord.common.Color import dev.kord.common.entity.Snowflake import dev.kord.core.behavior.UserBehavior import dev.kord.core.behavior.channel.createMessage @@ -37,10 +36,7 @@ import net.moonleay.lilJudd.data.tables.TimePlanningMessages import net.moonleay.lilJudd.extensions.FeatureManageExtension import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.IFeature -import net.moonleay.lilJudd.util.EmbedUtil -import net.moonleay.lilJudd.util.Logger -import net.moonleay.lilJudd.util.MessageUtil -import net.moonleay.lilJudd.util.TimeUtil +import net.moonleay.lilJudd.util.* import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.transactions.transaction @@ -101,7 +97,7 @@ object TimeManager : IFeature { "The weekly planning starts now <@&${Snowflake(roleMap[ch]?.wantstobenotifid!!)}>" this.embeds.add( MessageUtil.getEmbed( - Color(0X4C4645), + EmbedColor.INFO, "Time Planning Feature", "Do you have time on the following Days?", "Automated Message" @@ -112,7 +108,7 @@ object TimeManager : IFeature { c.createMessage { this.embeds.add( MessageUtil.getEmbed( - Color(0X4C4645), + EmbedColor.INFO, "Time Planning Feature", "Do you have time on the following Days?", "Automated Message" @@ -126,7 +122,7 @@ object TimeManager : IFeature { val msg = c.createMessage { this.embeds.add( MessageUtil.getEmbedWithTable( - Color(0X4C4645), + EmbedColor.INFO, "", "${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday", mapOf( @@ -184,14 +180,14 @@ object TimeManager : IFeature { } get TimePlanningChannels.id } return MessageUtil.getEmbed( - Color(0x52E01A), + EmbedColor.SUCCESS, "200: Success", "The feature was enabled in channel ${args.channel.data.name.value}", u.asUser().username + "#" + u.asUser().discriminator ) } return MessageUtil.getEmbed( - Color(0xE0311A), + EmbedColor.ERROR, "403: Forbidden", "The feature is already enabled in this channel.", u.asUser().username + "#" + u.asUser().discriminator @@ -226,7 +222,7 @@ object TimeManager : IFeature { } } return MessageUtil.getEmbed( - Color(0x52E019), + EmbedColor.SUCCESS, "200: Success", "The feature was disabled.", u.asUser().username + "#" + u.asUser().discriminator @@ -234,7 +230,7 @@ object TimeManager : IFeature { } // Do nothing; not in db return MessageUtil.getEmbed( - Color(0xE0311A), + EmbedColor.ERROR, "403: Forbidden", "The feature is already disabled in this channel.", u.asUser().username + "#" + u.asUser().discriminator From fdf63c4605d8d7579be43b20b270f542dc3afd82 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 12:42:49 +0200 Subject: [PATCH 071/103] chore: bump version Signed-off-by: moonleay --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7844542..dcda691 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,7 @@ val ownerID = 372703841151614976L group = "net.moonleay.liljudd" version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } - ?: "2.5.3" + ?: "2.5.4" val kordver = "1.5.6" val coroutinesver = "1.1.0" From 99c607efd45537d74d6fb1a4edd0eb8c9fca4016 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 18:30:12 +0200 Subject: [PATCH 072/103] feat: added TimePlanningChannelsData Signed-off-by: moonleay --- .../data/entry/TimePlanningChannelsData.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt new file mode 100644 index 0000000..2eebba4 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt @@ -0,0 +1,24 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.entry + +data class TimePlanningChannelsData( + val serverID: Long, + val channelID: Long, +) From b77271517d4aab3bdd3a4da5cba842c8a95632e3 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 14 Sep 2023 18:31:45 +0200 Subject: [PATCH 073/103] chore: fixed naming in data objects Signed-off-by: moonleay --- .../buttons/matchplanner/AcceptEditButton.kt | 6 ++-- .../buttons/matchplanner/CancelEditButton.kt | 4 +-- .../buttons/matchplanner/DeclineEditButton.kt | 6 ++-- .../data/entry/MatchPlanningDataData.kt | 16 +++++----- .../data/entry/PlanningNotifierRolesData.kt | 6 ++-- .../data/entry/TimePlanningMessagesData.kt | 6 ++-- .../lilJudd/features/AvailabilityManager.kt | 32 +++++++++---------- .../moonleay/lilJudd/features/MatchManager.kt | 8 ++--- .../moonleay/lilJudd/features/TimeManager.kt | 2 +- .../net/moonleay/lilJudd/jobs/MatchJob.kt | 4 +-- 10 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt index 55765ee..3dd02d7 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt @@ -75,11 +75,11 @@ class AcceptEditButton() : IEditButton { if (!found || mpdd == null) { return } - val role = guild.getRoleOrNull(Snowflake(mpdd.roleid)) ?: return + val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) ?: return val member = interaction.user.asMember(guild.id) ?: return // do the checks and update if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) { - if (member.roleIds.contains(Snowflake(mpdd.roleid))) { + if (member.roleIds.contains(Snowflake(mpdd.roleID))) { Logger.out("Removing role from ${member.username}") member.removeRole(role.id) } @@ -94,7 +94,7 @@ class AcceptEditButton() : IEditButton { shouldEditButton = true } if (!m.embeds[0].fields[0].value.contains(user.id.value.toString())) { - if (!member.roleIds.contains(Snowflake(mpdd.roleid))) { + if (!member.roleIds.contains(Snowflake(mpdd.roleID))) { Logger.out("Adding role to ${member.username}") member.addRole(role.id) } diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt index 4f70ab7..be99232 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt @@ -72,9 +72,9 @@ class CancelEditButton : IEditButton { if (!found || mpdd == null) { return } - val role = guild.getRoleOrNull(Snowflake(mpdd.roleid)) ?: return + val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) ?: return val member = interaction.user.asMember(guild.id) - if (member.roleIds.contains(Snowflake(mpdd.roleid))) { + if (member.roleIds.contains(Snowflake(mpdd.roleID))) { member.removeRole(role.id) } Bot.bot.kordRef.getChannelOf(interaction.channelId)!!.getMessage(m.id).edit { diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt index 3d0e0bd..9a3de97 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt @@ -75,10 +75,10 @@ class DeclineEditButton : IEditButton { if (!found || mpdd == null) { return } - val role = guild.getRoleOrNull(Snowflake(mpdd.roleid)) ?: return + val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) ?: return val member = interaction.user.asMember(guild.id) ?: return if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) { - if (member.roleIds.contains(Snowflake(mpdd.roleid))) { + if (member.roleIds.contains(Snowflake(mpdd.roleID))) { Logger.out("Removing role from ${member.username}") member.removeRole(role.id) } @@ -88,7 +88,7 @@ class DeclineEditButton : IEditButton { shouldEditButton = true } if (!m.embeds[0].fields[1].value.contains(user.id.value.toString())) { - if (member.roleIds.contains(Snowflake(mpdd.roleid))) { + if (member.roleIds.contains(Snowflake(mpdd.roleID))) { Logger.out("Removing role from ${member.username}") member.removeRole(role.id) } diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt index 451278e..f48dc28 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt @@ -20,13 +20,13 @@ package net.moonleay.lilJudd.data.entry data class MatchPlanningDataData( val id: Int, - val serverid: Long, - val channelid: Long, - val matchtype: String, - val registererid: Long, - val roleid: Long, - val opponentname: String, - val messageid: Long, + val serverID: Long, + val channelID: Long, + val matchType: String, + val registererID: Long, + val roleID: Long, + val opponentName: String, + val messageID: Long, val timestamp: Long, - val jobstr: String + val jobString: String ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt index fc15729..a36f351 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt @@ -20,7 +20,7 @@ package net.moonleay.lilJudd.data.entry data class PlanningNotifierRolesData( val serverID: Long, // The id of the server - val channelId: Long, // The id of the channel - val hastimeroleid: Long, // The id of the role that has time today - val wantstobenotifid: Long // The id of the role that wants to be notified + val channelID: Long, // The id of the channel + val hasTimeRoleID: Long, // The id of the role that has time today + val wantsToBeNotifiedID: Long // The id of the role that wants to be notified ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt index c4de368..6c5b2fc 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt @@ -19,8 +19,8 @@ package net.moonleay.lilJudd.data.entry data class TimePlanningMessagesData( - val serverid: Long, // The discord server id - val channelid: Long, // The discord channel id + val serverID: Long, // The discord server id + val channelID: Long, // The discord channel id val weekstamp: Long, // The timestamp of the monday of the week at 4am UTC - val messageids: String // IDs are in the following format: "{weekdayNr}:{id};{weekdayNr}:{id};[etc.]" + val messageIDs: String // IDs are in the following format: "{weekdayNr}:{id};{weekdayNr}:{id};[etc.]" ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index f883347..8683dd5 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -80,15 +80,15 @@ object AvailabilityManager : IFeature { for (snf in messageMap.keys) { // snf = Snowflake val data = messageMap[snf]!! // this is the data of the table - if (Bot.bot.kordRef.getChannel(Snowflake(data.channelid)) == null) + if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) continue // This channel does not exist anymore. if (roleMap.isEmpty()) { Logger.out("No saved roles. Canceling.") return } - val roleData = roleMap[data.channelid] // Get the role data + val roleData = roleMap[data.channelID] // Get the role data if (roleData == null) { - Logger.out("Role for channel ${data.channelid} does not exist") + Logger.out("Role for channel ${data.channelID} does not exist") continue // this took way to long to find out that this was the issue } this.updateInChannel(snf, data, roleData) @@ -130,10 +130,10 @@ object AvailabilityManager : IFeature { Logger.out("Could not find data for channel ${snf.value}") return } - if (Bot.bot.kordRef.getChannel(Snowflake(data.channelid)) == null) + if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) return // This channel does not exist anymore. if (roleData == null) { - Logger.out("Role for channel ${data.channelid} does not exist") + Logger.out("Role for channel ${data.channelID} does not exist") return // this took way to long to find out that this was the issue } updateInChannel(snf, data, roleData) @@ -141,18 +141,18 @@ object AvailabilityManager : IFeature { @OptIn(PrivilegedIntent::class) suspend fun updateInChannel(snf: Snowflake, tpmd: TimePlanningMessagesData, pnrd: PlanningNotifierRolesData) { - if (Bot.bot.kordRef.getChannel(Snowflake(tpmd.channelid)) == null) + if (Bot.bot.kordRef.getChannel(Snowflake(tpmd.channelID)) == null) return // This channel does not exist anymore. val c = - Bot.bot.kordRef.getChannelOf(Snowflake(tpmd.channelid))!! // Get the channel as MessageChannel - if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverid)) == null) { + Bot.bot.kordRef.getChannelOf(Snowflake(tpmd.channelID))!! // Get the channel as MessageChannel + if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverID)) == null) { Logger.out("Guild not found.") return } val weekday = ZonedDateTime.now().dayOfWeek // The current week day val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() * 1000 // The current week time stamp Logger.out("It is week ${weekStamp} and day ${weekday}/${TimeUtil.getDayOfMonthInt(weekday)} of the week.") - val g = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverid)) + val g = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverID)) // Get all members with the role val mce = g.requestMembers { this.requestAllMembers() @@ -161,8 +161,8 @@ object AvailabilityManager : IFeature { memberchunkevent.members.forEach { if (!it.isNullOrBot()) { // Check if the member is a bot Logger.out("Checking member ${it.id.value} (${it.username})") - if (it.roleIds.contains(Snowflake(pnrd.hastimeroleid))) { - it.removeRole(Snowflake(pnrd.hastimeroleid)) + if (it.roleIds.contains(Snowflake(pnrd.hasTimeRoleID))) { + it.removeRole(Snowflake(pnrd.hasTimeRoleID)) Logger.out("Removed role from ${it.username}") // Removed the role } } @@ -174,7 +174,7 @@ object AvailabilityManager : IFeature { // This stores the ids of the messages. // The format is weekdaNR:ID // The last entry (nr 8) is empty, so we can ignore it - val messageIdSplit = tpmd.messageids.split(";").subList(0, 7) + val messageIdSplit = tpmd.messageIDs.split(";").subList(0, 7) for (mid in messageIdSplit) { Logger.out("Checking id $mid") if (!mid.startsWith((TimeUtil.getDayOfMonthInt(weekday) - 1).toString(), true)) @@ -192,15 +192,15 @@ object AvailabilityManager : IFeature { val targets = EmbedUtil.getAllUsersInTheFirstXTables(2, message.embeds[0]) for (tid in targets) { Logger.out("Checking id $tid") - if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverid))!! + if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverID))!! .getMemberOrNull(Snowflake(tid)) == null ) continue// This member does not exist anymore. - val member = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverid)) + val member = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverID)) .getMember(Snowflake(tid)) // Get the member - if (member.roleIds.contains(Snowflake(pnrd.hastimeroleid))) + if (member.roleIds.contains(Snowflake(pnrd.hasTimeRoleID))) continue // This member already has the role - member.addRole(Snowflake(pnrd.hastimeroleid)) // Add the role + member.addRole(Snowflake(pnrd.hasTimeRoleID)) // Add the role Logger.out("Added role to ${member.username}") } Logger.out("Done with message. Moving on...") diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt index 1591545..aeb2203 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt @@ -57,9 +57,9 @@ object MatchManager { Logger.out("Checking match role ${data.id}...") if (data.timestamp.toLong() < System.currentTimeMillis()) { Logger.out("Match role ${data.id} is expired, removing...") - this.removeRoleFromGuild(data.serverid, data.roleid) + this.removeRoleFromGuild(data.serverID, data.roleID) transaction { - MatchPlanningData.deleteWhere { MatchPlanningData.messageid eq data.messageid } + MatchPlanningData.deleteWhere { MatchPlanningData.messageid eq data.messageID } } continue } @@ -71,9 +71,9 @@ object MatchManager { private fun registerJob(data: MatchPlanningDataData) { JobManager.addJob( MatchJob( - data.jobstr, + data.jobString, data.id, - "fromdb-${data.matchtype}_Vs_${data.opponentname}_[${data.id}]-${data.serverid}_${data.channelid}" + "fromdb-${data.matchType}_Vs_${data.opponentName}_[${data.id}]-${data.serverID}_${data.channelID}" ) ) Logger.out("Registered job for match ${data.id}...") diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt index 677520d..8a66ee7 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt @@ -94,7 +94,7 @@ object TimeManager : IFeature { if (roleMap != null && roleMap.keys.contains(ch) && roleMap[ch] != null) { c.createMessage { this.content = - "The weekly planning starts now <@&${Snowflake(roleMap[ch]?.wantstobenotifid!!)}>" + "The weekly planning starts now <@&${Snowflake(roleMap[ch]?.wantsToBeNotifiedID!!)}>" this.embeds.add( MessageUtil.getEmbed( EmbedColor.INFO, diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt index 89b33e4..f350b86 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt @@ -67,12 +67,12 @@ class MatchJob( ) } } - val guild = Bot.bot.kordRef.getGuildOrNull(Snowflake(mpdd.serverid)) + val guild = Bot.bot.kordRef.getGuildOrNull(Snowflake(mpdd.serverID)) if (guild == null) { Logger.out("Guild not found.") return } - val r = guild.getRoleOrNull(Snowflake(mpdd.roleid)) + val r = guild.getRoleOrNull(Snowflake(mpdd.roleID)) if (r == null) { Logger.out("Role not found.") return From e27efe094cb3eebd4ea85927f3e2d51ef0c5a7fc Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 15 Sep 2023 22:49:12 +0200 Subject: [PATCH 074/103] chore: removed unused comment Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/Bot.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt index 64e0314..750eb8c 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt @@ -103,8 +103,7 @@ object Bot { add(::FeatureManageExtension) add(::SendPlannerExtension) add(::MatchExtension) - add(::UpdateRolesExtension) // This command is only for debugging purposes - //add(::TestExtension) // See comment in TestExtension.kt + add(::UpdateRolesExtension) } this.presence { From 95c22c6bd0acf2c207ca0cb8f2a76bc685f97db9 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 15 Sep 2023 22:50:16 +0200 Subject: [PATCH 075/103] feat: moved all transactions into one package for reuse and simplicity Signed-off-by: moonleay --- .../buttons/matchplanner/AcceptEditButton.kt | 43 ++--- .../buttons/matchplanner/CancelEditButton.kt | 44 ++--- .../buttons/matchplanner/DeclineEditButton.kt | 43 ++--- .../data/entry/PlanningNotifierRolesData.kt | 1 + .../data/entry/TimePlanningChannelsData.kt | 1 + .../data/entry/TimePlanningMessagesData.kt | 1 + .../repository/MatchPlanningDataRepository.kt | 112 +++++++++++++ .../PlanningNotifierRolesRepository.kt | 104 ++++++++++++ .../TimePlanningChannelsRepository.kt | 69 ++++++++ .../TimePlanningMessagesRepository.kt | 76 +++++++++ .../lilJudd/extensions/MatchExtension.kt | 40 +++-- .../extensions/SendPlannerExtension.kt | 22 +-- .../lilJudd/features/AvailabilityManager.kt | 154 +++++------------- .../moonleay/lilJudd/features/MatchManager.kt | 32 +--- .../moonleay/lilJudd/features/TimeManager.kt | 106 ++++-------- .../net/moonleay/lilJudd/jobs/MatchJob.kt | 33 +--- 16 files changed, 509 insertions(+), 372 deletions(-) create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/repository/MatchPlanningDataRepository.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/repository/PlanningNotifierRolesRepository.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningChannelsRepository.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningMessagesRepository.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt index 3dd02d7..115a7e5 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt @@ -28,14 +28,10 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton -import net.moonleay.lilJudd.data.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.tables.MatchPlanningData +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.MessageUtil -import org.jetbrains.exposed.sql.and -import org.jetbrains.exposed.sql.select -import org.jetbrains.exposed.sql.transactions.transaction class AcceptEditButton() : IEditButton { override val id: String = "public.edit.btn.matchmanagement.accept" @@ -49,33 +45,20 @@ class AcceptEditButton() : IEditButton { val m = interaction.message val eb = MessageUtil.getAClonedEmbed(m.embeds[0]) var shouldEditButton = false - lateinit var mpdd: MatchPlanningDataData - var found = false - transaction { - for (pnr in MatchPlanningData.select { - MatchPlanningData.messageid eq (interaction.message.id.value.toLong()) and ( - MatchPlanningData.serverid eq (guild.id.value.toLong())) and ( - MatchPlanningData.channelid eq (interaction.channelId.value.toLong())) - }) { - mpdd = MatchPlanningDataData( - pnr[MatchPlanningData.id], - pnr[MatchPlanningData.serverid], - pnr[MatchPlanningData.channelid], - pnr[MatchPlanningData.matchtype], - pnr[MatchPlanningData.registererid], - pnr[MatchPlanningData.roleid], - pnr[MatchPlanningData.opponentName], - pnr[MatchPlanningData.messageid], - pnr[MatchPlanningData.timestamp], - pnr[MatchPlanningData.jobstr] - ) - found = true - } - } - if (!found || mpdd == null) { + val mpdd = MatchPlanningDataRepository.getFromMessageInChannelInServer( + m.id.value.toLong(), + interaction.channelId.value.toLong(), + guild.id.value.toLong() + ) + if (mpdd == null) { + Logger.out("mpdd is null") + return + } + val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) + if (role == null) { + Logger.out("role is null") return } - val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) ?: return val member = interaction.user.asMember(guild.id) ?: return // do the checks and update if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) { diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt index be99232..c7cebc3 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt @@ -28,12 +28,9 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton -import net.moonleay.lilJudd.data.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.tables.MatchPlanningData +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.util.EmbedUtil -import org.jetbrains.exposed.sql.and -import org.jetbrains.exposed.sql.select -import org.jetbrains.exposed.sql.transactions.transaction +import net.moonleay.lilJudd.util.Logger class CancelEditButton : IEditButton { override val id: String = "public.edit.btn.matchmanagement.cancel" @@ -46,33 +43,20 @@ class CancelEditButton : IEditButton { ) { val m = interaction.message if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) { - lateinit var mpdd: MatchPlanningDataData - var found = false - transaction { - for (pnr in MatchPlanningData.select { - MatchPlanningData.messageid eq (interaction.message.id.value.toLong()) and ( - MatchPlanningData.serverid eq (guild.id.value.toLong())) and ( - MatchPlanningData.channelid eq (interaction.channelId.value.toLong())) - }) { - mpdd = MatchPlanningDataData( - pnr[MatchPlanningData.id], - pnr[MatchPlanningData.serverid], - pnr[MatchPlanningData.channelid], - pnr[MatchPlanningData.matchtype], - pnr[MatchPlanningData.registererid], - pnr[MatchPlanningData.roleid], - pnr[MatchPlanningData.opponentName], - pnr[MatchPlanningData.messageid], - pnr[MatchPlanningData.timestamp], - pnr[MatchPlanningData.jobstr] - ) - found = true - } - } - if (!found || mpdd == null) { + val mpdd = MatchPlanningDataRepository.getFromMessageInChannelInServer( + m.id.value.toLong(), + interaction.channelId.value.toLong(), + guild.id.value.toLong() + ) + if (mpdd == null) { + Logger.out("mpdd is null") + return + } + val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) + if (role == null) { + Logger.out("role is null") return } - val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) ?: return val member = interaction.user.asMember(guild.id) if (member.roleIds.contains(Snowflake(mpdd.roleID))) { member.removeRole(role.id) diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt index 9a3de97..d775a29 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt @@ -28,14 +28,10 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton -import net.moonleay.lilJudd.data.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.tables.MatchPlanningData +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.MessageUtil -import org.jetbrains.exposed.sql.and -import org.jetbrains.exposed.sql.select -import org.jetbrains.exposed.sql.transactions.transaction class DeclineEditButton : IEditButton { override val id: String = "public.edit.btn.matchmanagement.decline" @@ -49,33 +45,20 @@ class DeclineEditButton : IEditButton { val m = interaction.message val eb = MessageUtil.getAClonedEmbed(m.embeds[0]) var shouldEditButton = false - lateinit var mpdd: MatchPlanningDataData - var found = false - transaction { - for (pnr in MatchPlanningData.select { - MatchPlanningData.messageid eq (interaction.message.id.value.toLong()) and ( - MatchPlanningData.serverid eq (guild.id.value.toLong())) and ( - MatchPlanningData.channelid eq (interaction.channelId.value.toLong())) - }) { - mpdd = MatchPlanningDataData( - pnr[MatchPlanningData.id], - pnr[MatchPlanningData.serverid], - pnr[MatchPlanningData.channelid], - pnr[MatchPlanningData.matchtype], - pnr[MatchPlanningData.registererid], - pnr[MatchPlanningData.roleid], - pnr[MatchPlanningData.opponentName], - pnr[MatchPlanningData.messageid], - pnr[MatchPlanningData.timestamp], - pnr[MatchPlanningData.jobstr] - ) - found = true - } - } - if (!found || mpdd == null) { + val mpdd = MatchPlanningDataRepository.getFromMessageInChannelInServer( + m.id.value.toLong(), + interaction.channelId.value.toLong(), + guild.id.value.toLong() + ) + if (mpdd == null) { + Logger.out("mpdd is null") + return + } + val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) + if (role == null) { + Logger.out("role is null") return } - val role = guild.getRoleOrNull(Snowflake(mpdd.roleID)) ?: return val member = interaction.user.asMember(guild.id) ?: return if (m.embeds[0].fields[0].value.contains(user.id.value.toString())) { if (member.roleIds.contains(Snowflake(mpdd.roleID))) { diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt index a36f351..730e7fe 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt @@ -19,6 +19,7 @@ package net.moonleay.lilJudd.data.entry data class PlanningNotifierRolesData( + val id: Int, // The id of the entry val serverID: Long, // The id of the server val channelID: Long, // The id of the channel val hasTimeRoleID: Long, // The id of the role that has time today diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt index 2eebba4..fba9898 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt @@ -19,6 +19,7 @@ package net.moonleay.lilJudd.data.entry data class TimePlanningChannelsData( + val id: Int, val serverID: Long, val channelID: Long, ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt index 6c5b2fc..fcb283b 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt @@ -19,6 +19,7 @@ package net.moonleay.lilJudd.data.entry data class TimePlanningMessagesData( + val id: Int, // The id of the entry val serverID: Long, // The discord server id val channelID: Long, // The discord channel id val weekstamp: Long, // The timestamp of the monday of the week at 4am UTC diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/repository/MatchPlanningDataRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/repository/MatchPlanningDataRepository.kt new file mode 100644 index 0000000..385eb69 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/repository/MatchPlanningDataRepository.kt @@ -0,0 +1,112 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.repository + +import net.moonleay.lilJudd.data.entry.MatchPlanningDataData +import net.moonleay.lilJudd.data.tables.MatchPlanningData +import org.jetbrains.exposed.sql.* +import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq +import org.jetbrains.exposed.sql.transactions.transaction + +object MatchPlanningDataRepository { + + fun getAll(): List { + val dataList = mutableListOf() + transaction { + MatchPlanningData.selectAll().forEach { + dataList.add( + MatchPlanningDataData( + it[MatchPlanningData.id], + it[MatchPlanningData.serverid], + it[MatchPlanningData.channelid], + it[MatchPlanningData.matchtype], + it[MatchPlanningData.registererid], + it[MatchPlanningData.roleid], + it[MatchPlanningData.opponentName], + it[MatchPlanningData.messageid], + it[MatchPlanningData.timestamp], + it[MatchPlanningData.jobstr] + ) + ) + } + } + return dataList + } + + fun get(id: Int): MatchPlanningDataData? = + transaction { + MatchPlanningData.select { MatchPlanningData.id eq id }.firstOrNull()?.let { + MatchPlanningDataData( + it[MatchPlanningData.id], + it[MatchPlanningData.serverid], + it[MatchPlanningData.channelid], + it[MatchPlanningData.matchtype], + it[MatchPlanningData.registererid], + it[MatchPlanningData.roleid], + it[MatchPlanningData.opponentName], + it[MatchPlanningData.messageid], + it[MatchPlanningData.timestamp], + it[MatchPlanningData.jobstr] + ) + } + } + + fun getFromMessageInChannelInServer(messageID: Long, channelID: Long, serverID: Long): MatchPlanningDataData? = + transaction { + MatchPlanningData.select { + MatchPlanningData.messageid eq (messageID) and ( + MatchPlanningData.serverid eq (serverID)) and ( + MatchPlanningData.channelid eq (channelID)) + }.firstOrNull()?.let { + MatchPlanningDataData( + it[MatchPlanningData.id], + it[MatchPlanningData.serverid], + it[MatchPlanningData.channelid], + it[MatchPlanningData.matchtype], + it[MatchPlanningData.registererid], + it[MatchPlanningData.roleid], + it[MatchPlanningData.opponentName], + it[MatchPlanningData.messageid], + it[MatchPlanningData.timestamp], + it[MatchPlanningData.jobstr] + ) + } + } + + fun delete(id: Int) { + transaction { + MatchPlanningData.deleteWhere { MatchPlanningData.id eq id } + } + } + + fun write(data: MatchPlanningDataData): Int = + transaction { + MatchPlanningData.insert { + it[MatchPlanningData.serverid] = data.serverID + it[MatchPlanningData.channelid] = data.channelID + it[MatchPlanningData.matchtype] = data.matchType + it[MatchPlanningData.registererid] = data.registererID + it[MatchPlanningData.roleid] = data.roleID + it[MatchPlanningData.opponentName] = data.opponentName + it[MatchPlanningData.messageid] = data.messageID + it[MatchPlanningData.timestamp] = data.timestamp + it[MatchPlanningData.jobstr] = data.jobString + } get MatchPlanningData.id + } +} diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/repository/PlanningNotifierRolesRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/repository/PlanningNotifierRolesRepository.kt new file mode 100644 index 0000000..2603081 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/repository/PlanningNotifierRolesRepository.kt @@ -0,0 +1,104 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.repository + +import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData +import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles +import org.jetbrains.exposed.sql.* +import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq +import org.jetbrains.exposed.sql.transactions.transaction + +object PlanningNotifierRolesRepository { + + fun getAll(): List { + val dataList = mutableListOf() + transaction { + for (pnr in PlanningNotifierRoles.selectAll()) { + dataList.add( + PlanningNotifierRolesData( + pnr[PlanningNotifierRoles.id], + pnr[PlanningNotifierRoles.serverid], + pnr[PlanningNotifierRoles.channelid], + pnr[PlanningNotifierRoles.hastimeroleid], + pnr[PlanningNotifierRoles.wantstobenotifiedid] + ) + ) + } + } + return dataList + } + + fun getForChannel(channelID: Long): PlanningNotifierRolesData? = + transaction { + PlanningNotifierRoles.select { + PlanningNotifierRoles.channelid eq channelID + }.firstOrNull()?.let { + PlanningNotifierRolesData( + it[PlanningNotifierRoles.id], + it[PlanningNotifierRoles.serverid], + it[PlanningNotifierRoles.channelid], + it[PlanningNotifierRoles.hastimeroleid], + it[PlanningNotifierRoles.wantstobenotifiedid] + ) + } + } + + fun getForChannelInServer(channelID: Long, serverID: Long): PlanningNotifierRolesData? = + transaction { + PlanningNotifierRoles.select { + PlanningNotifierRoles.channelid eq channelID and (PlanningNotifierRoles.serverid eq serverID) + }.firstOrNull()?.let { + PlanningNotifierRolesData( + it[PlanningNotifierRoles.id], + it[PlanningNotifierRoles.serverid], + it[PlanningNotifierRoles.channelid], + it[PlanningNotifierRoles.hastimeroleid], + it[PlanningNotifierRoles.wantstobenotifiedid] + ) + } + } + + fun existsInChannel(channelID: Long): Boolean = + transaction { + PlanningNotifierRoles.select { PlanningNotifierRoles.channelid eq channelID }.count() > 0 + } + + fun existsInChannelFromSever(channelID: Long, serverID: Long): Boolean = + transaction { + PlanningNotifierRoles.select { PlanningNotifierRoles.channelid eq channelID and (PlanningNotifierRoles.serverid eq serverID) } + .count() > 0 + } + + fun write(data: PlanningNotifierRolesData) { + transaction { + PlanningNotifierRoles.insert { + it[PlanningNotifierRoles.serverid] = data.serverID + it[PlanningNotifierRoles.channelid] = data.channelID + it[PlanningNotifierRoles.hastimeroleid] = data.hasTimeRoleID + it[PlanningNotifierRoles.wantstobenotifiedid] = data.wantsToBeNotifiedID + } get PlanningNotifierRoles.id + } + } + + fun delete(id: Int) { + transaction { + PlanningNotifierRoles.deleteWhere { PlanningNotifierRoles.id eq id } + } + } +} diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningChannelsRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningChannelsRepository.kt new file mode 100644 index 0000000..7756802 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningChannelsRepository.kt @@ -0,0 +1,69 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.repository + +import net.moonleay.lilJudd.data.entry.TimePlanningChannelsData +import net.moonleay.lilJudd.data.tables.TimePlanningChannels +import org.jetbrains.exposed.sql.* +import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq +import org.jetbrains.exposed.sql.transactions.transaction + +object TimePlanningChannelsRepository { + + fun getAll(): List { + val dataList = mutableListOf() + transaction { + for (tp in TimePlanningChannels.selectAll()) + dataList.add( + TimePlanningChannelsData( + id = tp[TimePlanningChannels.id], + serverID = tp[TimePlanningChannels.serverid], + channelID = tp[TimePlanningChannels.channelid], + ) + ) + } + return dataList + } + + fun exists(channelID: Long, serverID: Long): Boolean = + transaction { + TimePlanningChannels.select { TimePlanningChannels.channelid eq channelID and (TimePlanningChannels.serverid eq serverID) } + .firstOrNull() != null + } + + fun delete(id: Int) { + transaction { + TimePlanningChannels.deleteWhere { TimePlanningChannels.id eq id } + } + } + + fun deleteFromChannelInServer(channelID: Long, serverID: Long) { + transaction { + TimePlanningChannels.deleteWhere { TimePlanningChannels.channelid eq channelID and (TimePlanningChannels.serverid eq serverID) } + } + } + + fun write(data: TimePlanningChannelsData): Int = + transaction { + TimePlanningChannels.insert { + it[TimePlanningChannels.serverid] = data.serverID + it[TimePlanningChannels.channelid] = data.channelID + } get TimePlanningChannels.id + } +} diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningMessagesRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningMessagesRepository.kt new file mode 100644 index 0000000..5e2f273 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningMessagesRepository.kt @@ -0,0 +1,76 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.repository + +import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData +import net.moonleay.lilJudd.data.tables.TimePlanningMessages +import org.jetbrains.exposed.sql.and +import org.jetbrains.exposed.sql.insert +import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.transactions.transaction + +object TimePlanningMessagesRepository { + + fun write(data: TimePlanningMessagesData): Int = + transaction { + TimePlanningMessages.insert { + it[serverid] = data.serverID + it[channelid] = data.channelID + it[weekstamp] = data.weekstamp + it[messageids] = data.messageIDs + } get TimePlanningMessages.id + } + + fun getWeek(stamp: Long): List { + val dataList = mutableListOf() + transaction { + for (pnr in TimePlanningMessages.select { + TimePlanningMessages.weekstamp eq (stamp) + }) { + dataList.add( + TimePlanningMessagesData( + pnr[TimePlanningMessages.id], + pnr[TimePlanningMessages.serverid], + pnr[TimePlanningMessages.channelid], + pnr[TimePlanningMessages.weekstamp], + pnr[TimePlanningMessages.messageids] + ) + ) + } + } + return dataList + } + + fun getWeekInChannel(stamp: Long, channelID: Long): TimePlanningMessagesData? = + transaction { + TimePlanningMessages.select { + TimePlanningMessages.weekstamp eq (stamp) and (TimePlanningMessages.channelid eq channelID) + }.firstOrNull()?.let { + TimePlanningMessagesData( + it[TimePlanningMessages.id], + it[TimePlanningMessages.serverid], + it[TimePlanningMessages.channelid], + it[TimePlanningMessages.weekstamp], + it[TimePlanningMessages.messageids] + ) + } + } + + +} diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt index 40787d4..17592e6 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt @@ -28,7 +28,8 @@ import com.kotlindiscord.kord.extensions.types.respond import dev.kord.core.behavior.channel.createMessage import dev.kord.core.behavior.createRole import dev.kord.rest.builder.message.create.actionRow -import net.moonleay.lilJudd.data.tables.MatchPlanningData +import net.moonleay.lilJudd.data.entry.MatchPlanningDataData +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.extensions.component.MatchTypes import net.moonleay.lilJudd.jobs.MatchJob import net.moonleay.lilJudd.jobs.component.JobManager @@ -36,9 +37,6 @@ import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.MessageUtil import net.moonleay.lilJudd.util.TimeUtil -import org.jetbrains.exposed.sql.insert -import org.jetbrains.exposed.sql.transactions.transaction -import kotlin.properties.Delegates class MatchExtension : Extension() { @@ -100,28 +98,28 @@ class MatchExtension : Extension() { } return@action } - var tableID by Delegates.notNull() - transaction { - tableID = MatchPlanningData.insert { - it[MatchPlanningData.serverid] = gID.toLong() - it[MatchPlanningData.channelid] = cID.toLong() - it[MatchPlanningData.messageid] = msg.id.value.toLong() - it[MatchPlanningData.matchtype] = args.matchType.readableName - it[MatchPlanningData.roleid] = role.id.value.toLong() - it[MatchPlanningData.registererid] = m.id.value.toLong() - it[MatchPlanningData.opponentName] = opponent - it[MatchPlanningData.timestamp] = (zdt.toEpochSecond() * 1000) - it[MatchPlanningData.jobstr] = jobString - } get MatchPlanningData.id - } - if (tableID == null) { + val tID = MatchPlanningDataRepository.write( + MatchPlanningDataData( + 0, + gID.toLong(), + cID.toLong(), + args.matchType.readableName, + m.id.value.toLong(), + role.id.value.toLong(), + opponent, + msg.id.value.toLong(), + (zdt.toEpochSecond() * 1000), + jobString + ) + ) + if (tID == null || tID <= 0) { return@action // Not saved to db } JobManager.addJob( MatchJob( jobString, - tableID, - "${args.matchType.readableName}_Vs_${opponent}_[${tableID}]-${gID}_${cID}", + tID, + "${args.matchType.readableName}_Vs_${opponent}_[${tID}]-${gID}_${cID}", ) ) } diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt index fd293d9..ee85372 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt @@ -26,10 +26,9 @@ import dev.kord.common.entity.Permission import dev.kord.core.behavior.channel.createMessage import dev.kord.rest.builder.message.create.actionRow import kotlinx.coroutines.delay -import net.moonleay.lilJudd.data.tables.TimePlanningMessages +import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData +import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.util.* -import org.jetbrains.exposed.sql.insert -import org.jetbrains.exposed.sql.transactions.transaction import java.time.ZoneId import java.time.ZonedDateTime @@ -101,14 +100,15 @@ class SendPlannerExtension : Extension() { } // Save the message ids - transaction { - TimePlanningMessages.insert { - it[TimePlanningMessages.serverid] = c.data.guildId.value?.value!!.toLong() - it[TimePlanningMessages.channelid] = c.id.value.toLong() - it[TimePlanningMessages.weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000) - it[TimePlanningMessages.messageids] = msgStr - } get TimePlanningMessages.id - } + TimePlanningMessagesRepository.write( + TimePlanningMessagesData( + -1, + c.data.guildId.value?.value!!.toLong(), + c.id.value.toLong(), + (TimeUtil.getWeekStamp().toEpochSecond() * 1000), + msgStr + ) + ) Logger.out("Finished with ${c.data.guildId.value}") } } diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index 8683dd5..6a42046 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -32,61 +32,35 @@ import dev.kord.rest.builder.message.EmbedBuilder import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData -import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles -import net.moonleay.lilJudd.data.tables.TimePlanningMessages +import net.moonleay.lilJudd.data.repository.PlanningNotifierRolesRepository +import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.extensions.FeatureManageExtension import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.IFeature import net.moonleay.lilJudd.util.* -import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq -import org.jetbrains.exposed.sql.transactions.transaction import java.time.ZonedDateTime object AvailabilityManager : IFeature { // This runs during the cronjob. - @OptIn(PrivilegedIntent::class) suspend fun runThread() { Logger.out("Starting to update roles...") // ChannelID, Data - val messageMap = mutableMapOf() - // ChannelID, Data - val roleMap = mutableMapOf() + val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond() * 1000) + .associateBy { it.channelID } + val targetedRoles = PlanningNotifierRolesRepository.getAll().associateBy { it.channelID } - transaction { - for (pnr in TimePlanningMessages.select { - TimePlanningMessages.weekstamp eq (TimeUtil.getWeekStamp().toEpochSecond() * 1000) - }) { - messageMap[Snowflake(pnr[TimePlanningMessages.channelid])] = - TimePlanningMessagesData( - pnr[TimePlanningMessages.serverid], - pnr[TimePlanningMessages.channelid], - pnr[TimePlanningMessages.weekstamp], - pnr[TimePlanningMessages.messageids] - ) - } - for (pnr in PlanningNotifierRoles.selectAll()) { - roleMap[pnr[PlanningNotifierRoles.channelid]] = - PlanningNotifierRolesData( - pnr[PlanningNotifierRoles.serverid], - pnr[PlanningNotifierRoles.channelid], - pnr[PlanningNotifierRoles.hastimeroleid], - pnr[PlanningNotifierRoles.wantstobenotifiedid] - ) - } - } - - for (snf in messageMap.keys) { // snf = Snowflake - val data = messageMap[snf]!! // this is the data of the table + for (id in messages.keys) { + val snf = Snowflake(id) // snf = Snowflake + val data = messages[id]!! // this is the data of the table if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) continue // This channel does not exist anymore. - if (roleMap.isEmpty()) { + if (targetedRoles.isEmpty()) { Logger.out("No saved roles. Canceling.") return } - val roleData = roleMap[data.channelID] // Get the role data + val roleData = targetedRoles[data.channelID] // Get the role data if (roleData == null) { Logger.out("Role for channel ${data.channelID} does not exist") continue // this took way to long to find out that this was the issue @@ -97,58 +71,27 @@ object AvailabilityManager : IFeature { } suspend fun updateInChannel(snf: Snowflake) { - lateinit var data: TimePlanningMessagesData - lateinit var roleData: PlanningNotifierRolesData - var found1 = false - var found2 = false - for (pnr in TimePlanningMessages.select { - TimePlanningMessages.weekstamp eq (TimeUtil.getWeekStamp() - .toEpochSecond() * 1000) and (TimePlanningMessages.channelid eq (snf.value.toLong())) - }) { - data = - TimePlanningMessagesData( - pnr[TimePlanningMessages.serverid], - pnr[TimePlanningMessages.channelid], - pnr[TimePlanningMessages.weekstamp], - pnr[TimePlanningMessages.messageids] - ) - found1 = true - } - for (pnr in PlanningNotifierRoles.select { - PlanningNotifierRoles.channelid eq (snf.value.toLong()) - }) { - roleData = - PlanningNotifierRolesData( - pnr[PlanningNotifierRoles.serverid], - pnr[PlanningNotifierRoles.channelid], - pnr[PlanningNotifierRoles.hastimeroleid], - pnr[PlanningNotifierRoles.wantstobenotifiedid] - ) - found2 = true - } - if (!found1 || !found2) { + val messageData = TimePlanningMessagesRepository.getWeekInChannel( + TimeUtil.getWeekStamp().toEpochSecond() * 1000, + snf.value.toLong() + ) + val roleData = PlanningNotifierRolesRepository.getForChannel(snf.value.toLong()) + if (messageData == null) { Logger.out("Could not find data for channel ${snf.value}") return } - if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) - return // This channel does not exist anymore. if (roleData == null) { - Logger.out("Role for channel ${data.channelID} does not exist") + Logger.out("Role for channel ${messageData.channelID} does not exist") return // this took way to long to find out that this was the issue } - updateInChannel(snf, data, roleData) + updateInChannel(snf, messageData, roleData) } @OptIn(PrivilegedIntent::class) suspend fun updateInChannel(snf: Snowflake, tpmd: TimePlanningMessagesData, pnrd: PlanningNotifierRolesData) { - if (Bot.bot.kordRef.getChannel(Snowflake(tpmd.channelID)) == null) + if (Bot.bot.kordRef.getChannel(snf) == null) return // This channel does not exist anymore. - val c = - Bot.bot.kordRef.getChannelOf(Snowflake(tpmd.channelID))!! // Get the channel as MessageChannel - if (Bot.bot.kordRef.getGuildOrNull(Snowflake(tpmd.serverID)) == null) { - Logger.out("Guild not found.") - return - } + val c = Bot.bot.kordRef.getChannelOf(snf)!! // Get the channel as MessageChannel val weekday = ZonedDateTime.now().dayOfWeek // The current week day val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() * 1000 // The current week time stamp Logger.out("It is week ${weekStamp} and day ${weekday}/${TimeUtil.getDayOfMonthInt(weekday)} of the week.") @@ -228,13 +171,8 @@ object AvailabilityManager : IFeature { ch: Channel, args: FeatureManageExtension.FeatureManagerArgs ): EmbedBuilder { - var alreadyExists = false + var alreadyExists = PlanningNotifierRolesRepository.existsInChannel(cID) // Check if the channel and guild already exist in the db - transaction { - alreadyExists = PlanningNotifierRoles.select { - (PlanningNotifierRoles.serverid eq gID) and (PlanningNotifierRoles.channelid eq cID) - }.count() > 0 - } if (!alreadyExists) { // Create the roles in Discord val hasTimeRole = Bot.bot.kordRef.getGuildOrThrow(Snowflake(gID)).createRole { @@ -250,14 +188,15 @@ object AvailabilityManager : IFeature { val wnr = wantsNotifsRole.id.value.toLong() // Save the role ids to db - transaction { - PlanningNotifierRoles.insert { - it[PlanningNotifierRoles.serverid] = gID - it[PlanningNotifierRoles.channelid] = cID - it[PlanningNotifierRoles.hastimeroleid] = htr - it[PlanningNotifierRoles.wantstobenotifiedid] = wnr - } get PlanningNotifierRoles.id - } + PlanningNotifierRolesRepository.write( + PlanningNotifierRolesData( + id = -1, + serverID = gID, + channelID = cID, + hasTimeRoleID = htr, + wantsToBeNotifiedID = wnr + ) + ) return MessageUtil.getEmbed( EmbedColor.SUCCESS, @@ -284,35 +223,16 @@ object AvailabilityManager : IFeature { args: FeatureManageExtension.FeatureManagerArgs ): EmbedBuilder { // Check if entry exists in db - var alreadyExists = false - transaction { - alreadyExists = PlanningNotifierRoles.select { - (PlanningNotifierRoles.serverid eq gID) and (PlanningNotifierRoles.channelid eq cID) - }.count() > 0 - } - if (alreadyExists) { - var matchingEntries: List = mutableListOf() - transaction { - matchingEntries = PlanningNotifierRoles.select { - (PlanningNotifierRoles.serverid eq gID) and - (PlanningNotifierRoles.channelid eq cID) - }.toList() - } + if (PlanningNotifierRolesRepository.existsInChannelFromSever(cID, gID)) { + val entry = PlanningNotifierRolesRepository.getForChannelInServer(cID, gID)!! // delete all entries for this guild and channel combo - for (e in matchingEntries) { - Bot.bot.kordRef.getGuildOrThrow(Snowflake(gID)) - .getRoleOrNull(Snowflake(e[PlanningNotifierRoles.hastimeroleid]))?.delete() - Bot.bot.kordRef.getGuildOrThrow(Snowflake(gID)) - .getRoleOrNull(Snowflake(e[PlanningNotifierRoles.wantstobenotifiedid])) - ?.delete() - } + Bot.bot.kordRef.getGuildOrThrow(Snowflake(gID)) + .getRoleOrNull(Snowflake(entry.hasTimeRoleID))?.delete() + Bot.bot.kordRef.getGuildOrThrow(Snowflake(gID)) + .getRoleOrNull(Snowflake(entry.wantsToBeNotifiedID))?.delete() // delete all found entries - transaction { - matchingEntries.forEach { entry -> - PlanningNotifierRoles.deleteWhere { id eq entry[id] } - } - } + PlanningNotifierRolesRepository.delete(entry.id) return MessageUtil.getEmbed( EmbedColor.SUCCESS, "200: Success", diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt index aeb2203..fc89dc9 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt @@ -21,46 +21,22 @@ package net.moonleay.lilJudd.features import dev.kord.common.entity.Snowflake import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.data.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.tables.MatchPlanningData +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.jobs.MatchJob import net.moonleay.lilJudd.jobs.component.JobManager import net.moonleay.lilJudd.util.Logger -import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq -import org.jetbrains.exposed.sql.deleteWhere -import org.jetbrains.exposed.sql.selectAll -import org.jetbrains.exposed.sql.transactions.transaction object MatchManager { suspend fun update() { Logger.out("Updating match roles...") - val dataList = mutableListOf() - transaction { - MatchPlanningData.selectAll().forEach { - dataList.add( - MatchPlanningDataData( - it[MatchPlanningData.id], - it[MatchPlanningData.serverid], - it[MatchPlanningData.channelid], - it[MatchPlanningData.matchtype], - it[MatchPlanningData.registererid], - it[MatchPlanningData.roleid], - it[MatchPlanningData.opponentName], - it[MatchPlanningData.messageid], - it[MatchPlanningData.timestamp], - it[MatchPlanningData.jobstr] - ) - ) - } - } + val dataList = MatchPlanningDataRepository.getAll() for (data in dataList) { Logger.out("Checking match role ${data.id}...") - if (data.timestamp.toLong() < System.currentTimeMillis()) { + if (data.timestamp < System.currentTimeMillis()) { Logger.out("Match role ${data.id} is expired, removing...") this.removeRoleFromGuild(data.serverID, data.roleID) - transaction { - MatchPlanningData.deleteWhere { MatchPlanningData.messageid eq data.messageID } - } + MatchPlanningDataRepository.delete(data.id) continue } this.registerJob(data) diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt index 8a66ee7..d986440 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt @@ -29,17 +29,18 @@ import dev.kord.rest.builder.message.EmbedBuilder import dev.kord.rest.builder.message.create.actionRow import kotlinx.coroutines.delay import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData -import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles -import net.moonleay.lilJudd.data.tables.TimePlanningChannels -import net.moonleay.lilJudd.data.tables.TimePlanningMessages +import net.moonleay.lilJudd.data.entry.TimePlanningChannelsData +import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData +import net.moonleay.lilJudd.data.repository.PlanningNotifierRolesRepository +import net.moonleay.lilJudd.data.repository.TimePlanningChannelsRepository +import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.extensions.FeatureManageExtension import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.IFeature -import net.moonleay.lilJudd.util.* -import org.jetbrains.exposed.sql.* -import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq -import org.jetbrains.exposed.sql.transactions.transaction +import net.moonleay.lilJudd.util.EmbedColor +import net.moonleay.lilJudd.util.EmbedUtil +import net.moonleay.lilJudd.util.Logger +import net.moonleay.lilJudd.util.MessageUtil import java.time.ZoneId import java.time.ZonedDateTime @@ -60,41 +61,23 @@ object TimeManager : IFeature { private suspend fun runThread() { Logger.out("Starting to notify...") + // ChannelID -> Data + val targetedChannels = TimePlanningChannelsRepository.getAll().associateBy { it.channelID } + val targetedRoles = PlanningNotifierRolesRepository.getAll().associateBy { it.channelID } - // ChannelID, ServerID - val channelList = mutableMapOf() - // ChannelID, Data - val roleMap = mutableMapOf() + lateinit var msgStr: String - var msgStr = "" - - transaction { - for (tp in TimePlanningChannels.selectAll()) { - channelList[Snowflake(tp[TimePlanningChannels.channelid])] = - Snowflake(tp[TimePlanningChannels.serverid]) - Logger.out("Have to notify channel with ID ${tp[TimePlanningChannels.channelid]}.") - } - - for (pnr in PlanningNotifierRoles.selectAll()) { - roleMap[Snowflake(pnr[PlanningNotifierRoles.channelid])] = PlanningNotifierRolesData( - pnr[PlanningNotifierRoles.serverid], - pnr[PlanningNotifierRoles.channelid], - pnr[PlanningNotifierRoles.hastimeroleid], - pnr[PlanningNotifierRoles.wantstobenotifiedid] - ) - Logger.out("Have to ping roles: ${pnr[PlanningNotifierRoles.wantstobenotifiedid]}}") - } - } - Logger.out("${channelList.count()} Channels to notify with ${roleMap.count()} Roles to ping!") - for (ch in channelList.keys) { + Logger.out("${targetedChannels.count()} Channels to notify with ${targetedRoles.count()} Roles to ping!") + for (ch2 in targetedChannels.keys) { + val ch = Snowflake(ch2) if (Bot.bot.kordRef.getChannel(ch) == null) continue // TODO: Check if the channel is valid in another shard val c = Bot.bot.kordRef.getChannelOf(ch)!! msgStr = "" - if (roleMap != null && roleMap.keys.contains(ch) && roleMap[ch] != null) { + if (targetedRoles != null && targetedRoles.keys.contains(ch2) && targetedRoles[ch2] != null) { c.createMessage { this.content = - "The weekly planning starts now <@&${Snowflake(roleMap[ch]?.wantsToBeNotifiedID!!)}>" + "The weekly planning starts now <@&${Snowflake(targetedRoles[ch2]?.wantsToBeNotifiedID!!)}>" this.embeds.add( MessageUtil.getEmbed( EmbedColor.INFO, @@ -145,14 +128,15 @@ object TimeManager : IFeature { } // Save the message ids - transaction { - TimePlanningMessages.insert { - it[TimePlanningMessages.serverid] = c.data.guildId.value?.value!!.toLong() - it[TimePlanningMessages.channelid] = c.id.value.toLong() - it[TimePlanningMessages.weekstamp] = (TimeUtil.getWeekStamp().toEpochSecond() * 1000) - it[TimePlanningMessages.messageids] = msgStr - } get TimePlanningMessages.id - } + TimePlanningMessagesRepository.write( + TimePlanningMessagesData( + id = -1, + serverID = c.data.guildId.value?.value!!.toLong(), + channelID = c.data.id.value.toLong(), + weekstamp = then.minusDays(7).toEpochSecond(), + messageIDs = msgStr + ) + ) Logger.out("Finished with ${c.data.guildId.value}") } Logger.out("Done! Until next Monday! <3 ") @@ -165,20 +149,8 @@ object TimeManager : IFeature { ch: Channel, args: FeatureManageExtension.FeatureManagerArgs ): EmbedBuilder { - var alreadyExists = false - transaction { - alreadyExists = TimePlanningChannels.select { - (TimePlanningChannels.serverid eq gID) and - (TimePlanningChannels.channelid eq cID) - }.count() > 0 - } - if (!alreadyExists) { - transaction { - TimePlanningChannels.insert { - it[TimePlanningChannels.serverid] = gID - it[TimePlanningChannels.channelid] = cID - } get TimePlanningChannels.id - } + if (!TimePlanningChannelsRepository.exists(cID, gID)) { + TimePlanningChannelsRepository.write(TimePlanningChannelsData(id = -1, serverID = gID, channelID = cID)) return MessageUtil.getEmbed( EmbedColor.SUCCESS, "200: Success", @@ -202,25 +174,9 @@ object TimeManager : IFeature { args: FeatureManageExtension.FeatureManagerArgs ): EmbedBuilder { // Check if entry exists in db - var alreadyExists = false - transaction { - alreadyExists = TimePlanningChannels.select { - (TimePlanningChannels.serverid eq gID) and - (TimePlanningChannels.channelid eq cID) - }.count() > 0 - } - if (alreadyExists) { + if (TimePlanningChannelsRepository.exists(cID, gID)) { // delete all entrys for this channel - transaction { - val matchingEntries = TimePlanningChannels.select { - (TimePlanningChannels.serverid eq gID) and - (TimePlanningChannels.channelid eq cID) - }.toList() - - matchingEntries.forEach { entry -> - TimePlanningChannels.deleteWhere { id eq entry[id] } - } - } + TimePlanningChannelsRepository.deleteFromChannelInServer(cID, gID) return MessageUtil.getEmbed( EmbedColor.SUCCESS, "200: Success", diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt index f350b86..8360f62 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt @@ -22,16 +22,11 @@ import dev.inmo.krontab.KronScheduler import dev.kord.common.entity.Snowflake import kotlinx.coroutines.Job import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.tables.MatchPlanningData +import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.jobs.component.CronjobType import net.moonleay.lilJudd.jobs.component.ICronjob import net.moonleay.lilJudd.jobs.component.JobManager import net.moonleay.lilJudd.util.Logger -import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq -import org.jetbrains.exposed.sql.deleteWhere -import org.jetbrains.exposed.sql.select -import org.jetbrains.exposed.sql.transactions.transaction class MatchJob( override val jobIncoming: String, @@ -48,25 +43,7 @@ class MatchJob( * */ override suspend fun jobFunction() { Logger.out("Running MatchJob \"${this.jobName}\"") - lateinit var mpdd: MatchPlanningDataData - transaction { - for (pnr in MatchPlanningData.select { - MatchPlanningData.id eq (tableId) - }) { - mpdd = MatchPlanningDataData( - pnr[MatchPlanningData.id], - pnr[MatchPlanningData.serverid], - pnr[MatchPlanningData.channelid], - pnr[MatchPlanningData.matchtype], - pnr[MatchPlanningData.registererid], - pnr[MatchPlanningData.roleid], - pnr[MatchPlanningData.opponentName], - pnr[MatchPlanningData.messageid], - pnr[MatchPlanningData.timestamp], - pnr[MatchPlanningData.jobstr] - ) - } - } + val mpdd = MatchPlanningDataRepository.get(tableId)!! val guild = Bot.bot.kordRef.getGuildOrNull(Snowflake(mpdd.serverID)) if (guild == null) { Logger.out("Guild not found.") @@ -78,11 +55,7 @@ class MatchJob( return } r.delete() - transaction { - MatchPlanningData.deleteWhere { - MatchPlanningData.id eq (tableId) - } - } + MatchPlanningDataRepository.delete(tableId) Logger.out("MatchJob \"${this.jobName}\" finished.") Logger.out("Killing job \"${this.jobName}\"..") JobManager.killJob(this) From 672982ef37daf2412f54d105d206a729968ab4e5 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 15 Sep 2023 23:37:06 +0200 Subject: [PATCH 076/103] chore: bump version Signed-off-by: moonleay --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index dcda691..ceda37c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,7 @@ val ownerID = 372703841151614976L group = "net.moonleay.liljudd" version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } - ?: "2.5.4" + ?: "2.5.5" val kordver = "1.5.6" val coroutinesver = "1.1.0" From d2af0fce9452f24d64e85b0e88d5a872c456954e Mon Sep 17 00:00:00 2001 From: moonleay Date: Sun, 17 Sep 2023 12:58:15 +0200 Subject: [PATCH 077/103] chore!: upgrade dependencies & gradle (7.4.2 -> 8.3) Signed-off-by: moonleay --- build.gradle.kts | 34 ++++++++++++++--------- gradle/wrapper/gradle-wrapper.jar | Bin 60756 -> 59821 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ceda37c..a90bf54 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,9 +21,9 @@ import org.jetbrains.gradle.ext.TaskTriggersConfig import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - kotlin("jvm") version "1.8.20" - id("com.github.johnrengelman.shadow") version "7.1.2" - id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.6" + kotlin("jvm") version "1.9.10" + id("com.github.johnrengelman.shadow") version "8.1.1" + id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7" `maven-publish` } @@ -32,14 +32,14 @@ val ownerID = 372703841151614976L group = "net.moonleay.liljudd" version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } - ?: "2.5.5" + ?: "2.5.6" -val kordver = "1.5.6" -val coroutinesver = "1.1.0" -val ktor_version = "2.3.0" -val exposedver = "0.40.1" -val postgresver = "42.3.8" -val krontabver = "2.1.2" +val kordver = "1.5.9-SNAPSHOT" +val coroutinesver = "1.7.3" +val ktor_version = "2.3.4" +val exposedver = "0.43.0" +val postgresver = "42.6.0" +val krontabver = "2.2.0" val mavenArtifact = "lilJudd" project.base.archivesName.set(mavenArtifact) @@ -72,6 +72,14 @@ repositories { } } } + maven { + name = "sonatype" + url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") + } + maven { + name = "sonatype 2" + url = uri("https://oss.sonatype.org/content/repositories/snapshots") + } } val shadow by configurations.getting @@ -95,14 +103,14 @@ dependencies { //Korntab shadow("dev.inmo:krontab:$krontabver") - "shadow"("io.ktor:ktor-client-core-jvm:2.3.1") - "shadow"("io.ktor:ktor-client-cio-jvm:2.3.1") + "shadow"("io.ktor:ktor-client-core-jvm:2.3.4") + "shadow"("io.ktor:ktor-client-cio-jvm:2.3.4") } val targetJavaVersion = 17 val templateSrc = project.rootDir.resolve("src/main/templates") -val templateDest = project.buildDir.resolve("generated/templates") +val templateDest = project.projectDir.resolve("build/generated/templates") val templateProps = mapOf( "version" to project.version as String, "ownerID" to ownerID, diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e5832f090a2944b7473328c07c9755baa3196..41d9927a4d4fb3f96a785543079b8df6723c946b 100644 GIT binary patch delta 9308 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 delta 10197 zcmaKS1ymhDwk=#NxVyW%y9U<)A-Dv)xI0|j{UX8L-JRg>5ZnnKAh;%chM6~S-g^K4 z>eZ{yK4;gd>gwvXs=Id8Jk-J}R4pT911;+{Jp9@aiz6!p1Oz9z&_kGLA%J5%3Ih@0 zQ|U}%$)3u|G`jIfPzMVfcWs?jV2BO^*3+q2><~>3j+Z`^Z%=;19VWg0XndJ zwJ~;f4$;t6pBKaWn}UNO-wLCFHBd^1)^v%$P)fJk1PbK5<;Z1K&>k~MUod6d%@Bq9 z>(44uiaK&sdhwTTxFJvC$JDnl;f}*Q-^01T508(8{+!WyquuyB7R!d!J)8Ni0p!cV6$CHsLLy6}7C zYv_$eD;)@L)tLj0GkGpBoa727hs%wH$>EhfuFy{_8Q8@1HI%ZAjlpX$ob{=%g6`Ox zLzM!d^zy`VV1dT9U9(^}YvlTO9Bf8v^wMK37`4wFNFzW?HWDY(U(k6@tp(crHD)X5>8S-# zW1qgdaZa*Sh6i%60e1+hty}34dD%vKgb?QmQiZ=-j+isA4={V_*R$oGN#j|#ia@n6 zuZx4e2Xx?^lUwYFn2&Tmbx0qA3Z8;y+zKoeQu;~k~FZGy!FU_TFxYd!Ck;5QvMx9gj5fI2@BLNp~Ps@ zf@k<&Q2GS5Ia9?_D?v~$I%_CLA4x~eiKIZ>9w^c#r|vB?wXxZ(vXd*vH(Fd%Me8p( z=_0)k=iRh%8i`FYRF>E97uOFTBfajv{IOz(7CU zv0Gd84+o&ciHlVtY)wn6yhZTQQO*4Mvc#dxa>h}82mEKKy7arOqU$enb9sgh#E=Lq zU;_RVm{)30{bw+|056%jMVcZRGEBSJ+JZ@jH#~DvaDQm92^TyUq=bY*+AkEakpK>8 zB{)CkK48&nE5AzTqT;WysOG|!y}5fshxR8Ek(^H6i>|Fd&wu?c&Q@N9ZrJ=?ABHI! z`*z8D`w=~AJ!P-9M=T}f`;76$qZRllB&8#9WgbuO$P7lVqdX1=g*t=7z6!0AQ^ux_ z9rcfUv^t}o_l-ZE+TqvqFsA*~W<^78!k;~!i8(eS+(+@u8FxK+Q7;mHZ<1}|4m<}vh@p`t%|@eM_J(P% zI>M7C)Ir{l|J;$G_EGGEhbP4?6{sYzMqBv+x95N&YWFH6UcE@b}B?q)G*4<4mR@sy1#vPnLMK51tb#ED(8TA1nE zYfhK7bo1!R5WJF$5Y?zG21)6+_(_5oSX9sGIW;(O&S?Rh(nydNQYzKjjJ54aDJ-1F zrJ=np8LsN?%?Rt7f~3aAX!2E{`fh_pb?2(;HOB3W+I*~A>W%iY+v45+^e$cE10fA} zXPvw9=Bd+(;+!rl)pkYj0HGB}+3Z!Mr;zr%gz~c-hFMv8b2VRE2R$8V=_XE zq$3=|Yg05(fmwrJ)QK2ptB4no`Y8Dg_vK2QDc6-6sXRQ5k78-+cPi-fH}vpgs|Ive zE=m*XNVs?EWgiNI!5AcD*3QMW)R`EqT!f0e1%hERO&?AT7HWnSf5@#AR{OGuXG3Zb zCnVWg7h|61lGV3k+>L<#d>)InG>ETn1DbOHCfztqzQ_fBiaUt@q6VMy={Fe-w#~2- z0?*f|z$zgjI9>+JVICObBaK=pU}AEOd@q(8d?j7zQFD@=6t`|KmolTr2MfBI$;EGh zD%W0cA_d#V6Lb$us5yIG(|d>r-QleC4;%hEu5W9hyY zY#+ESY&v`8(&mC~?*|e5WEhC!YU2>m_}`K+q9)a(d$bsS<=YkyZGp}YA%TXw>@abA zS_poVPoN+?<6?DAuCNt&5SHV(hp56PJ})swwVFZFXM->F zc|0c8<$H_OV%DR|y7e+s$12@Ac8SUClPg8_O9sTUjpv%6Jsn5vsZCg>wL+db4c+{+ zsg<#wOuV4jeOq`veckdi-1`dz;gvL)bZeH|D*x=8UwRU5&8W1@l>3$)8WzET0%;1J zM3(X<7tKK&9~kWRI{&FmwY5Gg!b5f4kI_vSm)H1#>l6M+OiReDXC{kPy!`%Ecq-+3yZTk=<` zm)pE6xum5q0Qkd#iny0Q-S}@I0;mDhxf>sX)Oiv)FdsAMnpx%oe8OQ`m%Xeozdzx!C1rQR>m1c_}+J4x)K}k{G zo68;oGG&Ox7w^-m7{g4a7NJu-B|~M;oIH~~#`RyUNm##feZH;E?pf}nshmoiIY52n z%pc%lnU4Q#C=RUz)RU6}E_j4#)jh<&a%JyJj$Fufc#&COaxFHtl}zJUGNLBu3~_@1 zn9F^JO9);Duxo&i@>X(kbYga1i>6p1fca8FzQ0>((Lb-aPUbC*d~a03V$y;*RBY!R ziEJ2IF^FjrvO}0Uy{cMn%u<+P5U!UO>pm9#ZYL5i6|xSC+np7IH$GfXs&uI;y4as@ z&AzJh>(S2?3PKKgab3Z(`xbx(C#46XIvVcW8eG_DjT~}Yz_8PWZ`uf6^Xr=vkvL_` zqmvfgJL+Zc`;iq~iP?%@G7}~fal-zqxa0yNyHBJJ5M)9bI>7S_cg?Ya&p(I)C5Ef4 zZ>YAF6x|U=?ec?g*|f2g5Tw3PgxaM_bi_5Az9MO$;_Byw(2d}2%-|bg4ShdQ;)Z|M z4K|tFv)qx*kKGKoyh!DQY<{n&UmAChq@DJrQP>EY7g1JF(ih*D8wCVWyQ z5Jj^|-NVFSh5T0vd1>hUvPV6?=`90^_)t(L9)XOW7jeP45NyA2lzOn&QAPTl&d#6P zSv%36uaN(9i9WlpcH#}rmiP#=L0q(dfhdxvFVaOwM;pY;KvNQ9wMyUKs6{d}29DZQ z{H3&Sosr6)9Z+C>Q5)iHSW~gGoWGgK-0;k~&dyr-bA3O|3PCNzgC?UKS_B=^i8Ri^ zd_*_qI4B07Cayq|p4{`U_E_P=K`N_~{F|+-+`sCgcNxs`%X!$=(?l2aAW}0M=~COb zf19oe^iuAUuDEf)4tgv<=WRPpK@IjToNNC*#&Ykw!)aqWU4h#|U@(cG_=Qx+&xt~a zvCz~Ds3F71dsjNLkfM%TqdVNu=RNMOzh7?b+%hICbFlOAPphrYy>7D-e7{%o_kPFn z;T!?ilE-LcKM0P(GKMseEeW57Vs`=FF}(y@^pQl;rL3fHs8icmA+!6YJt&8 ztSF?%Un35qkv>drkks&BNTJv~xK?vD;aBkp7eIkDYqn+G0%;sT4FcwAoO+vke{8CO z0d76sgg$CannW5T#q`z~L4id)9BCKRU0A!Z-{HpXr)QJrd9@iJB+l32Ql)Z}*v(St zE)Vp=BB=DDB4Pr}B(UHNe31<@!6d{U?XDoxJ@S)9QM)2L%SA0x^~^fb=bdsBy!uh& zU?M_^kvnt%FZzm+>~bEH{2o?v&Iogs`1t-b+Ml`J!ZPS(46YQJKxWE81O$HE5w;** z|8zM%bp`M7J8)4;%DqH`wVTmM0V@D}xd%tRE3_6>ioMJxyi5Hkb>85muF81&EY!73ei zA3e<#ug||EZJ=1GLXNJ)A z791&ge#lF;GVX6IU?iw0jX^1bYaU?+x{zPlpyX6zijyn*nEdZ$fxxkl!a-~*P3bkf zPd*pzu~3GBYkR_>ET`5UM^>>zTV>5m>)f=az{d0sg6a8VzUtXy$ZS?h#Gk-CA?7)c zI%Vu9DN6XSDQn6;?n9`>l$q&>s?K)R8*OsmI+$L_m z_~E`}w694Z*`Xk3Ne=497Si~=RWRqCM?6=88smrxle#s*W znwhTRsMRmg?37GLJ-)%nDZA7r$YG849j8mJWir1bWBy& zZPneYojSbooC8U@tkO`bWx4%E5*;p#Q^1^S3lsfy7(6A{jL0`A__0vm?>xC%1y8_m z57FfWr^@YG2I1K7MGYuYd>JC}@sT2n^rkrY3w%~$J$Y~HSoOHn?zpR$ zjLj_bq@Yj8kd~DXHh30KVbz@K)0S;hPKm+S&-o%IG+@x@MEcrxW2KFh;z^4dJDZix zGRGe&lQD$p)0JVF4NRgGYuh0bYLy)BCy~sbS3^b3 zHixT<%-Vwbht|25T{3^Hk;qZ^3s!OOgljHs+EIf~C%=_>R5%vQI4mQR9qOXThMXlU zS|oSH>0PjnCakb*js2{ObN`}%HYsT6=%(xA| znpUtG_TJ08kHgm5l@G|t?4E3tG2fq?wNtIp*Vqrb{9@bo^~Rx7+J&OnayrX`LDcF~ zd@0m0ZJ#Z@=T>4kTa5e2FjI&5c(F7S{gnRPoGpu9eIqrtSvnT_tk$8T)r%YwZw!gK zj*k@cG)V&@t+mtDi37#>LhVGTfRA^p%x0d#_P|Mktz3*KOoLIqFm`~KGoDDD4OOxe z?}ag_c08u%vu=5Vx=~uoS8Q;}+R2~?Uh|m-+`-2kDo$d6T!nD*hc#dB(*R{LXV=zo z`PJP0V=O!@3l-bw+d`X6(=@fq=4O#ETa8M^fOvO4qja9o3e8ANc9$sI=A4$zUut~w z4+JryRkI{9qWxU1CCMM$@Aj=6)P+z?vqa=UCv_4XyVNoBD{Xb~Oi4cjjhm8fRD!*U z2)zaS;AI78^Wq+5mDInKiMz|z#K`2emQfNH*U;{9^{NqSMVoq?RSo43<8YpJM^+W$ zxy!A5>5Zl16Vi#?nAYywu3w_=KWnd3*QetocWt`3pK67>)ZVwnT3h zbPdD&MZkD?q=-N`MpCCwpM74L+Tr1aa)zJ)8G;(Pg51@U&5W>aNu9rA`bh{vgfE={ zdJ>aKc|2Ayw_bop+dK?Y5$q--WM*+$9&3Q9BBiwU8L<-`T6E?ZC`mT0b}%HR*LPK} z!MCd_Azd{36?Y_>yN{U1w5yrN8q`z(Vh^RnEF+;4b|2+~lfAvPT!`*{MPiDioiix8 zY*GdCwJ{S(5(HId*I%8XF=pHFz<9tAe;!D5$Z(iN#jzSql4sqX5!7Y?q4_%$lH zz8ehZuyl0K=E&gYhlfFWabnSiGty$>md|PpU1VfaC5~kskDnZX&Yu}?-h;OSav=8u z=e3Yq=mi$4A|sB-J00;1d{Sd1+!v0NtU((Nz2;PFFlC}V{@p&4wGcVhU&nI($RAS! zwXn7)?8~1J3*4+VccRSg5JS<(bBhBM&{ELMD4C_NTpvzboH!{Zr*%HP;{UqxI#g&7 zOAqPSW5Qus$8-xtTvD%h{Tw<2!XR(lU54LZG{)Cah*LZbpJkA=PMawg!O>X@&%+5XiyeIf91n2E*hl$k-Y(3iW*E}Mz-h~H~7S9I1I zR#-j`|Hk?$MqFhE4C@=n!hN*o5+M%NxRqP+aLxDdt=wS6rAu6ECK*;AB%Nyg0uyAv zO^DnbVZZo*|Ef{nsYN>cjZC$OHzR_*g%T#oF zCky9HJS;NCi=7(07tQXq?V8I&OA&kPlJ_dfSRdL2bRUt;tA3yKZRMHMXH&#W@$l%-{vQd7y@~i*^qnj^`Z{)V$6@l&!qP_y zg2oOd!Wit#)2A~w-eqw3*Mbe)U?N|q6sXw~E~&$!!@QYX4b@%;3=>)@Z#K^`8~Aki z+LYKJu~Y$;F5%_0aF9$MsbGS9Bz2~VUG@i@3Fi2q(hG^+Ia44LrfSfqtg$4{%qBDM z_9-O#3V+2~W$dW0G)R7l_R_vw(KSkC--u&%Rs^Io&*?R=`)6BN64>6>)`TxyT_(Rd zUn+aIl1mPa#Jse9B3`!T=|e!pIp$(8ZOe0ao?nS7o?oKlj zypC-fMj1DHIDrh1unUI1vp=-Fln;I9e7Jvs3wj*^_1&W|X} zZSL|S|Bb@CV*YC_-T&2!Ht3b6?)d`tHOP?rA;;t#zaXa0Sc;vGnV0BLIf8f-r{QHh z*Zp`4_ItlOR7{u(K+!p_oLDmaAkNag*l4#29F2b_A*0oz0T|#-&f*;c#<`^)(W@gm z#k9k=t%u8<+C1fNUA{Fh7~wgPrEZZ#(6aBI%6bR4RO(e1(ZocjoDek4#MTgZD>1NG zy9~yoZfWYfwe&S-(zk4o6q6o?2*~DOrJ(%5wSnEJMVOKCzHd z=Yhm+HLzoDl{P*Ybro7@sk1!Ez3`hE+&qr7Rw^2glw^M(b(NS2!F|Q!mi|l~lF94o z!QiV)Q{Z>GO5;l1y!$O)=)got;^)%@v#B!ZEVQy1(BJApHr5%Zh&W|gweD+%Ky%CO ztr45vR*y(@*Dg_Qw5v~PJtm^@Lyh*zRuT6~(K+^HWEF{;R#L$vL2!_ndBxCtUvZ(_ zauI7Qq}ERUWjr&XW9SwMbU>*@p)(cuWXCxRK&?ZoOy>2VESII53iPDP64S1pl{NsC zD;@EGPxs&}$W1;P6BB9THF%xfoLX|4?S;cu@$)9OdFst-!A7T{(LXtdNQSx!*GUSIS_lyI`da8>!y_tpJb3Zuf0O*;2y?HCfH z5QT6@nL|%l3&u4;F!~XG9E%1YwF*Fgs5V&uFsx52*iag(?6O|gYCBY3R{qhxT-Etb zq(E%V=MgQnuDGEKOGsmBj9T0-nmI%zys8NSO>gfJT4bP>tI>|ol@ zDt(&SUKrg%cz>AmqtJKEMUM;f47FEOFc%Bbmh~|*#E zDd!Tl(wa)ZZIFwe^*)4>{T+zuRykc3^-=P1aI%0Mh}*x7%SP6wD{_? zisraq`Las#y-6{`y@CU3Ta$tOl|@>4qXcB;1bb)oH9kD6 zKym@d$ zv&PZSSAV1Gwwzqrc?^_1+-ZGY+3_7~a(L+`-WdcJMo>EWZN3%z4y6JyF4NR^urk`c z?osO|J#V}k_6*9*n2?j+`F{B<%?9cdTQyVNm8D}H~T}?HOCXt%r7#2hz97Gx#X%62hyaLbU z_ZepP0<`<;eABrHrJAc!_m?kmu#7j}{empH@iUIEk^jk}^EFwO)vd7NZB=&uk6JG^ zC>xad8X$h|eCAOX&MaX<$tA1~r|hW?-0{t4PkVygTc`yh39c;&efwY(-#;$W)+4Xb z$XFsdG&;@^X`aynAMxsq)J#KZXX!sI@g~YiJdHI~r z$4mj_?S29sIa4c$z)19JmJ;Uj?>Kq=0XuH#k#};I&-6zZ_&>)j>UR0XetRO!-sjF< zd_6b1A2vfi++?>cf}s{@#BvTD|a%{9si7G}T+8ZnwuA z1k8c%lgE<-7f~H`cqgF;qZ|$>R-xNPA$25N1WI3#n%gj}4Ix}vj|e=x)B^roGQpB) zO+^#nO2 zjzJ9kHI6nI5ni&V_#5> z!?<7Qd9{|xwIf4b0bRc;zb}V4>snRg6*wl$Xz`hRDN8laL5tg&+@Dv>U^IjGQ}*=XBnXWrwTy;2nX?<1rkvOs#u(#qJ=A zBy>W`N!?%@Ay=upXFI}%LS9bjw?$h)7Dry0%d}=v0YcCSXf9nnp0tBKT1eqZ-4LU` zyiXglKRX)gtT0VbX1}w0f2ce8{$WH?BQm@$`ua%YP8G@<$n13D#*(Yd5-bHfI8!on zf5q4CPdgJLl;BqIo#>CIkX)G;rh|bzGuz1N%rr+5seP${mEg$;uQ3jC$;TsR&{IX< z;}7j3LnV+xNn^$F1;QarDf6rNYj7He+VsjJk6R@0MAkcwrsq4?(~`GKy|mgkfkd1msc2>%B!HpZ~HOzj}kl|ZF(IqB=D6ZTVcKe=I7)LlAI=!XU?J*i#9VXeKeaG zwx_l@Z(w`)5Cclw`6kQKlS<;_Knj)^Dh2pL`hQo!=GPOMR0iqEtx12ORLpN(KBOm5 zontAH5X5!9WHS_=tJfbACz@Dnkuw|^7t=l&x8yb2a~q|aqE_W&0M|tI7@ilGXqE)MONI8p67OiQGqKEQWw;LGga=ZM1;{pSw1jJK_y$vhY6 ztFrV7-xf>lbeKH1U)j3R=?w*>(Yh~NNEPVmeQ8n}0x01$-o z2Jyjn+sXhgOz>AzcZ zAbJZ@f}MBS0lLKR=IE{z;Fav%tcb+`Yi*!`HTDPqSCsFr>;yt^^&SI2mhKJ8f*%ji zz%JkZGvOn{JFn;)5jf^21AvO-9nRzsg0&CPz;OEn07`CfT@gK4abFBT$Mu?8fCcscmRkK+ zbAVJZ~#_a z{|(FFX}~8d3;DW8zuY9?r#Dt>!aD>} zlYw>D7y#eDy+PLZ&XKIY&Df0hsLDDi(Yrq8O==d30RchrUw8a=Eex>Dd?)3+k=}Q> z-b85lun-V$I}86Vg#l1S@1%=$2BQD5_waAZKQfJ${3{b2SZ#w1u+jMr{dJMvI|Og= zpQ9D={XK|ggbe04z Date: Sun, 17 Sep 2023 12:59:54 +0200 Subject: [PATCH 078/103] fix: fixed removed functions Signed-off-by: moonleay --- .../moonleay/lilJudd/features/AvailabilityManager.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index 6a42046..df88ee1 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -95,7 +95,7 @@ object AvailabilityManager : IFeature { val weekday = ZonedDateTime.now().dayOfWeek // The current week day val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() * 1000 // The current week time stamp Logger.out("It is week ${weekStamp} and day ${weekday}/${TimeUtil.getDayOfMonthInt(weekday)} of the week.") - val g = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverID)) + val g = Bot.bot.kordRef.getGuild(Snowflake(tpmd.serverID)) // Get all members with the role val mce = g.requestMembers { this.requestAllMembers() @@ -139,7 +139,7 @@ object AvailabilityManager : IFeature { .getMemberOrNull(Snowflake(tid)) == null ) continue// This member does not exist anymore. - val member = Bot.bot.kordRef.getGuildOrThrow(Snowflake(tpmd.serverID)) + val member = Bot.bot.kordRef.getGuild(Snowflake(tpmd.serverID)) .getMember(Snowflake(tid)) // Get the member if (member.roleIds.contains(Snowflake(pnrd.hasTimeRoleID))) continue // This member already has the role @@ -175,13 +175,13 @@ object AvailabilityManager : IFeature { // Check if the channel and guild already exist in the db if (!alreadyExists) { // Create the roles in Discord - val hasTimeRole = Bot.bot.kordRef.getGuildOrThrow(Snowflake(gID)).createRole { + val hasTimeRole = Bot.bot.kordRef.getGuild(Snowflake(gID)).createRole { this.name = "available [${ch.data.name.value}]" this.mentionable = true } val htr = hasTimeRole.id.value.toLong() - val wantsNotifsRole = Bot.bot.kordRef.getGuildOrThrow(Snowflake(gID)).createRole { + val wantsNotifsRole = Bot.bot.kordRef.getGuild(Snowflake(gID)).createRole { this.name = "notifications [${ch.data.name.value}]" this.mentionable = true } @@ -226,9 +226,9 @@ object AvailabilityManager : IFeature { if (PlanningNotifierRolesRepository.existsInChannelFromSever(cID, gID)) { val entry = PlanningNotifierRolesRepository.getForChannelInServer(cID, gID)!! // delete all entries for this guild and channel combo - Bot.bot.kordRef.getGuildOrThrow(Snowflake(gID)) + Bot.bot.kordRef.getGuild(Snowflake(gID)) .getRoleOrNull(Snowflake(entry.hasTimeRoleID))?.delete() - Bot.bot.kordRef.getGuildOrThrow(Snowflake(gID)) + Bot.bot.kordRef.getGuild(Snowflake(gID)) .getRoleOrNull(Snowflake(entry.wantsToBeNotifiedID))?.delete() // delete all found entries From 967492685adf3ce9adfdf55dd6f952a7a1a9d358 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sun, 17 Sep 2023 13:17:14 +0200 Subject: [PATCH 079/103] chore: update README.md Signed-off-by: moonleay --- README.md | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 14b1834..acb019b 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,6 @@ A Discord Bot for Splatoon Teams -[![Latest Release](https://gitlab.com/moonleay/liljudd/-/badges/release.svg)](https://gitlab.com/moonleay/liljudd/-/releases) -[![pipeline status](https://gitlab.com/moonleay/liljudd/badges/master/pipeline.svg)](https://gitlab.com/moonleay/liljudd/-/commits/master) -[![License](https://img.shields.io/badge/license-GPL--3.0-brightgreen)](https://gitlab.com/moonleay/liljudd/-/blob/master/LICENSE) - ## Contributors [![Developer](https://img.shields.io/badge/moonleay-Developer-red)](https://gitlab.com/moonleay) @@ -33,36 +29,31 @@ A Discord Bot for Splatoon Teams - Rndm map command - Maybe a DSB / DSL API -## TODO - -- Rewrite the Database connection system (from transactions all over the place to a single package with transactions) - ## How to self-host (using the Docker container) -1. Pull the container +1. Pull the container from [Docker Hub](https://hub.docker.com/repository/docker/limiteddev/liljudd/general) 2. Map /data/ to a folder on disk 3. Run the Bot once -4. Follow step 4 - 7 of "How to self-host (using the JAR)" +4. follow step 4 and 5 from the JAR section +5. Run the Bot again +6. Profit. +7. ## How to self-host (using the JAR) -1. Download the latest release from the Package Registry ("Packages and registries" > "Package Registry") - 1. It should be called something like this: "lilJudd-X.X.X-xxxxxxxx-prod.jar" (replace "X.X.X" with the latest - version and xxxxxxxx" with the commit its based on.) - 2. If you want to run an early version, which may be (very) unsable, you can run a development version. Just use an - entry ending in "-dev.jar" +1. Download the latest release from the Releases page. 2. Place it anywhere you want. 3. Run the following command: - > java -jar lilJudd-X.X.X-xxxxxxxx-prod.jar + > java -jar lilJudd.jar 4. The bot should start and create a config file named "credentials.nils" in a folder called "data" 5. Open it and put in your credentials. 1. token: your Discord bot token 2. dbDomain: the domain and port of your postgresql database (e.g.: 192.168.178.1:5432) - 3. dbName: the name of your database + 3. dbName: the name of the database 4. dbUser: the username of the database - 5. dbPassword: the password to your user + 5. dbPassword: the password to the db user 6. Rerun the command - > java -jar lilJudd-X.X.X-xxxxxxxx-prod.jar + > java -jar lilJudd.jar 7. The bot should now be up and running. ## How to set up workspace From d789b5ee649c6d77d1c799a4d52771876fddedab Mon Sep 17 00:00:00 2001 From: moonleay Date: Sun, 17 Sep 2023 13:20:41 +0200 Subject: [PATCH 080/103] chore: update README.md Signed-off-by: moonleay --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index acb019b..cfc9bea 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ "Oh boy, here we go again" ~ me -A Discord Bot for Splatoon Teams +A Discord Bot for Splatoon Teams. + +More information can be found on the [Homepage](https://moonleay.net/projects/liljudd/). ## Contributors @@ -17,9 +19,13 @@ A Discord Bot for Splatoon Teams - Commands - version -- Show the versions of the bot and the most important dependencies - feature -- Manage bot features + - match -- Create a new match + - updateroles -- Update the roles of all users + - sendplanner -- Send the planner message - Features - Time Planner -- Make the bot send messages and reactions into a selected channel in order to make planning easier - Availability Manager -- Make the bot assign users roles every day, so it is possible to notify available people + - Match Planner -- Make a match, for which players can sign up and the bot will assign teams and roles to them ## (Maybe) upcoming features @@ -37,7 +43,6 @@ A Discord Bot for Splatoon Teams 4. follow step 4 and 5 from the JAR section 5. Run the Bot again 6. Profit. -7. ## How to self-host (using the JAR) From 55fafa29c59fed3c29b3e16581e48b3f9479a48c Mon Sep 17 00:00:00 2001 From: moonleay Date: Sun, 17 Sep 2023 13:22:34 +0200 Subject: [PATCH 081/103] chore: update names in action.yml Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index d9e4272..222014e 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -7,10 +7,10 @@ jobs: build-gradle-project: runs-on: ubuntu-latest steps: - - name: apt 1 + - name: apt update run: apt update - - name: apt 2 - run: apt upgrade -y + - name: apt upgrade + run: apt upgrade -y - name: install prerequisits run: apt install openjdk-17-jdk ca-certificates-java ssl-cert openssl ca-certificates -y - name: Checkout project sources @@ -22,4 +22,4 @@ jobs: - uses: actions/upload-artifact@v3 with: name: lilJudd.jar - path: build/libs/ \ No newline at end of file + path: build/libs/ From c7b03d49c91d8babf8fc29a40713331b008c1b46 Mon Sep 17 00:00:00 2001 From: moonleay Date: Sun, 17 Sep 2023 13:23:13 +0200 Subject: [PATCH 082/103] Update .forgejo/workflows/action.yml --- .forgejo/workflows/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 222014e..470b719 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -6,7 +6,7 @@ on: jobs: build-gradle-project: runs-on: ubuntu-latest - steps: + - steps: - name: apt update run: apt update - name: apt upgrade From f762e18b1fb0d5e9e9781f7e565d74bc1a5e0b8d Mon Sep 17 00:00:00 2001 From: moonleay Date: Sun, 17 Sep 2023 13:24:33 +0200 Subject: [PATCH 083/103] chore: update names in action.yml Signed-off-by: moonleay --- .forgejo/workflows/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/action.yml b/.forgejo/workflows/action.yml index 470b719..8418c1c 100644 --- a/.forgejo/workflows/action.yml +++ b/.forgejo/workflows/action.yml @@ -6,10 +6,10 @@ on: jobs: build-gradle-project: runs-on: ubuntu-latest - - steps: - - name: apt update + steps: + - name: apt update run: apt update - - name: apt upgrade + - name: apt upgrade run: apt upgrade -y - name: install prerequisits run: apt install openjdk-17-jdk ca-certificates-java ssl-cert openssl ca-certificates -y From 935af908f7c95b3e10d0b4b93e68e70085925fbe Mon Sep 17 00:00:00 2001 From: moonleay Date: Mon, 18 Sep 2023 16:07:55 +0200 Subject: [PATCH 084/103] chore: moved Database stuff in /database package Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/Bot.kt | 2 +- .../lilJudd/buttons/matchplanner/AcceptEditButton.kt | 2 +- .../lilJudd/buttons/matchplanner/CancelEditButton.kt | 2 +- .../lilJudd/buttons/matchplanner/DeclineEditButton.kt | 2 +- .../net/moonleay/lilJudd/data/{ => database}/DB.kt | 10 +++++----- .../data/{ => database}/entry/MatchPlanningDataData.kt | 2 +- .../{ => database}/entry/PlanningNotifierRolesData.kt | 2 +- .../{ => database}/entry/TimePlanningChannelsData.kt | 2 +- .../{ => database}/entry/TimePlanningMessagesData.kt | 2 +- .../repository/MatchPlanningDataRepository.kt | 6 +++--- .../repository/PlanningNotifierRolesRepository.kt | 6 +++--- .../repository/TimePlanningChannelsRepository.kt | 6 +++--- .../repository/TimePlanningMessagesRepository.kt | 6 +++--- .../data/{ => database}/tables/MatchPlanningData.kt | 2 +- .../{ => database}/tables/PlanningNotifierRoles.kt | 2 +- .../data/{ => database}/tables/TimePlanningChannels.kt | 2 +- .../data/{ => database}/tables/TimePlanningMessages.kt | 2 +- .../net/moonleay/lilJudd/extensions/MatchExtension.kt | 4 ++-- .../lilJudd/extensions/SendPlannerExtension.kt | 4 ++-- .../moonleay/lilJudd/features/AvailabilityManager.kt | 8 ++++---- .../net/moonleay/lilJudd/features/MatchManager.kt | 4 ++-- .../net/moonleay/lilJudd/features/TimeManager.kt | 10 +++++----- src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt | 2 +- 23 files changed, 45 insertions(+), 45 deletions(-) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/DB.kt (83%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/entry/MatchPlanningDataData.kt (95%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/entry/PlanningNotifierRolesData.kt (95%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/entry/TimePlanningChannelsData.kt (94%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/entry/TimePlanningMessagesData.kt (95%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/repository/MatchPlanningDataRepository.kt (95%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/repository/PlanningNotifierRolesRepository.kt (95%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/repository/TimePlanningChannelsRepository.kt (92%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/repository/TimePlanningMessagesRepository.kt (93%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/tables/MatchPlanningData.kt (96%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/tables/PlanningNotifierRoles.kt (95%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/tables/TimePlanningChannels.kt (94%) rename src/main/kotlin/net/moonleay/lilJudd/data/{ => database}/tables/TimePlanningMessages.kt (95%) diff --git a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt index 750eb8c..1201560 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt @@ -33,7 +33,7 @@ import kotlinx.coroutines.launch import net.moonleay.botendo.build.BuildConstants import net.moonleay.lilJudd.buttons.component.EditButtonManager import net.moonleay.lilJudd.data.CredentialManager -import net.moonleay.lilJudd.data.DB +import net.moonleay.lilJudd.data.database.DB import net.moonleay.lilJudd.extensions.* import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.features.MatchManager diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt index 115a7e5..4e04fa1 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/AcceptEditButton.kt @@ -28,7 +28,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton -import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.MessageUtil diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt index c7cebc3..348446c 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/CancelEditButton.kt @@ -28,7 +28,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton -import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.Logger diff --git a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt index d775a29..93f6b36 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/buttons/matchplanner/DeclineEditButton.kt @@ -28,7 +28,7 @@ import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.rest.builder.message.modify.embed import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.buttons.component.IEditButton -import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.util.EmbedUtil import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.MessageUtil diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/DB.kt similarity index 83% rename from src/main/kotlin/net/moonleay/lilJudd/data/DB.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/DB.kt index f02009e..7c58ea0 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/DB.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/DB.kt @@ -16,13 +16,13 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data +package net.moonleay.lilJudd.data.database -import net.moonleay.lilJudd.data.tables.MatchPlanningData -import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles -import net.moonleay.lilJudd.data.tables.TimePlanningChannels -import net.moonleay.lilJudd.data.tables.TimePlanningMessages +import net.moonleay.lilJudd.data.database.tables.MatchPlanningData +import net.moonleay.lilJudd.data.database.tables.PlanningNotifierRoles +import net.moonleay.lilJudd.data.database.tables.TimePlanningChannels +import net.moonleay.lilJudd.data.database.tables.TimePlanningMessages import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.SchemaUtils import org.jetbrains.exposed.sql.transactions.transaction diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/MatchPlanningDataData.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/entry/MatchPlanningDataData.kt index f48dc28..b19c5e7 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/MatchPlanningDataData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/MatchPlanningDataData.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.entry +package net.moonleay.lilJudd.data.database.entry data class MatchPlanningDataData( val id: Int, diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/PlanningNotifierRolesData.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/entry/PlanningNotifierRolesData.kt index 730e7fe..c58130a 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/PlanningNotifierRolesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/PlanningNotifierRolesData.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.entry +package net.moonleay.lilJudd.data.database.entry data class PlanningNotifierRolesData( val id: Int, // The id of the entry diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningChannelsData.kt similarity index 94% rename from src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningChannelsData.kt index fba9898..7edd496 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningChannelsData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningChannelsData.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.entry +package net.moonleay.lilJudd.data.database.entry data class TimePlanningChannelsData( val id: Int, diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningMessagesData.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningMessagesData.kt index fcb283b..3126e2c 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/entry/TimePlanningMessagesData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/entry/TimePlanningMessagesData.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.entry +package net.moonleay.lilJudd.data.database.entry data class TimePlanningMessagesData( val id: Int, // The id of the entry diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/repository/MatchPlanningDataRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/MatchPlanningDataRepository.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/repository/MatchPlanningDataRepository.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/repository/MatchPlanningDataRepository.kt index 385eb69..84a1e66 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/repository/MatchPlanningDataRepository.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/MatchPlanningDataRepository.kt @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.repository +package net.moonleay.lilJudd.data.database.repository -import net.moonleay.lilJudd.data.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.tables.MatchPlanningData +import net.moonleay.lilJudd.data.database.entry.MatchPlanningDataData +import net.moonleay.lilJudd.data.database.tables.MatchPlanningData import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.transactions.transaction diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/repository/PlanningNotifierRolesRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/PlanningNotifierRolesRepository.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/repository/PlanningNotifierRolesRepository.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/repository/PlanningNotifierRolesRepository.kt index 2603081..4059e70 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/repository/PlanningNotifierRolesRepository.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/PlanningNotifierRolesRepository.kt @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.repository +package net.moonleay.lilJudd.data.database.repository -import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData -import net.moonleay.lilJudd.data.tables.PlanningNotifierRoles +import net.moonleay.lilJudd.data.database.entry.PlanningNotifierRolesData +import net.moonleay.lilJudd.data.database.tables.PlanningNotifierRoles import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.transactions.transaction diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningChannelsRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningChannelsRepository.kt similarity index 92% rename from src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningChannelsRepository.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningChannelsRepository.kt index 7756802..f5fd171 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningChannelsRepository.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningChannelsRepository.kt @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.repository +package net.moonleay.lilJudd.data.database.repository -import net.moonleay.lilJudd.data.entry.TimePlanningChannelsData -import net.moonleay.lilJudd.data.tables.TimePlanningChannels +import net.moonleay.lilJudd.data.database.entry.TimePlanningChannelsData +import net.moonleay.lilJudd.data.database.tables.TimePlanningChannels import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.transactions.transaction diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningMessagesRepository.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningMessagesRepository.kt similarity index 93% rename from src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningMessagesRepository.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningMessagesRepository.kt index 5e2f273..780a939 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/repository/TimePlanningMessagesRepository.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/repository/TimePlanningMessagesRepository.kt @@ -16,10 +16,10 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.repository +package net.moonleay.lilJudd.data.database.repository -import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData -import net.moonleay.lilJudd.data.tables.TimePlanningMessages +import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData +import net.moonleay.lilJudd.data.database.tables.TimePlanningMessages import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.select diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/tables/MatchPlanningData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/MatchPlanningData.kt similarity index 96% rename from src/main/kotlin/net/moonleay/lilJudd/data/tables/MatchPlanningData.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/tables/MatchPlanningData.kt index e2e8afa..391b3e8 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/tables/MatchPlanningData.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/MatchPlanningData.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.tables +package net.moonleay.lilJudd.data.database.tables import org.jetbrains.exposed.sql.Table diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/tables/PlanningNotifierRoles.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/PlanningNotifierRoles.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/tables/PlanningNotifierRoles.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/tables/PlanningNotifierRoles.kt index e2fc9e0..66fe906 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/tables/PlanningNotifierRoles.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/PlanningNotifierRoles.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.tables +package net.moonleay.lilJudd.data.database.tables import org.jetbrains.exposed.sql.Table diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningChannels.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningChannels.kt similarity index 94% rename from src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningChannels.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningChannels.kt index a521838..d3b31e3 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningChannels.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningChannels.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.tables +package net.moonleay.lilJudd.data.database.tables import org.jetbrains.exposed.sql.Table diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningMessages.kt b/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningMessages.kt similarity index 95% rename from src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningMessages.kt rename to src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningMessages.kt index 8f8a01b..dd48838 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/tables/TimePlanningMessages.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/database/tables/TimePlanningMessages.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.lilJudd.data.tables +package net.moonleay.lilJudd.data.database.tables import org.jetbrains.exposed.sql.Table diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt index 17592e6..9f2674d 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt @@ -28,8 +28,8 @@ import com.kotlindiscord.kord.extensions.types.respond import dev.kord.core.behavior.channel.createMessage import dev.kord.core.behavior.createRole import dev.kord.rest.builder.message.create.actionRow -import net.moonleay.lilJudd.data.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.database.entry.MatchPlanningDataData +import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.extensions.component.MatchTypes import net.moonleay.lilJudd.jobs.MatchJob import net.moonleay.lilJudd.jobs.component.JobManager diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt index ee85372..7b85b1d 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt @@ -26,8 +26,8 @@ import dev.kord.common.entity.Permission import dev.kord.core.behavior.channel.createMessage import dev.kord.rest.builder.message.create.actionRow import kotlinx.coroutines.delay -import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData -import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository +import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData +import net.moonleay.lilJudd.data.database.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.util.* import java.time.ZoneId import java.time.ZonedDateTime diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index df88ee1..148c251 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -30,10 +30,10 @@ import dev.kord.core.entity.channel.MessageChannel import dev.kord.gateway.PrivilegedIntent import dev.kord.rest.builder.message.EmbedBuilder import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.entry.PlanningNotifierRolesData -import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData -import net.moonleay.lilJudd.data.repository.PlanningNotifierRolesRepository -import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository +import net.moonleay.lilJudd.data.database.entry.PlanningNotifierRolesData +import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData +import net.moonleay.lilJudd.data.database.repository.PlanningNotifierRolesRepository +import net.moonleay.lilJudd.data.database.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.extensions.FeatureManageExtension import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.IFeature diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt index fc89dc9..129fdc0 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/MatchManager.kt @@ -20,8 +20,8 @@ package net.moonleay.lilJudd.features import dev.kord.common.entity.Snowflake import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.entry.MatchPlanningDataData -import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.database.entry.MatchPlanningDataData +import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.jobs.MatchJob import net.moonleay.lilJudd.jobs.component.JobManager import net.moonleay.lilJudd.util.Logger diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt index d986440..ec073ac 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/TimeManager.kt @@ -29,11 +29,11 @@ import dev.kord.rest.builder.message.EmbedBuilder import dev.kord.rest.builder.message.create.actionRow import kotlinx.coroutines.delay import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.entry.TimePlanningChannelsData -import net.moonleay.lilJudd.data.entry.TimePlanningMessagesData -import net.moonleay.lilJudd.data.repository.PlanningNotifierRolesRepository -import net.moonleay.lilJudd.data.repository.TimePlanningChannelsRepository -import net.moonleay.lilJudd.data.repository.TimePlanningMessagesRepository +import net.moonleay.lilJudd.data.database.entry.TimePlanningChannelsData +import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData +import net.moonleay.lilJudd.data.database.repository.PlanningNotifierRolesRepository +import net.moonleay.lilJudd.data.database.repository.TimePlanningChannelsRepository +import net.moonleay.lilJudd.data.database.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.extensions.FeatureManageExtension import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.IFeature diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt index 8360f62..6f13dfa 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/MatchJob.kt @@ -22,7 +22,7 @@ import dev.inmo.krontab.KronScheduler import dev.kord.common.entity.Snowflake import kotlinx.coroutines.Job import net.moonleay.lilJudd.Bot -import net.moonleay.lilJudd.data.repository.MatchPlanningDataRepository +import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.jobs.component.CronjobType import net.moonleay.lilJudd.jobs.component.ICronjob import net.moonleay.lilJudd.jobs.component.JobManager From 9a134c691f8d423faf1e44b4eea61cfb42b12b36 Mon Sep 17 00:00:00 2001 From: moonleay Date: Tue, 26 Sep 2023 07:43:37 +0200 Subject: [PATCH 085/103] chore: bump version Signed-off-by: moonleay --- build.gradle.kts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a90bf54..34a37f1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,7 @@ val ownerID = 372703841151614976L group = "net.moonleay.liljudd" version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } - ?: "2.5.6" + ?: "2.6.0" val kordver = "1.5.9-SNAPSHOT" val coroutinesver = "1.7.3" @@ -103,8 +103,8 @@ dependencies { //Korntab shadow("dev.inmo:krontab:$krontabver") - "shadow"("io.ktor:ktor-client-core-jvm:2.3.4") - "shadow"("io.ktor:ktor-client-cio-jvm:2.3.4") + shadow("io.ktor:ktor-client-core-jvm:2.3.4") + shadow("io.ktor:ktor-client-cio-jvm:2.3.4") } From 4a0792af087dfd93d46b3d0bd9606862aba12d55 Mon Sep 17 00:00:00 2001 From: moonleay Date: Tue, 26 Sep 2023 07:43:56 +0200 Subject: [PATCH 086/103] chore: upgrade crontab Signed-off-by: moonleay --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 34a37f1..bb2560b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,7 +39,7 @@ val coroutinesver = "1.7.3" val ktor_version = "2.3.4" val exposedver = "0.43.0" val postgresver = "42.6.0" -val krontabver = "2.2.0" +val krontabver = "2.2.1" val mavenArtifact = "lilJudd" project.base.archivesName.set(mavenArtifact) From cd37bd1242074411a79e287f5053d9822f823c4b Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 10:29:27 +0200 Subject: [PATCH 087/103] fix: fixed issues with timestamps Signed-off-by: moonleay --- .../lilJudd/extensions/MatchExtension.kt | 2 +- .../extensions/SendPlannerExtension.kt | 2 +- .../lilJudd/features/AvailabilityManager.kt | 23 +++++++++++-------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt index 9f2674d..ff47b9b 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt @@ -108,7 +108,7 @@ class MatchExtension : Extension() { role.id.value.toLong(), opponent, msg.id.value.toLong(), - (zdt.toEpochSecond() * 1000), + (zdt.toEpochSecond()), jobString ) ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt index 7b85b1d..781de2c 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt @@ -105,7 +105,7 @@ class SendPlannerExtension : Extension() { -1, c.data.guildId.value?.value!!.toLong(), c.id.value.toLong(), - (TimeUtil.getWeekStamp().toEpochSecond() * 1000), + (TimeUtil.getWeekStamp().toEpochSecond()), msgStr ) ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt index 148c251..cc49d1c 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/AvailabilityManager.kt @@ -47,18 +47,21 @@ object AvailabilityManager : IFeature { Logger.out("Starting to update roles...") // ChannelID, Data - val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond() * 1000) + val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond()) .associateBy { it.channelID } val targetedRoles = PlanningNotifierRolesRepository.getAll().associateBy { it.channelID } + if (targetedRoles.isEmpty()) { + Logger.out("No saved roles. Canceling.") + return + } for (id in messages.keys) { val snf = Snowflake(id) // snf = Snowflake val data = messages[id]!! // this is the data of the table - if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) - continue // This channel does not exist anymore. - if (targetedRoles.isEmpty()) { - Logger.out("No saved roles. Canceling.") - return + if (Bot.bot.kordRef.getChannel(Snowflake(data.channelID)) == null) { + // This channel does not exist anymore. + Logger.out("Warning: Channel ${data.channelID} does not exist anymore. Skipping.") + continue } val roleData = targetedRoles[data.channelID] // Get the role data if (roleData == null) { @@ -71,15 +74,17 @@ object AvailabilityManager : IFeature { } suspend fun updateInChannel(snf: Snowflake) { + val stamp = TimeUtil.getWeekStamp().toEpochSecond() + Logger.out("Weekstamp: $stamp") val messageData = TimePlanningMessagesRepository.getWeekInChannel( - TimeUtil.getWeekStamp().toEpochSecond() * 1000, + stamp, snf.value.toLong() ) - val roleData = PlanningNotifierRolesRepository.getForChannel(snf.value.toLong()) if (messageData == null) { Logger.out("Could not find data for channel ${snf.value}") return } + val roleData = PlanningNotifierRolesRepository.getForChannel(snf.value.toLong()) if (roleData == null) { Logger.out("Role for channel ${messageData.channelID} does not exist") return // this took way to long to find out that this was the issue @@ -93,7 +98,7 @@ object AvailabilityManager : IFeature { return // This channel does not exist anymore. val c = Bot.bot.kordRef.getChannelOf(snf)!! // Get the channel as MessageChannel val weekday = ZonedDateTime.now().dayOfWeek // The current week day - val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() * 1000 // The current week time stamp + val weekStamp = TimeUtil.getWeekStamp().toEpochSecond() // The current week time stamp Logger.out("It is week ${weekStamp} and day ${weekday}/${TimeUtil.getDayOfMonthInt(weekday)} of the week.") val g = Bot.bot.kordRef.getGuild(Snowflake(tpmd.serverID)) // Get all members with the role From 93223fa0ab51420e9934d2605705dcb138a4fdad Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 11:38:14 +0200 Subject: [PATCH 088/103] feat: added Splatoon3.ink API Signed-off-by: moonleay --- .../moonleay/lilJudd/data/api/Splatoon3Api.kt | 117 ++++ .../lilJudd/data/api/Splatoon3ApiCache.kt | 535 ++++++++++++++++++ .../data/api/entry/coop/CoopGearData.kt | 28 + .../api/entry/schedule/ChallengeModeData.kt | 34 ++ .../data/api/entry/schedule/MapData.kt | 27 + .../data/api/entry/schedule/ModeData.kt | 30 + .../data/api/entry/schedule/ShiftData.kt | 34 ++ .../data/api/entry/schedule/TimePeriodData.kt | 24 + .../data/api/entry/schedule/WeaponData.kt | 26 + .../api/entry/splatfest/SplatfestColor.kt | 26 + .../data/api/entry/splatfest/SplatfestData.kt | 33 ++ .../api/entry/splatfest/SplatfestTeamData.kt | 25 + .../entry/splatfest/SplatfestTeamResults.kt | 33 ++ .../data/api/entry/splatnet/BrandData.kt | 28 + .../api/entry/splatnet/GearAbilityData.kt | 27 + .../api/entry/splatnet/SplatnetItemData.kt | 32 ++ .../lilJudd/data/api/type/ApiDataType.kt | 27 + .../lilJudd/data/api/type/ApiRequestType.kt | 26 + 18 files changed, 1112 insertions(+) create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3Api.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3ApiCache.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/coop/CoopGearData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ChallengeModeData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/MapData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ModeData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ShiftData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/TimePeriodData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/WeaponData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestColor.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamResults.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/BrandData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/GearAbilityData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/SplatnetItemData.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiDataType.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiRequestType.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3Api.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3Api.kt new file mode 100644 index 0000000..b0192e5 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3Api.kt @@ -0,0 +1,117 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api + +import net.moonleay.lilJudd.data.api.entry.schedule.ModeData +import net.moonleay.lilJudd.util.TimeUtil + +object Splatoon3Api { + private fun getRegularMode(timestamp: Long): ModeData { + Splatoon3ApiCache.cachedRegularModeData.map { modeData -> + val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") + val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") + if (timestamp in startTime..endTime) { + return modeData + } + } + throw Exception("No current mode found") + } + + private fun getOpenMode(timestamp: Long): ModeData { + Splatoon3ApiCache.cachedCompetitiveOpenModeData.map { modeData -> + val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") + val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") + if (timestamp in startTime..endTime) { + return modeData + } + } + throw Exception("No current mode found") + } + + private fun getXMode(timestamp: Long): ModeData { + Splatoon3ApiCache.cachedXModeData.map { modeData -> + val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") + val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") + if (timestamp in startTime..endTime) { + return modeData + } + } + throw Exception("No current mode found") + } + + private fun getSeriesMode(timestamp: Long): ModeData { + Splatoon3ApiCache.cachedCompetitiveSeriesModeData.map { modeData -> + val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") + val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") + if (timestamp in startTime..endTime) { + return modeData + } + } + throw Exception("No current mode found") + } + + fun getRegularMapsFormatted(timestamp: Long): String { + val modeData = getRegularMode(timestamp) + val map1 = modeData.map1!!.name.split(" ")[0] + val map2 = modeData.map2!!.name.split(" ")[0] + return "R: $map1 & $map2" + } + + fun getOpenModeFormatted(timestamp: Long): String { + val modeData = getOpenMode(timestamp) + val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") + val diffStamp = TimeUtil.getTimeDifferenceFormatted(System.currentTimeMillis(), endTime) + return "O: ${modeData.ruleSetName} $diffStamp left" + } + + fun getOpenMapFormatted(timestamp: Long): String { + val modeData = getOpenMode(timestamp) + val map1 = modeData.map1!!.name.split(" ")[0] + val map2 = modeData.map2!!.name.split(" ")[0] + return "O: $map1 & $map2" + } + + fun getSeriesModeFormatted(timestamp: Long): String { + val modeData = getSeriesMode(timestamp) + val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") + val diffStamp = TimeUtil.getTimeDifferenceFormatted(System.currentTimeMillis(), endTime) + return "S: ${modeData.ruleSetName} $diffStamp left" + } + + fun getSeriesMapsFormatted(timestamp: Long): String { + val modeData = getSeriesMode(timestamp) + val map1 = modeData.map1!!.name.split(" ")[0] + val map2 = modeData.map2!!.name.split(" ")[0] + return "S: $map1 & $map2" + } + + fun getXModeFormatted(timestamp: Long): String { + val modeData = getXMode(timestamp) + val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") + val diffStamp = TimeUtil.getTimeDifferenceFormatted(System.currentTimeMillis(), endTime) + return "X: ${modeData.ruleSetName} $diffStamp left" + } + + fun getXMapFormatted(timestamp: Long): String { + val modeData = getXMode(timestamp) + val map1 = modeData.map1!!.name.split(" ")[0] + val map2 = modeData.map2!!.name.split(" ")[0] + return "X: $map1 & $map2" + } +} diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3ApiCache.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3ApiCache.kt new file mode 100644 index 0000000..42ff01c --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3ApiCache.kt @@ -0,0 +1,535 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api + +import io.ktor.http.* +import kotlinx.serialization.json.* +import net.moonleay.botendo.build.BuildConstants +import net.moonleay.lilJudd.data.api.entry.coop.CoopGearData +import net.moonleay.lilJudd.data.api.entry.schedule.* +import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestColor +import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestData +import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestTeamData +import net.moonleay.lilJudd.data.api.entry.splatfest.SplatfestTeamResults +import net.moonleay.lilJudd.data.api.entry.splatnet.BrandData +import net.moonleay.lilJudd.data.api.entry.splatnet.GearAbilityData +import net.moonleay.lilJudd.data.api.entry.splatnet.SplatnetItemData +import net.moonleay.lilJudd.data.api.type.ApiDataType +import net.moonleay.lilJudd.data.api.type.ApiRequestType +import net.moonleay.lilJudd.util.Logger +import net.moonleay.lilJudd.util.NetUtil + +object Splatoon3ApiCache { + private val user_agent = + "lilJudd/${BuildConstants.version} (${System.getProperty("os.name")}/${System.getProperty("os.version")}) [contact@moonleay.net]" + private val base_url = "https://splatoon3.ink/data/" // Thank god there is an API + + internal var cachedSplatfestData = mutableListOf() + internal var cachedMapData = mutableMapOf() + internal var cachedRegularModeData = mutableListOf() + internal var cachedCompetitiveSeriesModeData = mutableListOf() + internal var cachedCompetitiveOpenModeData = mutableListOf() + internal var cachedXModeData = mutableListOf() + internal var cachedChallengesData = mutableListOf() + internal var cachedShiftData = mutableListOf() + internal var cachedBigRunShiftData = mutableListOf() + internal var cachedCoopRewardsData = mutableListOf() + internal var cachedSplatnetItemData = mutableListOf() + internal var cachedSplatnetLimitedItemData = mutableListOf() + internal lateinit var splatnetShopBrandData: BrandData + internal lateinit var splatnetShopNextBrandData: BrandData + fun updateData(dataType: ApiDataType, requestType: ApiRequestType) { + Logger.out("Updating data for $dataType with USER-AGENT: $user_agent") + Logger.out("Reason for update: $requestType") + when (dataType) { + ApiDataType.SCHEDULES -> { + updateScheduleCache(user_agent) + } + + ApiDataType.SPLATNETGEAR -> { + updateSplatnetGearCache(user_agent) + } + + ApiDataType.COOP -> { + updateCOOPCache(user_agent) + } + + ApiDataType.SPLATFESTS -> { + updateSplatfestCache(user_agent) + } + + ApiDataType.ALL -> { + updateScheduleCache(user_agent) + updateSplatnetGearCache(user_agent) + updateSplatfestCache(user_agent) + updateCOOPCache(user_agent) + } + } + Logger.out("Finished updating data for $dataType") + } + + private fun updateSplatnetGearCache(uag: String) { + val apiResponse = NetUtil.GETJsonData("${base_url}gear.json", uag) + if (apiResponse.startsWith("Error")) { + Logger.out("Error getting splatnet data: $apiResponse") + return + } + val json = Json.parseToJsonElement(apiResponse) + val pickupBrandData = json.jsonObject["data"]!!.jsonObject["gesotown"]!!.jsonObject["pickupBrand"]!!.jsonObject + + val brand = pickupBrandData["brand"]!!.jsonObject + splatnetShopBrandData = + BrandData( + brand["name"]!!.jsonPrimitive.content, + Url(pickupBrandData["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), + GearAbilityData( + brand["usualGearPower"]!!.jsonObject["name"]!!.jsonPrimitive.content, + brand["usualGearPower"]!!.jsonObject["desc"]!!.jsonPrimitive.content, + Url(brand["usualGearPower"]!!.jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ), + pickupBrandData["saleEndTime"]!!.jsonPrimitive.content + ) + val nextBrand = pickupBrandData["nextBrand"]!!.jsonObject + splatnetShopNextBrandData = + BrandData( + nextBrand["name"]!!.jsonPrimitive.content, + Url(pickupBrandData["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), + null, + null + ) + cachedSplatnetItemData = mutableListOf() + val items = pickupBrandData["brandGears"]!!.jsonArray + items.forEach { + val obj = it as JsonObject + val gear = it["gear"]!!.jsonObject + val primaryGearPower = gear["primaryGearPower"]!!.jsonObject + val additionalGearPowers = gear["additionalGearPowers"]!!.jsonArray + val additionalGearPowersList = mutableListOf() + additionalGearPowers.forEach { + val ob = it as JsonObject + additionalGearPowersList.add( + GearAbilityData( + ob["name"]!!.jsonPrimitive.content, + null, + Url(ob["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ) + ) + } + cachedSplatnetItemData.add( + SplatnetItemData( + obj["saleEndTime"]!!.jsonPrimitive.content, + obj["price"]!!.jsonPrimitive.int, + gear["__typename"]!!.jsonPrimitive.content, + gear["name"]!!.jsonPrimitive.content, + GearAbilityData( + primaryGearPower["name"]!!.jsonPrimitive.content, + null, + Url(primaryGearPower["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ), + additionalGearPowersList, + Url(gear["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), + splatnetShopBrandData + ) + ) + } + Logger.out("Updated gear data") + + val limitedItemData = json.jsonObject["data"]!!.jsonObject["gesotown"]!!.jsonObject["limitedGears"]!!.jsonArray + cachedSplatnetLimitedItemData = mutableListOf() + limitedItemData.forEach { + val obj = it as JsonObject + val gear = obj["gear"]!!.jsonObject + val additionalGearPowers = gear["additionalGearPowers"]!!.jsonArray + val additionalGearPowersList = mutableListOf() + additionalGearPowers.forEach { + val ob = it as JsonObject + additionalGearPowersList.add( + GearAbilityData( + ob["name"]!!.jsonPrimitive.content, + null, + Url(ob["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ) + ) + } + cachedSplatnetLimitedItemData.add( + SplatnetItemData( + obj["saleEndTime"]!!.jsonPrimitive.content, + obj["price"]!!.jsonPrimitive.int, + gear["__typename"]!!.jsonPrimitive.content, + gear["name"]!!.jsonPrimitive.content, + GearAbilityData( + gear["primaryGearPower"]!!.jsonObject["name"]!!.jsonPrimitive.content, + null, + Url(gear["primaryGearPower"]!!.jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ), + additionalGearPowersList, + Url(gear["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), + splatnetShopBrandData + ) + ) + } + } + + private fun updateCOOPCache(uag: String) { + val apiResponse = NetUtil.GETJsonData("${base_url}coop.json", uag) + if (apiResponse.startsWith("Error")) { + Logger.out("Error getting coop data: $apiResponse") + return + } + val json = Json.parseToJsonElement(apiResponse) + val data = json.jsonObject["data"]!!.jsonObject["coopResult"]!!.jsonObject["monthlyGear"]!!.jsonObject + cachedCoopRewardsData = mutableListOf() + cachedCoopRewardsData.add( + CoopGearData( + data["name"]!!.jsonPrimitive.content, + Url(data["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), + data["__typename"]!!.jsonPrimitive.content + ) + ) + Logger.out("Updated COOP data") + } + + private fun updateScheduleCache(uag: String) { + val apiResponse = NetUtil.GETJsonData("${base_url}schedules.json", uag) + if (apiResponse.startsWith("Error")) { + Logger.out("Error getting schedule data: $apiResponse") + return + } + val json = Json.decodeFromString(apiResponse) as JsonObject + val data = json["data"]!!.jsonObject + + val mapList = data["vsStages"]!!.jsonObject["nodes"]!!.jsonArray + cachedMapData = mutableMapOf() + mapList.forEach { + val obj = it as JsonObject + val imageURL = Url(obj.jsonObject["originalImage"]!!.jsonObject["url"]!!.jsonPrimitive.content) + val id = obj.jsonObject["vsStageId"]!!.jsonPrimitive.int + cachedMapData[id] = MapData( + id, + imageURL, + it.jsonObject["name"]!!.jsonPrimitive.content + ) + } + Logger.out("Updated maplist data") + + val regularMatches = data["regularSchedules"]!!.jsonObject["nodes"]!!.jsonArray + cachedRegularModeData = mutableListOf() + regularMatches.forEach { + val obj = it as JsonObject + val setting = obj["regularMatchSetting"]!!.jsonObject + cachedRegularModeData.add( + ModeData( + obj["startTime"]!!.jsonPrimitive.content, + obj["endTime"]!!.jsonPrimitive.content, + setting["__typename"]!!.jsonPrimitive.content, + cachedMapData[setting["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int], + cachedMapData[setting["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int], + setting["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content, + setting["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content, + "TURF_WAR" + ) + ) + } + Logger.out("Updated Regular match data") + + val compMatches = data["bankaraSchedules"]!!.jsonObject["nodes"]!!.jsonArray + cachedCompetitiveSeriesModeData = mutableListOf() + cachedCompetitiveOpenModeData = mutableListOf() + compMatches.forEach { + val obj = it as JsonObject + val setting = obj["bankaraMatchSettings"]!!.jsonArray + setting.forEach { + val ob = it as JsonObject + val mode = ob["bankaraMode"]!!.jsonPrimitive.content + if (mode == "CHALLENGE") { + cachedCompetitiveSeriesModeData.add( + ModeData( + obj["startTime"]!!.jsonPrimitive.content, + obj["endTime"]!!.jsonPrimitive.content, + ob["__typename"]!!.jsonPrimitive.content, + cachedMapData[ob["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int], + cachedMapData[ob["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int], + ob["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content, + ob["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content, + mode + ) + ) + } else if (mode == "OPEN") { + cachedCompetitiveOpenModeData.add( + ModeData( + obj["startTime"]!!.jsonPrimitive.content, + obj["endTime"]!!.jsonPrimitive.content, + ob["__typename"]!!.jsonPrimitive.content, + cachedMapData[ob["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int], + cachedMapData[ob["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int], + ob["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content, + ob["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content, + mode + ) + ) + } + } + } + Logger.out("Updated Competitive match data") + + val xMatches = data["xSchedules"]!!.jsonObject["nodes"]!!.jsonArray + cachedXModeData = mutableListOf() + xMatches.forEach { + val obj = it as JsonObject + val setting = obj["xMatchSetting"]!!.jsonObject + cachedXModeData.add( + ModeData( + obj["startTime"]!!.jsonPrimitive.content, + obj["endTime"]!!.jsonPrimitive.content, + setting["__typename"]!!.jsonPrimitive.content, + cachedMapData[setting["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int], + cachedMapData[setting["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int], + setting["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content, + setting["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content, + "X" + ) + ) + } + Logger.out("Updated X match data") + + val challengeData = data["eventSchedules"]!!.jsonObject["nodes"]!!.jsonArray + cachedChallengesData = mutableListOf() + challengeData.forEach { + val obj = it as JsonObject + val tpd = obj["timePeriods"]!!.jsonArray + val setting = obj["leagueMatchSetting"]!!.jsonObject + val event = setting["leagueMatchEvent"]!!.jsonObject + cachedChallengesData.add( + ChallengeModeData( + event["leagueMatchEventId"]!!.jsonPrimitive.content, + event["name"]!!.jsonPrimitive.content, + event["desc"]!!.jsonPrimitive.content, + event["regulation"]!!.jsonPrimitive.content, + cachedMapData[setting["vsStages"]!!.jsonArray[0].jsonObject["vsStageId"]!!.jsonPrimitive.int], + cachedMapData[setting["vsStages"]!!.jsonArray[1].jsonObject["vsStageId"]!!.jsonPrimitive.int], + setting["__typename"]!!.jsonPrimitive.content, + setting["vsRule"]!!.jsonObject["rule"]!!.jsonPrimitive.content, + setting["vsRule"]!!.jsonObject["name"]!!.jsonPrimitive.content, + TimePeriodData( + tpd[0].jsonObject["startTime"]!!.jsonPrimitive.content, + tpd[0].jsonObject["endTime"]!!.jsonPrimitive.content + ), + TimePeriodData( + tpd[1].jsonObject["startTime"]!!.jsonPrimitive.content, + tpd[1].jsonObject["endTime"]!!.jsonPrimitive.content + ), + TimePeriodData( + tpd[2].jsonObject["startTime"]!!.jsonPrimitive.content, + tpd[2].jsonObject["endTime"]!!.jsonPrimitive.content + ) + ) + ) + } + Logger.out("Updated Challenge data") + + val shiftData = data["coopGroupingSchedule"]!!.jsonObject["regularSchedules"]!!.jsonObject["nodes"]!!.jsonArray + cachedShiftData = mutableListOf() + shiftData.forEach { + val obj = it as JsonObject + val setting = obj["setting"]!!.jsonObject + val stage = setting["coopStage"]!!.jsonObject + val weapons = setting["weapons"]!!.jsonArray + cachedShiftData.add( + ShiftData( + obj["startTime"]!!.jsonPrimitive.content, + obj["endTime"]!!.jsonPrimitive.content, + obj["__splatoon3ink_king_salmonid_guess"]!!.jsonPrimitive.content, + setting["__typename"]!!.jsonPrimitive.content, + stage["name"]!!.jsonPrimitive.content, + Url(stage["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), + WeaponData( + weapons[0].jsonObject["name"]!!.jsonPrimitive.content, + Url(weapons[0].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ), + WeaponData( + weapons[1].jsonObject["name"]!!.jsonPrimitive.content, + Url(weapons[1].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ), + WeaponData( + weapons[2].jsonObject["name"]!!.jsonPrimitive.content, + Url(weapons[2].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ), + WeaponData( + weapons[3].jsonObject["name"]!!.jsonPrimitive.content, + Url(weapons[3].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ) + ) + ) + } + + val bigRunData = data["coopGroupingSchedule"]!!.jsonObject["bigRunSchedules"]!!.jsonObject["nodes"]!!.jsonArray + cachedBigRunShiftData = mutableListOf() + bigRunData.forEach { + val obj = it as JsonObject + val setting = obj["setting"]!!.jsonObject + val stage = setting["coopStage"]!!.jsonObject + val weapons = setting["weapons"]!!.jsonArray + cachedBigRunShiftData.add( + ShiftData( + obj["startTime"]!!.jsonPrimitive.content, + obj["endTime"]!!.jsonPrimitive.content, + obj["__splatoon3ink_king_salmonid_guess"]!!.jsonPrimitive.content, + setting["__typename"]!!.jsonPrimitive.content, + stage["name"]!!.jsonPrimitive.content, + Url(stage["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), + WeaponData( + weapons[0].jsonObject["name"]!!.jsonPrimitive.content, + Url(weapons[0].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ), + WeaponData( + weapons[1].jsonObject["name"]!!.jsonPrimitive.content, + Url(weapons[1].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ), + WeaponData( + weapons[2].jsonObject["name"]!!.jsonPrimitive.content, + Url(weapons[2].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ), + WeaponData( + weapons[3].jsonObject["name"]!!.jsonPrimitive.content, + Url(weapons[3].jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content) + ) + ) + ) + } + Logger.out("Updated big run data") + + Logger.out("Updated all Schedules") + } + + private fun updateSplatfestCache(uag: String) { + val apiResponse = NetUtil.GETJsonData("${base_url}festivals.json", uag) + if (apiResponse.startsWith("Error")) { + Logger.out("Error getting splatfest data: $apiResponse") + return + } + val json = Json.decodeFromString(apiResponse) as JsonObject + val festivals = json["US"]!!.jsonObject["data"]!!.jsonObject["festRecords"]!!.jsonObject["nodes"]!!.jsonArray + cachedSplatfestData = mutableListOf() + festivals.forEach { + val fest = it as JsonObject + val teams = fest.jsonObject["teams"]!!.jsonArray + val team1 = teams[0].jsonObject + val team1Color = team1["color"]!!.jsonObject + var team1Result: JsonObject? = null + if (team1["result"] !is JsonNull) { + team1Result = team1["result"]!!.jsonObject + } + val team2 = teams[1].jsonObject + val team2Color = team2["color"]!!.jsonObject + var team2Result: JsonObject? = null + if (team2["result"] !is JsonNull) { + team2Result = team2["result"]!!.jsonObject + } + val team3 = teams[2].jsonObject + val team3Color = team3["color"]!!.jsonObject + var team3Result: JsonObject? = null + if (team3["result"] !is JsonNull) { + team3Result = team3["result"]!!.jsonObject + } + cachedSplatfestData.add( + SplatfestData( + fest.jsonObject["id"]!!.jsonPrimitive.content, + fest.jsonObject["state"]!!.jsonPrimitive.content, + fest.jsonObject["startTime"]!!.jsonPrimitive.content, + fest.jsonObject["endTime"]!!.jsonPrimitive.content, + fest.jsonObject["title"]!!.jsonPrimitive.content, + Url(fest.jsonObject["image"]!!.jsonObject["url"]!!.jsonPrimitive.content), + SplatfestTeamData( + team1["teamName"]!!.jsonPrimitive.content, + SplatfestColor( + team1Color["a"]!!.jsonPrimitive.int, + team1Color["b"]!!.jsonPrimitive.double, + team1Color["g"]!!.jsonPrimitive.double, + team1Color["r"]!!.jsonPrimitive.double + ), + if (team1Result.isNullOrEmpty() || team1Result["tricolorContributionRatio"]!!.jsonPrimitive.doubleOrNull == null) + null + else SplatfestTeamResults( + team1Result["isWinner"]!!.jsonPrimitive.boolean, + team1Result["horagaiRatio"]!!.jsonPrimitive.double, + team1Result["isHoragaiRatioTop"]!!.jsonPrimitive.boolean, + team1Result["voteRatio"]!!.jsonPrimitive.double, + team1Result["isVoteRatioTop"]!!.jsonPrimitive.boolean, + team1Result["regularContributionRatio"]!!.jsonPrimitive.double, + team1Result["isRegularContributionRatioTop"]!!.jsonPrimitive.boolean, + team1Result["challengeContributionRatio"]!!.jsonPrimitive.double, + team1Result["isChallengeContributionRatioTop"]!!.jsonPrimitive.boolean, + team1Result["tricolorContributionRatio"]!!.jsonPrimitive.double, + team1Result["isTricolorContributionRatioTop"]!!.jsonPrimitive.boolean, + ) + ), + SplatfestTeamData( + team2["teamName"]!!.jsonPrimitive.content, + SplatfestColor( + team2Color["a"]!!.jsonPrimitive.int, + team2Color["b"]!!.jsonPrimitive.double, + team2Color["g"]!!.jsonPrimitive.double, + team2Color["r"]!!.jsonPrimitive.double + ), + if (team2Result.isNullOrEmpty() || team2Result["tricolorContributionRatio"]!!.jsonPrimitive.doubleOrNull == null) + null + else SplatfestTeamResults( + team2Result["isWinner"]!!.jsonPrimitive.boolean, + team2Result["horagaiRatio"]!!.jsonPrimitive.double, + team2Result["isHoragaiRatioTop"]!!.jsonPrimitive.boolean, + team2Result["voteRatio"]!!.jsonPrimitive.double, + team2Result["isVoteRatioTop"]!!.jsonPrimitive.boolean, + team2Result["regularContributionRatio"]!!.jsonPrimitive.double, + team2Result["isRegularContributionRatioTop"]!!.jsonPrimitive.boolean, + team2Result["challengeContributionRatio"]!!.jsonPrimitive.double, + team2Result["isChallengeContributionRatioTop"]!!.jsonPrimitive.boolean, + team2Result["tricolorContributionRatio"]!!.jsonPrimitive.double, + team2Result["isTricolorContributionRatioTop"]!!.jsonPrimitive.boolean, + ) + ), + SplatfestTeamData( + team3["teamName"]!!.jsonPrimitive.content, + SplatfestColor( + team3Color["a"]!!.jsonPrimitive.int, + team3Color["b"]!!.jsonPrimitive.double, + team3Color["g"]!!.jsonPrimitive.double, + team3Color["r"]!!.jsonPrimitive.double + ), + if (team3Result.isNullOrEmpty() || team3Result["tricolorContributionRatio"]!!.jsonPrimitive.doubleOrNull == null) + null + else SplatfestTeamResults( + team3Result["isWinner"]!!.jsonPrimitive.boolean, + team3Result["horagaiRatio"]!!.jsonPrimitive.double, + team3Result["isHoragaiRatioTop"]!!.jsonPrimitive.boolean, + team3Result["voteRatio"]!!.jsonPrimitive.double, + team3Result["isVoteRatioTop"]!!.jsonPrimitive.boolean, + team3Result["regularContributionRatio"]!!.jsonPrimitive.double, + team3Result["isRegularContributionRatioTop"]!!.jsonPrimitive.boolean, + team3Result["challengeContributionRatio"]!!.jsonPrimitive.double, + team3Result["isChallengeContributionRatioTop"]!!.jsonPrimitive.boolean, + team3Result["tricolorContributionRatio"]!!.jsonPrimitive.double, + team3Result["isTricolorContributionRatioTop"]!!.jsonPrimitive.boolean, + ) + ), + ) + ) + } + Logger.out("Updated Splatfest data") + } +} diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/coop/CoopGearData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/coop/CoopGearData.kt new file mode 100644 index 0000000..4f46642 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/coop/CoopGearData.kt @@ -0,0 +1,28 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.coop + +import io.ktor.http.* + +data class CoopGearData( + val name: String, + val image: Url, + val __typename: String, + + ) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ChallengeModeData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ChallengeModeData.kt new file mode 100644 index 0000000..c288fe9 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ChallengeModeData.kt @@ -0,0 +1,34 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.schedule + +data class ChallengeModeData( + val leagueMatchEventId: String, + val name: String, + val description: String, + val regulation: String, + val map1: MapData?, + val map2: MapData?, + val __typename: String, + val ruleSet: String, + val ruleSetName: String, + val timePeriod1: TimePeriodData, + val timePeriod2: TimePeriodData, + val timePeriod3: TimePeriodData, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/MapData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/MapData.kt new file mode 100644 index 0000000..422783c --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/MapData.kt @@ -0,0 +1,27 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.schedule + +import io.ktor.http.* + +data class MapData( + val stageID: Int, + val image: Url, + val name: String, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ModeData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ModeData.kt new file mode 100644 index 0000000..8295a1a --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ModeData.kt @@ -0,0 +1,30 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.schedule + +data class ModeData( + val startTime: String, + val endTime: String, + val matchType: String, + val map1: MapData?, + val map2: MapData?, + val ruleSetName: String, + val ruleSet: String, + val mode: String, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ShiftData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ShiftData.kt new file mode 100644 index 0000000..a4d28ae --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/ShiftData.kt @@ -0,0 +1,34 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.schedule + +import io.ktor.http.* + +data class ShiftData( + val startTime: String, + val endTime: String, + val __splatoon3ink_king_salmonid_guess: String, + val __typename: String, + val stageName: String, + val image: Url, + val weapon1: WeaponData, + val weapon2: WeaponData, + val weapon3: WeaponData, + val weapon4: WeaponData, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/TimePeriodData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/TimePeriodData.kt new file mode 100644 index 0000000..53edb96 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/TimePeriodData.kt @@ -0,0 +1,24 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.schedule + +data class TimePeriodData( + val startTime: String, + val endTime: String, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/WeaponData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/WeaponData.kt new file mode 100644 index 0000000..997a24b --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/schedule/WeaponData.kt @@ -0,0 +1,26 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.schedule + +import io.ktor.http.* + +data class WeaponData( + val name: String, + val image: Url, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestColor.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestColor.kt new file mode 100644 index 0000000..391ccb3 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestColor.kt @@ -0,0 +1,26 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.splatfest + +data class SplatfestColor( + val a: Int, + val b: Double, + val g: Double, + val r: Double, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestData.kt new file mode 100644 index 0000000..f52b9b4 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestData.kt @@ -0,0 +1,33 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.splatfest + +import io.ktor.http.* + +data class SplatfestData( + val id: String, + val state: String, + val startTime: String, + val endTime: String, + val title: String, + val image: Url, + val team1: SplatfestTeamData, + val team2: SplatfestTeamData, + val team3: SplatfestTeamData, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamData.kt new file mode 100644 index 0000000..9ea2e72 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamData.kt @@ -0,0 +1,25 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.splatfest + +data class SplatfestTeamData( + val teamName: String, + val color: SplatfestColor, + val results: SplatfestTeamResults?, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamResults.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamResults.kt new file mode 100644 index 0000000..4888adc --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatfest/SplatfestTeamResults.kt @@ -0,0 +1,33 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.splatfest + +data class SplatfestTeamResults( + val isWinner: Boolean, + val horagaiRatio: Double, + val horagaiRatioTop: Boolean, + val voteRatio: Double, + val voteRatioTop: Boolean, + val regularRatio: Double, + val regularRatioTop: Boolean, + val challengeRatio: Double, + val challengeRatioTop: Boolean, + val tricolorRatio: Double, + val tricolorRatioTop: Boolean, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/BrandData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/BrandData.kt new file mode 100644 index 0000000..6781172 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/BrandData.kt @@ -0,0 +1,28 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.splatnet + +import io.ktor.http.* + +data class BrandData( + val name: String, + val image: Url, + val usualGearPower: GearAbilityData?, + val saleEndTime: String?, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/GearAbilityData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/GearAbilityData.kt new file mode 100644 index 0000000..713d946 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/GearAbilityData.kt @@ -0,0 +1,27 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.splatnet + +import io.ktor.http.* + +data class GearAbilityData( + val name: String, + val description: String?, + val image: Url, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/SplatnetItemData.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/SplatnetItemData.kt new file mode 100644 index 0000000..43df20b --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/entry/splatnet/SplatnetItemData.kt @@ -0,0 +1,32 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.entry.splatnet + +import io.ktor.http.* + +data class SplatnetItemData( + val saleEndTime: String, + val price: Int, + val typeName: String, + val name: String, + val primaryGearPower: GearAbilityData, + val additionalGearPowers: List, + val image: Url, + val brand: BrandData, +) diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiDataType.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiDataType.kt new file mode 100644 index 0000000..7123b0d --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiDataType.kt @@ -0,0 +1,27 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.type + +enum class ApiDataType { + SCHEDULES, + SPLATNETGEAR, + COOP, + SPLATFESTS, + ALL +} diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiRequestType.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiRequestType.kt new file mode 100644 index 0000000..da20371 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/type/ApiRequestType.kt @@ -0,0 +1,26 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.data.api.type + +enum class ApiRequestType(val nameToDisplay: String) { + AUTOMATIC_CACHE_UPDATE("automatic request to update the cache"), + AUTOMATIC_CACHE_CREATION_AT_STARTUP("automatic request to create cache at startup"), + MANUAL("manual request"), + DEBUG("debug request") +} From 7f173e4bc256d5815a2350d1e7b1c454c80bbc6c Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 11:38:34 +0200 Subject: [PATCH 089/103] chore: added credits for the provided data Signed-off-by: moonleay --- .../extensions/{VersionExtension.kt => InfoExtension.kt} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename src/main/kotlin/net/moonleay/lilJudd/extensions/{VersionExtension.kt => InfoExtension.kt} (89%) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/VersionExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/InfoExtension.kt similarity index 89% rename from src/main/kotlin/net/moonleay/lilJudd/extensions/VersionExtension.kt rename to src/main/kotlin/net/moonleay/lilJudd/extensions/InfoExtension.kt index 3554f72..ff5a61a 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/VersionExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/InfoExtension.kt @@ -24,11 +24,11 @@ import net.moonleay.botendo.build.BuildConstants import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.MessageUtil -class VersionExtension : Extension() { - override val name = "version" +class InfoExtension : Extension() { + override val name = "info" override suspend fun setup() { publicSlashCommand { - name = "version" + name = "info" description = "Show infos about the bot" this.action { MessageUtil.sendEmbedForPublicSlashCommand( @@ -38,7 +38,8 @@ class VersionExtension : Extension() { "Lil' Judd ***v." + BuildConstants.version + "***\n" + "Kord-Extensions ***v." + BuildConstants.kordVersion + "***\n" + "Coroutines ***v." + BuildConstants.coroutinesVersion + "***\n" + - "Krontab ***v." + BuildConstants.krontabVersion + "***" + "Krontab ***v." + BuildConstants.krontabVersion + "***\n\n" + + "Splatoon 3 api data provided by splatoon3.ink" ) } } From b08779546d2888ade912cd5082339550c82dc9ca Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 11:39:23 +0200 Subject: [PATCH 090/103] feat: added cacheUpdateJobs Signed-off-by: moonleay --- ...atoon3ApiFestivalAndCoopUpdateScheduler.kt | 50 +++++++++++++++++++ .../Splatoon3ApiScheduleUpdateScheduler.kt | 48 ++++++++++++++++++ ...Splatoon3ApiSplatnetGearUpdateScheduler.kt | 47 +++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt new file mode 100644 index 0000000..8e05cb1 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt @@ -0,0 +1,50 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.jobs + +import dev.inmo.krontab.KronScheduler +import kotlinx.coroutines.Job +import net.moonleay.lilJudd.data.api.Splatoon3ApiCache +import net.moonleay.lilJudd.data.api.type.ApiDataType +import net.moonleay.lilJudd.data.api.type.ApiRequestType +import net.moonleay.lilJudd.jobs.component.CronjobType +import net.moonleay.lilJudd.jobs.component.ICronjob +import net.moonleay.lilJudd.util.Logger + +object Splatoon3ApiFestivalAndCoopUpdateScheduler : ICronjob { + override val jobName: String + get() = "Splatoon3ApiFestivalAndCoopUpdateScheduler" + override val jobIncoming: String + get() = "0 0 0 /1 *" // once a day + override val jobType: CronjobType + get() = CronjobType.INFINITE + override val continueJob: Boolean + get() = true + override lateinit var cronjobJob: Job + override lateinit var scheduler: KronScheduler + + override suspend fun jobFunction() { + Logger.out("Running Splatoon3ApiFestivalUpdateScheduler.") + Splatoon3ApiCache.updateData(ApiDataType.SPLATFESTS, ApiRequestType.AUTOMATIC_CACHE_UPDATE) + Logger.out("Splatoon3ApiFestivalUpdateScheduler finished.") + Logger.out("Running Splatoon3ApiCoopUpdateScheduler.") + Splatoon3ApiCache.updateData(ApiDataType.COOP, ApiRequestType.AUTOMATIC_CACHE_UPDATE) + Logger.out("Splatoon3ApiCoopUpdateScheduler finished.") + } +} diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt new file mode 100644 index 0000000..70d7c58 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt @@ -0,0 +1,48 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.jobs + +import dev.inmo.krontab.KronScheduler +import kotlinx.coroutines.Job +import net.moonleay.lilJudd.data.api.Splatoon3ApiCache +import net.moonleay.lilJudd.data.api.type.ApiDataType +import net.moonleay.lilJudd.data.api.type.ApiRequestType +import net.moonleay.lilJudd.jobs.component.CronjobType +import net.moonleay.lilJudd.jobs.component.ICronjob +import net.moonleay.lilJudd.util.Logger + +object Splatoon3ApiScheduleUpdateScheduler : ICronjob { + override val jobName: String + get() = "Splatoon3ApiScheduleUpdateScheduler" + override val jobIncoming: String + get() = "0 /30 * * *" //Every 30 minutes + override val jobType: CronjobType + get() = CronjobType.INFINITE + override val continueJob: Boolean + get() = true + override lateinit var cronjobJob: Job + override lateinit var scheduler: KronScheduler + + override suspend fun jobFunction() { + Logger.out("Running Splatoon3ApiScheduleUpdateScheduler.") + Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_UPDATE) + StatusUpdater.refreshStatusList(System.currentTimeMillis()) + Logger.out("Splatoon3ApiScheduleUpdateScheduler finished.") + } +} diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt new file mode 100644 index 0000000..3db9fda --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt @@ -0,0 +1,47 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.jobs + +import dev.inmo.krontab.KronScheduler +import kotlinx.coroutines.Job +import net.moonleay.lilJudd.data.api.Splatoon3ApiCache +import net.moonleay.lilJudd.data.api.type.ApiDataType +import net.moonleay.lilJudd.data.api.type.ApiRequestType +import net.moonleay.lilJudd.jobs.component.CronjobType +import net.moonleay.lilJudd.jobs.component.ICronjob +import net.moonleay.lilJudd.util.Logger + +object Splatoon3ApiSplatnetGearUpdateScheduler : ICronjob { + override val jobName: String + get() = "Splatoon3ApiSplatnetGearUpdateScheduler" + override val jobIncoming: String + get() = "* * /6 * *" //Every 6 hours + override val jobType: CronjobType + get() = CronjobType.INFINITE + override val continueJob: Boolean + get() = true + override lateinit var cronjobJob: Job + override lateinit var scheduler: KronScheduler + + override suspend fun jobFunction() { + Logger.out("Running Splatoon3ApiSplatnetGearUpdateScheduler.") + Splatoon3ApiCache.updateData(ApiDataType.SPLATNETGEAR, ApiRequestType.AUTOMATIC_CACHE_UPDATE) + Logger.out("Splatoon3ApiSplatnetGearUpdateScheduler finished.") + } +} From cc41445d2f125435d82e5a261032388f8a1d162c Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 11:39:46 +0200 Subject: [PATCH 091/103] feat: added NetUtil for web requests Signed-off-by: moonleay --- .../net/moonleay/lilJudd/util/NetUtil.kt | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main/kotlin/net/moonleay/lilJudd/util/NetUtil.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/NetUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/NetUtil.kt new file mode 100644 index 0000000..5b43bbc --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/util/NetUtil.kt @@ -0,0 +1,45 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.util + +import java.net.URL +import javax.net.ssl.HttpsURLConnection + +object NetUtil { + fun GETJsonData(urlIN: String, userAgent: String): String { + val startTime = System.currentTimeMillis() + val url = URL(urlIN) + val connection = url.openConnection() as HttpsURLConnection + connection.requestMethod = "GET" + connection.setRequestProperty("User-Agent", userAgent) + connection.setRequestProperty("Accept", "application/json") + val responseCode = connection.responseCode + val timeDiff = System.currentTimeMillis() - startTime + Logger.out("GET took $timeDiff ms (from: $urlIN, as $userAgent)") + return if (responseCode == HttpsURLConnection.HTTP_OK) { + val inputStream = connection.inputStream + val inputStreamReader = inputStream.reader() + val inputAsString = inputStreamReader.readText() + inputStream.close() + inputAsString + } else { + "Error $responseCode" + } + } +} From e354ed91439a84e853b9e3b2e769361ef1073671 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 11:40:16 +0200 Subject: [PATCH 092/103] feat: added JSON deformatter to TimeUtil Signed-off-by: moonleay --- .../net/moonleay/lilJudd/util/TimeUtil.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt index c3c3e54..5287bc3 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/util/TimeUtil.kt @@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit object TimeUtil { - fun getTimeFormatedShortend(time2: Long): String { + fun getTimeFormatedShortend(time2: Long, showS: Boolean): String { var time = time2 val days: Long = TimeUnit.MILLISECONDS .toDays(time) @@ -52,7 +52,7 @@ object TimeUtil { if (minutes >= 1) { s += minutes.toString() + "m " } - if (seconds >= 1 && hours < 1) { + if (seconds >= 1 && hours < 1 && showS) { s += seconds.toString() + "s" } if (s.isEmpty() || s.isBlank()) { @@ -158,4 +158,17 @@ object TimeUtil { val zdt_ = zdt.minusHours(1) return "0 ${zdt_.minute} ${zdt_.hour} ${zdt_.dayOfMonth - 1} ${zdt_.month.value - 1} ${zdt_.year}"// 0o *w" } + + fun deformatJSONTime(inp: String, zone: String): Long { + // 2023-10-05T08:00:00Z + val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'") + val localDateTime = LocalDateTime.parse(inp, formatter) + val zoneId = ZoneId.of(zone) // TODO: Add the possibility to set your timezone + return ZonedDateTime.of(localDateTime, zoneId).toEpochSecond() * 1000 + } + + fun getTimeDifferenceFormatted(start: Long, end: Long): String { + val diff = end - start + return getTimeFormatedShortend(diff, false) + } } From 5b4b3c98284cf3c6b4a97852063933643736722f Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 11:40:45 +0200 Subject: [PATCH 093/103] feat: added StatusUpdater to update the status of the bot Signed-off-by: moonleay --- .../moonleay/lilJudd/jobs/StatusUpdater.kt | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt new file mode 100644 index 0000000..7f70859 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt @@ -0,0 +1,68 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.jobs + +import dev.inmo.krontab.KronScheduler +import dev.kord.common.entity.PresenceStatus +import kotlinx.coroutines.Job +import net.moonleay.lilJudd.Bot +import net.moonleay.lilJudd.data.api.Splatoon3Api +import net.moonleay.lilJudd.jobs.component.CronjobType +import net.moonleay.lilJudd.jobs.component.ICronjob +import net.moonleay.lilJudd.util.Logger + +object StatusUpdater : ICronjob { + override val jobName: String + get() = "StatusUpdater" + override val jobIncoming: String + get() = "/6 * * * *" //Every 10 seconds + override val jobType: CronjobType + get() = CronjobType.INFINITE + override val continueJob: Boolean + get() = true + override lateinit var cronjobJob: Job + override lateinit var scheduler: KronScheduler + + private var statusList = listOf() + private var index = 0 + + override suspend fun jobFunction() { + Logger.out("Updating status.") + Bot.bot.kordRef.editPresence { + this.status = PresenceStatus.DoNotDisturb + this.playing(statusList[index]) + } + ++index + if (index >= statusList.size) { + index = 0 + } + } + + fun refreshStatusList(timestamp: Long) { + statusList = listOf( + Splatoon3Api.getRegularMapsFormatted(timestamp), + Splatoon3Api.getSeriesModeFormatted(timestamp), + Splatoon3Api.getSeriesMapsFormatted(timestamp), + Splatoon3Api.getOpenModeFormatted(timestamp), + Splatoon3Api.getOpenMapFormatted(timestamp), + Splatoon3Api.getXModeFormatted(timestamp), + Splatoon3Api.getXMapFormatted(timestamp), + ) + } +} From 84f0176ba445fb557f61a55b38a461115e3c78be Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 11:41:46 +0200 Subject: [PATCH 094/103] feat: registered new jobs and features Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/Bot.kt | 26 ++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt index 1201560..dc78d89 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt @@ -33,11 +33,17 @@ import kotlinx.coroutines.launch import net.moonleay.botendo.build.BuildConstants import net.moonleay.lilJudd.buttons.component.EditButtonManager import net.moonleay.lilJudd.data.CredentialManager +import net.moonleay.lilJudd.data.api.Splatoon3ApiCache +import net.moonleay.lilJudd.data.api.type.ApiDataType +import net.moonleay.lilJudd.data.api.type.ApiRequestType import net.moonleay.lilJudd.data.database.DB import net.moonleay.lilJudd.extensions.* import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.features.MatchManager import net.moonleay.lilJudd.features.TimeManager +import net.moonleay.lilJudd.jobs.Splatoon3ApiScheduleUpdateScheduler +import net.moonleay.lilJudd.jobs.StatusUpdater +import net.moonleay.lilJudd.jobs.component.JobManager import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.MessageUtil @@ -99,7 +105,7 @@ object Bot { } extensions { - add(::VersionExtension) + add(::InfoExtension) add(::FeatureManageExtension) add(::SendPlannerExtension) add(::MatchExtension) @@ -120,7 +126,6 @@ object Bot { sharding { recommended -> Shards(recommended) } */ - // Same goes for a Database table rewrite } // Register button presses @@ -141,7 +146,6 @@ object Bot { } if (inter.componentId.startsWith("public.message.")) { val response = inter.deferPublicResponse() - val g = this.interaction.getOriginalInteractionResponse().getGuild() response.respond { this.embeds = mutableListOf( MessageUtil.getEmbed( @@ -161,6 +165,22 @@ object Bot { MatchManager.update() // Update Matches } + // Update the Splatoon 3 api data and make sure it stays up-to-date + Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_CREATION_AT_STARTUP) + JobManager.addJob(Splatoon3ApiScheduleUpdateScheduler) + /* + Other caches will be added when implemented + its not used yet in order to reduce load on the api, + which i am using. + */ + //JobManager.addJob(Splatoon3ApiFestivalAndCoopUpdateScheduler) + //JobManager.addJob(Splatoon3ApiSplatnetGearUpdateScheduler) + + // Make the bot update the status every 10 seconds + JobManager.addJob(StatusUpdater) + // Update the status messages for the bot + StatusUpdater.refreshStatusList(System.currentTimeMillis()) + //Start the bot bot.start() From b13c2e5f5f45d637505938f744f0ea83659b8a3c Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 11:52:42 +0200 Subject: [PATCH 095/103] feat: made the status refresh every time it updates Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt index 7f70859..84d4660 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt @@ -25,7 +25,6 @@ import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.data.api.Splatoon3Api import net.moonleay.lilJudd.jobs.component.CronjobType import net.moonleay.lilJudd.jobs.component.ICronjob -import net.moonleay.lilJudd.util.Logger object StatusUpdater : ICronjob { override val jobName: String @@ -43,7 +42,7 @@ object StatusUpdater : ICronjob { private var index = 0 override suspend fun jobFunction() { - Logger.out("Updating status.") + refreshStatusList(System.currentTimeMillis()) Bot.bot.kordRef.editPresence { this.status = PresenceStatus.DoNotDisturb this.playing(statusList[index]) From 85602038e9851026f1ba5895dc71661b5286694c Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 11:53:18 +0200 Subject: [PATCH 096/103] feat: removed the not needed status refreshes Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/Bot.kt | 3 --- .../lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt | 1 - 2 files changed, 4 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt index dc78d89..ab169a6 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt @@ -178,9 +178,6 @@ object Bot { // Make the bot update the status every 10 seconds JobManager.addJob(StatusUpdater) - // Update the status messages for the bot - StatusUpdater.refreshStatusList(System.currentTimeMillis()) - //Start the bot bot.start() diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt index 70d7c58..3a4c8ed 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt @@ -42,7 +42,6 @@ object Splatoon3ApiScheduleUpdateScheduler : ICronjob { override suspend fun jobFunction() { Logger.out("Running Splatoon3ApiScheduleUpdateScheduler.") Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_UPDATE) - StatusUpdater.refreshStatusList(System.currentTimeMillis()) Logger.out("Splatoon3ApiScheduleUpdateScheduler finished.") } } From 2a34d1568776a99e2ae8420f9a0f747620000cc1 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 15:09:30 +0200 Subject: [PATCH 097/103] fix: StatusUpdater now starts after the bot is online Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/Bot.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt index ab169a6..6a5bf7b 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt @@ -163,6 +163,8 @@ object Bot { bot.kordRef.on { AvailabilityManager.runThread() // Update Availabilities MatchManager.update() // Update Matches + // Make the bot update the status every 6 seconds + JobManager.addJob(StatusUpdater) } // Update the Splatoon 3 api data and make sure it stays up-to-date @@ -176,9 +178,6 @@ object Bot { //JobManager.addJob(Splatoon3ApiFestivalAndCoopUpdateScheduler) //JobManager.addJob(Splatoon3ApiSplatnetGearUpdateScheduler) - // Make the bot update the status every 10 seconds - JobManager.addJob(StatusUpdater) - //Start the bot bot.start() } From 50df374564147f2a158011d4c979117c3283f312 Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 15:09:45 +0200 Subject: [PATCH 098/103] chore: updated comment Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt index 84d4660..f022950 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt @@ -30,7 +30,7 @@ object StatusUpdater : ICronjob { override val jobName: String get() = "StatusUpdater" override val jobIncoming: String - get() = "/6 * * * *" //Every 10 seconds + get() = "/6 * * * *" //Every 6 seconds override val jobType: CronjobType get() = CronjobType.INFINITE override val continueJob: Boolean From e9babd0d7436c527928ed8a899822f62b61dbfdd Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 5 Oct 2023 15:09:58 +0200 Subject: [PATCH 099/103] chore: bump version Signed-off-by: moonleay --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index bb2560b..71eb2dd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,7 @@ val ownerID = 372703841151614976L group = "net.moonleay.liljudd" version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } - ?: "2.6.0" + ?: "2.6.2" val kordver = "1.5.9-SNAPSHOT" val coroutinesver = "1.7.3" From 95f6772581c3960c5eb78e38cb9a8f96ce3df248 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 6 Oct 2023 09:42:50 +0200 Subject: [PATCH 100/103] fix: fixed api schedulers Signed-off-by: moonleay --- .../lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt | 2 +- .../lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt | 2 +- .../lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt | 2 +- src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt index 8e05cb1..ff299fc 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiFestivalAndCoopUpdateScheduler.kt @@ -31,7 +31,7 @@ object Splatoon3ApiFestivalAndCoopUpdateScheduler : ICronjob { override val jobName: String get() = "Splatoon3ApiFestivalAndCoopUpdateScheduler" override val jobIncoming: String - get() = "0 0 0 /1 *" // once a day + get() = "0 0 0 /1 * * 0o *" // once a day override val jobType: CronjobType get() = CronjobType.INFINITE override val continueJob: Boolean diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt index 3a4c8ed..5c38b15 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiScheduleUpdateScheduler.kt @@ -31,7 +31,7 @@ object Splatoon3ApiScheduleUpdateScheduler : ICronjob { override val jobName: String get() = "Splatoon3ApiScheduleUpdateScheduler" override val jobIncoming: String - get() = "0 /30 * * *" //Every 30 minutes + get() = "0 0 /1 * * * 0o *" //Every hour override val jobType: CronjobType get() = CronjobType.INFINITE override val continueJob: Boolean diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt index 3db9fda..51048f2 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/Splatoon3ApiSplatnetGearUpdateScheduler.kt @@ -31,7 +31,7 @@ object Splatoon3ApiSplatnetGearUpdateScheduler : ICronjob { override val jobName: String get() = "Splatoon3ApiSplatnetGearUpdateScheduler" override val jobIncoming: String - get() = "* * /6 * *" //Every 6 hours + get() = "0 0 /6 * * * 0o *" //Every 6 hours override val jobType: CronjobType get() = CronjobType.INFINITE override val continueJob: Boolean diff --git a/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt b/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt index f022950..7df554b 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/jobs/StatusUpdater.kt @@ -30,7 +30,7 @@ object StatusUpdater : ICronjob { override val jobName: String get() = "StatusUpdater" override val jobIncoming: String - get() = "/6 * * * *" //Every 6 seconds + get() = "/5 * * * * * 0o *" //Every 5 seconds override val jobType: CronjobType get() = CronjobType.INFINITE override val continueJob: Boolean From 982212ddf32fd8e25d8c21463803f5dbe8c14b31 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 6 Oct 2023 09:43:21 +0200 Subject: [PATCH 101/103] fix: fixed issue with time in the match extension Signed-off-by: moonleay --- .../kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt index ff47b9b..9f2674d 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/MatchExtension.kt @@ -108,7 +108,7 @@ class MatchExtension : Extension() { role.id.value.toLong(), opponent, msg.id.value.toLong(), - (zdt.toEpochSecond()), + (zdt.toEpochSecond() * 1000), jobString ) ) From 5bf19e578b2c5cf1d52dfdd4dcf8d90d99e7dbf0 Mon Sep 17 00:00:00 2001 From: moonleay Date: Fri, 6 Oct 2023 09:43:32 +0200 Subject: [PATCH 102/103] chore: bump version Signed-off-by: moonleay --- build.gradle.kts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 71eb2dd..549c10f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,11 +32,11 @@ val ownerID = 372703841151614976L group = "net.moonleay.liljudd" version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } - ?: "2.6.2" + ?: "2.6.4" val kordver = "1.5.9-SNAPSHOT" val coroutinesver = "1.7.3" -val ktor_version = "2.3.4" +val ktorver = "2.3.5" val exposedver = "0.43.0" val postgresver = "42.6.0" val krontabver = "2.2.1" @@ -89,6 +89,8 @@ implementation.extendsFrom(shadow) dependencies { //Discord shadow("com.kotlindiscord.kord.extensions:kord-extensions:$kordver") + + //Coroutines shadow("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesver") //Logging @@ -101,10 +103,10 @@ dependencies { shadow("org.jetbrains.exposed:exposed-jdbc:$exposedver") shadow("org.postgresql:postgresql:$postgresver") - //Korntab + //Krontab shadow("dev.inmo:krontab:$krontabver") - shadow("io.ktor:ktor-client-core-jvm:2.3.4") - shadow("io.ktor:ktor-client-cio-jvm:2.3.4") + shadow("io.ktor:ktor-client-core-jvm:2.3.5") + shadow("io.ktor:ktor-client-cio-jvm:2.3.5") } @@ -116,7 +118,7 @@ val templateProps = mapOf( "ownerID" to ownerID, "kordversion" to kordver, "coroutinesversion" to coroutinesver, - "ktorversion" to ktor_version, + "ktorversion" to ktorver, "exposedversion" to exposedver, "postgresversion" to postgresver, "krontabversion" to krontabver From 3a4cb20c957032e149d984afa43edaf819919d2a Mon Sep 17 00:00:00 2001 From: moonleay Date: Thu, 19 Oct 2023 16:42:07 +0200 Subject: [PATCH 103/103] chore: progress commit Signed-off-by: moonleay --- src/main/kotlin/net/moonleay/lilJudd/Bot.kt | 1 + .../moonleay/lilJudd/data/api/Splatoon3Api.kt | 8 +- .../lilJudd/extensions/RotationExtension.kt | 80 +++++++++++++++++++ .../component/SplatoonOnlineMode.kt | 30 +++++++ .../moonleay/lilJudd/build/BuildConstants.kt | 2 +- 5 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 src/main/kotlin/net/moonleay/lilJudd/extensions/RotationExtension.kt create mode 100644 src/main/kotlin/net/moonleay/lilJudd/extensions/component/SplatoonOnlineMode.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt index 6a5bf7b..d38c329 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/Bot.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/Bot.kt @@ -110,6 +110,7 @@ object Bot { add(::SendPlannerExtension) add(::MatchExtension) add(::UpdateRolesExtension) + add(::RotationExtension) } this.presence { diff --git a/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3Api.kt b/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3Api.kt index b0192e5..968ce22 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3Api.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/data/api/Splatoon3Api.kt @@ -22,7 +22,7 @@ import net.moonleay.lilJudd.data.api.entry.schedule.ModeData import net.moonleay.lilJudd.util.TimeUtil object Splatoon3Api { - private fun getRegularMode(timestamp: Long): ModeData { + fun getRegularMode(timestamp: Long): ModeData { Splatoon3ApiCache.cachedRegularModeData.map { modeData -> val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") @@ -33,7 +33,7 @@ object Splatoon3Api { throw Exception("No current mode found") } - private fun getOpenMode(timestamp: Long): ModeData { + fun getOpenMode(timestamp: Long): ModeData { Splatoon3ApiCache.cachedCompetitiveOpenModeData.map { modeData -> val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") @@ -44,7 +44,7 @@ object Splatoon3Api { throw Exception("No current mode found") } - private fun getXMode(timestamp: Long): ModeData { + fun getXMode(timestamp: Long): ModeData { Splatoon3ApiCache.cachedXModeData.map { modeData -> val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") @@ -55,7 +55,7 @@ object Splatoon3Api { throw Exception("No current mode found") } - private fun getSeriesMode(timestamp: Long): ModeData { + fun getSeriesMode(timestamp: Long): ModeData { Splatoon3ApiCache.cachedCompetitiveSeriesModeData.map { modeData -> val startTime = TimeUtil.deformatJSONTime(modeData.startTime, "UTC") val endTime = TimeUtil.deformatJSONTime(modeData.endTime, "UTC") diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/RotationExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/RotationExtension.kt new file mode 100644 index 0000000..4185fd3 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/RotationExtension.kt @@ -0,0 +1,80 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.extensions + +import com.kotlindiscord.kord.extensions.commands.Arguments +import com.kotlindiscord.kord.extensions.commands.application.slash.converters.impl.enumChoice +import com.kotlindiscord.kord.extensions.extensions.Extension +import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand +import net.moonleay.lilJudd.extensions.component.SplatoonOnlineMode +import net.moonleay.lilJudd.util.Logger + +class RotationExtension : Extension() { + + override val name = "rotation" + override val allowApplicationCommandInDMs: Boolean + get() = false + + + override suspend fun setup() { + publicSlashCommand(::RotationArguments) { + name = "rotation" + description = "Check the current rotations" + this.action { + val mode = this.arguments.mode + when (mode) { + SplatoonOnlineMode.ALL -> { + + } + + SplatoonOnlineMode.REGULAR -> { + + } + + SplatoonOnlineMode.SERIES -> { + + } + + SplatoonOnlineMode.OPEN -> { + + } + + SplatoonOnlineMode.X -> { + + } + + SplatoonOnlineMode.SALMON_RUN -> { + + } + } + + Logger.out("Done") + } + } + } + + inner class RotationArguments : Arguments() { + + val mode by enumChoice { + this.name = "mode" + this.description = "The mode you want to check the rotation for" + this.typeName = "en_US" + } + } +} diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/component/SplatoonOnlineMode.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/component/SplatoonOnlineMode.kt new file mode 100644 index 0000000..866c91a --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/component/SplatoonOnlineMode.kt @@ -0,0 +1,30 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.extensions.component + +import com.kotlindiscord.kord.extensions.commands.application.slash.converters.ChoiceEnum + +enum class SplatoonOnlineMode(override val readableName: String) : ChoiceEnum { + ALL("All Modes"), + REGULAR("Regular Battle"), + SERIES("Ranked Battle (Series)"), + OPEN("Ranked Battle (Open)"), + X("X Battle"), + SALMON_RUN("Salmon Run"), +} diff --git a/src/main/templates/net/moonleay/lilJudd/build/BuildConstants.kt b/src/main/templates/net/moonleay/lilJudd/build/BuildConstants.kt index fdcf269..fa84c6d 100644 --- a/src/main/templates/net/moonleay/lilJudd/build/BuildConstants.kt +++ b/src/main/templates/net/moonleay/lilJudd/build/BuildConstants.kt @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package net.moonleay.botendo.build +package net.moonleay.lilJudd.build internal object BuildConstants { const val version = "${version}"