mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-24 18:04:01 +00:00
Compare commits
120 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
653671ea79 | ||
|
|
7185908682 | ||
|
|
675da8d5d8 | ||
|
|
e91becee0d | ||
|
|
18732efe75 | ||
|
|
63897fd914 | ||
|
|
9b865af43b | ||
|
|
b78275734c | ||
|
|
00a6b0d1f8 | ||
|
|
13fe6f5e51 | ||
|
|
bc0c3a18d7 | ||
|
|
8f9b7eba16 | ||
|
|
48eacb2e1c | ||
|
|
2168814814 | ||
|
|
972a2829d7 | ||
|
|
dbf5d99622 | ||
|
|
f45721ba42 | ||
|
|
9034968868 | ||
|
|
bcb9bacea5 | ||
|
|
4b922da294 | ||
|
|
6d90314492 | ||
|
|
93b02d37ed | ||
|
|
c11ddd84ab | ||
|
|
518355a68a | ||
|
|
74ebeb4844 | ||
|
|
7d872c815c | ||
|
|
4ebcbeb753 | ||
|
|
53b0c91360 | ||
|
|
59575e0b49 | ||
|
|
94a18559d3 | ||
|
|
b0c90ee8e2 | ||
|
|
c20c7321ea | ||
|
|
11914d1be5 | ||
|
|
1689fcdae9 | ||
|
|
fc887d2f36 | ||
|
|
485782ff16 | ||
|
|
6460d2c5b7 | ||
|
|
e92b7320bd | ||
|
|
4af47ce086 | ||
|
|
3f2f3a9c1b | ||
|
|
fe1f03833b | ||
|
|
f2522d5a47 | ||
|
|
61450a6a00 | ||
|
|
05ea4d7dd3 | ||
|
|
71c18f8348 | ||
|
|
6030904d21 | ||
|
|
2fd636a39e | ||
|
|
a94b9293f7 | ||
|
|
3c4edf5671 | ||
|
|
f02f1eac4c | ||
|
|
373ed4cde5 | ||
|
|
5eb9a0e674 | ||
|
|
d4f07bd719 | ||
|
|
8924b75530 | ||
|
|
25bdc98944 | ||
|
|
062581fce5 | ||
|
|
be41551529 | ||
|
|
af8206c529 | ||
|
|
8efedf6f6f | ||
|
|
80aff40054 | ||
|
|
c71f5f004d | ||
|
|
350a634f50 | ||
|
|
f5de74c1e4 | ||
|
|
6e3809bfd9 | ||
|
|
8e6339a99b | ||
|
|
befef1f61d | ||
|
|
1f0bc493d9 | ||
|
|
48fa7a99dc | ||
|
|
d12497753d | ||
|
|
20a6e29f1b | ||
|
|
d2231b0934 | ||
|
|
0464afb7db | ||
|
|
c473ca74d4 | ||
|
|
a70ac5aa94 | ||
|
|
d10faf4d3d | ||
|
|
a346e1372c | ||
|
|
9a7c769e8f | ||
|
|
980ca9380c | ||
|
|
e9d14ac417 | ||
|
|
474e632fed | ||
|
|
2e5c2c26b9 | ||
|
|
a8ca9a8055 | ||
|
|
453ccf2e27 | ||
|
|
52c805f4ea | ||
|
|
4b3038078e | ||
|
|
af5f9a8361 | ||
|
|
e84b5ecbb5 | ||
|
|
1ba8219d7b | ||
|
|
60d2c669a2 | ||
|
|
3a122a72e5 | ||
|
|
d53126e5a5 | ||
|
|
208d9a28ed | ||
|
|
6643359953 | ||
|
|
bd7149d159 | ||
|
|
c0b6a19bca | ||
|
|
58eece0814 | ||
|
|
abfd2c9591 | ||
|
|
a71a448b4b | ||
|
|
4d1ce7158f | ||
|
|
9bbb9430d9 | ||
|
|
a608fba082 | ||
|
|
f97fe42e65 | ||
|
|
f12581f322 | ||
|
|
e8f630c94c | ||
|
|
14f35caede | ||
|
|
915eb8ced9 | ||
|
|
148c10f250 | ||
|
|
74e5154e29 | ||
|
|
baad696a20 | ||
|
|
b7b5dc7b6a | ||
|
|
f27f59c0b3 | ||
|
|
ccd7ace8d9 | ||
|
|
73a73dc4f2 | ||
|
|
156725afa6 | ||
|
|
b369b56823 | ||
|
|
7482bf545d | ||
|
|
9804d165ca | ||
|
|
59ddb0b27d | ||
|
|
9aea9d2b4f | ||
|
|
b042e586a7 |
@@ -1,2 +1,2 @@
|
|||||||
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
|
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
|
||||||
VERSION=1.5.5
|
VERSION=1.5.30
|
||||||
10
.github/workflows/build.yml
vendored
10
.github/workflows/build.yml
vendored
@@ -25,8 +25,18 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
distribution: 'corretto'
|
distribution: 'corretto'
|
||||||
java-version: 17
|
java-version: 17
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '21.x'
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn -B install --file abstracto-application/pom.xml
|
run: mvn -B install --file abstracto-application/pom.xml
|
||||||
|
- name: Install node dependencies and build
|
||||||
|
working-directory: ./ui/experience-tracking
|
||||||
|
run: npm ci
|
||||||
|
- name: Build ui application
|
||||||
|
working-directory: ./ui/experience-tracking
|
||||||
|
run: npm run build
|
||||||
- uses: actions/setup-ruby@v1
|
- uses: actions/setup-ruby@v1
|
||||||
- name: Send Webhook Notification
|
- name: Send Webhook Notification
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
56
.github/workflows/release.yml
vendored
56
.github/workflows/release.yml
vendored
@@ -1,56 +0,0 @@
|
|||||||
name: Publish package to GitHub Packages and deploy documentation to GitHub pages
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [created]
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Set up Java for publishing to GitHub Packages
|
|
||||||
uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
distribution: 'corretto'
|
|
||||||
java-version: 17
|
|
||||||
- name: Load current version
|
|
||||||
id: version
|
|
||||||
run: echo "version=$(mvn --file abstracto-application/pom.xml -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_ENV
|
|
||||||
- name: Publish to GitHub Packages
|
|
||||||
run: mvn --file abstracto-application/pom.xml -B deploy -P documentation,javadoc -Dmaven.wagon.http.pool=false -DskipTests=true
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: Deploy documentation to GitHub pages
|
|
||||||
uses: JamesIves/github-pages-deploy-action@v4
|
|
||||||
with:
|
|
||||||
repository-name: Sheldan/abstracto-docs
|
|
||||||
target-folder: docs/${{ env.version }}
|
|
||||||
branch: master
|
|
||||||
ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
|
||||||
folder: abstracto-application/documentation/target/generated-docs
|
|
||||||
- name: Deploy documentation to GitHub pages latest
|
|
||||||
uses: JamesIves/github-pages-deploy-action@v4
|
|
||||||
with:
|
|
||||||
repository-name: Sheldan/abstracto-docs
|
|
||||||
target-folder: docs/current
|
|
||||||
branch: master
|
|
||||||
ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
|
||||||
folder: abstracto-application/documentation/target/generated-docs
|
|
||||||
- name: Login to Harbor
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: harbor.sheldan.dev
|
|
||||||
username: ${{ secrets.HARBOR_USERNAME }}
|
|
||||||
password: ${{ secrets.HARBOR_TOKEN }}
|
|
||||||
- name: Load env files
|
|
||||||
id: dotenv
|
|
||||||
uses: falti/dotenv-action@v1.0.4
|
|
||||||
with:
|
|
||||||
path: ./deployment/installer/.env
|
|
||||||
- name: Push container
|
|
||||||
run: docker-compose build && docker-compose push
|
|
||||||
working-directory: ./deployment/installer/
|
|
||||||
env:
|
|
||||||
REGISTRY_PREFIX: ${{ steps.dotenv.outputs.registry_prefix }}
|
|
||||||
VERSION: ${{ steps.dotenv.outputs.version }}
|
|
||||||
78
.github/workflows/release_manual.yml
vendored
Normal file
78
.github/workflows/release_manual.yml
vendored
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
name: Publishes a new version of abstracto
|
||||||
|
on: workflow_dispatch
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: write
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'corretto'
|
||||||
|
java-version: 17
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '21.x'
|
||||||
|
- name: Load current version
|
||||||
|
id: version
|
||||||
|
working-directory: ./abstracto-application
|
||||||
|
run: echo "version=$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec | cut -d- -f1)" >> $GITHUB_ENV
|
||||||
|
- name: Create a Release
|
||||||
|
uses: elgohr/Github-Release-Action@v5
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
title: Release of version ${{ env.version }}
|
||||||
|
- name: Release maven packages
|
||||||
|
uses: qcastel/github-actions-maven-release@v1.12.41
|
||||||
|
env:
|
||||||
|
JAVA_HOME: /usr/lib/jvm/java-17-openjdk/
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
maven-project-folder: "abstracto-application/"
|
||||||
|
git-release-bot-name: "release-bot"
|
||||||
|
git-release-bot-email: "release-bot@sheldan.dev"
|
||||||
|
release-branch-name: master
|
||||||
|
maven-args: "-Dmaven.javadoc.skip=true -s settings.xml -DskipTests"
|
||||||
|
access-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Install node dependencies and build
|
||||||
|
working-directory: ./ui/experience-tracking
|
||||||
|
run: npm ci
|
||||||
|
- name: Build ui application
|
||||||
|
working-directory: ./ui/experience-tracking
|
||||||
|
run: npm run build
|
||||||
|
- name: Copy built UI
|
||||||
|
run: cp -R ui/experience-tracking/build/* python/components/experience-tracking/resources/templates/experience/leaderboards/
|
||||||
|
- name: Login to Harbor
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: harbor.sheldan.dev
|
||||||
|
username: ${{ secrets.HARBOR_USERNAME }}
|
||||||
|
password: ${{ secrets.HARBOR_TOKEN }}
|
||||||
|
- name: Update .env version
|
||||||
|
run:
|
||||||
|
sed -i '2s/.*/VERSION=${{ env.version }}/' .env
|
||||||
|
- name: Load env file
|
||||||
|
id: dotenv
|
||||||
|
uses: falti/dotenv-action@v1.0.4
|
||||||
|
with:
|
||||||
|
path: .env
|
||||||
|
- name: Build and push Docker containers
|
||||||
|
run: docker-compose build && docker-compose push
|
||||||
|
env:
|
||||||
|
REGISTRY_PREFIX: ${{ steps.dotenv.outputs.registry_prefix }}
|
||||||
|
VERSION: ${{ steps.dotenv.outputs.version }}
|
||||||
|
- name: Fix file permissions
|
||||||
|
run:
|
||||||
|
sudo chmod -R ugo+rwX . # https://github.com/actions/checkout/issues/164
|
||||||
|
- name: Commit updated versions
|
||||||
|
uses: EndBug/add-and-commit@v9
|
||||||
|
with:
|
||||||
|
author_name: "release-bot"
|
||||||
|
author_email: "release-bot@sheldan.dev"
|
||||||
@@ -12,7 +12,7 @@ An example implementation of this bot can be seen [here](https://github.com/Shel
|
|||||||
|
|
||||||
|
|
||||||
## Technologies
|
## Technologies
|
||||||
* [JDA](https://github.com/DV8FromTheWorld/JDA/) The Discord API Wrapper in the version 5.0.0-beta.5
|
* [JDA](https://github.com/DV8FromTheWorld/JDA/) The Discord API Wrapper in the version 5.0.0-beta.21
|
||||||
* [Spring boot](https://github.com/spring-projects/spring-boot) is used as a framework to create standalone application in Java with Java EE methods. (including dependency injection and more)
|
* [Spring boot](https://github.com/spring-projects/spring-boot) is used as a framework to create standalone application in Java with Java EE methods. (including dependency injection and more)
|
||||||
* [Hibernate](https://github.com/hibernate/hibernate-orm) is used as a reference implementation of JPA.
|
* [Hibernate](https://github.com/hibernate/hibernate-orm) is used as a reference implementation of JPA.
|
||||||
* [Freemarker](https://github.com/apache/freemarker) is used as a templating engine. This is used to provide internationalization for user facing text and enable dynamic embed configuration.
|
* [Freemarker](https://github.com/apache/freemarker) is used as a templating engine. This is used to provide internationalization for user facing text and enable dynamic embed configuration.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>anti-raid</artifactId>
|
<artifactId>anti-raid</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="feature.xml" relativeToChangelogFile="true"/>
|
<include file="feature.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="anti_raid-feature-insertion">
|
<changeSet author="Sheldan" id="anti_raid-feature-insertion">
|
||||||
<insert tableName="feature">
|
<insert tableName="feature">
|
||||||
<column name="key" value="antiRaid"/>
|
<column name="key" value="antiRaid"/>
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="1.3.3/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.3.3/collection.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>anti-raid</artifactId>
|
<artifactId>anti-raid</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>assignable-roles</artifactId>
|
<artifactId>assignable-roles</artifactId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -41,13 +41,19 @@ public class ActivateAssignableRolePlace extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
Parameter placeName = Parameter.builder().name("name").type(String.class).templated(true).build();
|
Parameter placeName = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("name")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
List<Parameter> parameters = Arrays.asList(placeName);
|
List<Parameter> parameters = Arrays.asList(placeName);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
.name("activateAssignableRolePlace")
|
.name("activateAssignableRolePlace")
|
||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
|
|||||||
@@ -36,16 +36,40 @@ public class AddAssignableRoleCondition extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
Parameter placeName = Parameter.builder().name("name").type(String.class).templated(true).build();
|
Parameter placeName = Parameter
|
||||||
Parameter role = Parameter.builder().name("role").type(Role.class).templated(true).build();
|
.builder()
|
||||||
Parameter conditionKey = Parameter.builder().name("conditionKey").type(AssignableRoleConditionType.class).templated(true).build();
|
.name("name")
|
||||||
Parameter conditionValue = Parameter.builder().name("conditionParameter").type(String.class).templated(true).build();
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter role = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("role")
|
||||||
|
.type(Role.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter conditionKey = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("conditionKey")
|
||||||
|
.type(AssignableRoleConditionType.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter conditionValue = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("conditionParameter")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
List<Parameter> parameters = Arrays.asList(placeName, role, conditionKey, conditionValue);
|
List<Parameter> parameters = Arrays.asList(placeName, role, conditionKey, conditionValue);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
.name("addAssignableRoleCondition")
|
.name("addAssignableRoleCondition")
|
||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
|
|||||||
@@ -62,17 +62,42 @@ public class AddRoleToAssignableRolePost extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
Parameter placeName = Parameter.builder().name("name").type(String.class).templated(true).build();
|
Parameter placeName = Parameter
|
||||||
Parameter role = Parameter.builder().name("role").type(Role.class).templated(true).build();
|
.builder()
|
||||||
Parameter rolePostName = Parameter.builder().name("displayText").type(String.class).templated(true).build();
|
.name("name")
|
||||||
Parameter emote = Parameter.builder().name("emote").type(FullEmote.class).optional(true).templated(true).build();
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter role = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("role")
|
||||||
|
.type(Role.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter rolePostName = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("displayText")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter emote = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("emote")
|
||||||
|
.type(FullEmote.class)
|
||||||
|
.optional(true)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
List<Parameter> parameters = Arrays.asList(placeName, role, rolePostName, emote);
|
List<Parameter> parameters = Arrays.asList(placeName, role, rolePostName, emote);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
.name("addRoleToAssignableRolePlace")
|
.name("addRoleToAssignableRolePlace")
|
||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
|
|||||||
@@ -47,9 +47,24 @@ public class ChangeAssignableRolePlaceConfig extends AbstractConditionableComman
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
Parameter assignableRolePlaceName = Parameter.builder().name("name").type(String.class).templated(true).build();
|
Parameter assignableRolePlaceName = Parameter
|
||||||
Parameter parameterKey = Parameter.builder().name("key").type(AssignableRolePlaceParameterKey.class).templated(true).build();
|
.builder()
|
||||||
Parameter parameterValue = Parameter.builder().name("value").type(String.class).templated(true).build();
|
.name("name")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter parameterKey = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("key")
|
||||||
|
.type(AssignableRolePlaceParameterKey.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter parameterValue = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("value")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
List<Parameter> parameters = Arrays.asList(assignableRolePlaceName, parameterKey, parameterValue);
|
List<Parameter> parameters = Arrays.asList(assignableRolePlaceName, parameterKey, parameterValue);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||||
@@ -57,6 +72,7 @@ public class ChangeAssignableRolePlaceConfig extends AbstractConditionableComman
|
|||||||
.name("changeAssignableRolePlaceConfig")
|
.name("changeAssignableRolePlaceConfig")
|
||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ public class CreateAssignableRolePost extends AbstractConditionableCommand {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ChannelManagementService channelManagementService;
|
private ChannelManagementService channelManagementService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ServerManagementService serverManagementService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(CommandContext commandContext) {
|
public CommandResult execute(CommandContext commandContext) {
|
||||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||||
@@ -57,20 +54,47 @@ public class CreateAssignableRolePost extends AbstractConditionableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
List<ParameterValidator> rolePlaceNameValidator = Arrays.asList(MaxStringLengthValidator.max(AssignableRolePlace.ASSIGNABLE_PLACE_NAME_LIMIT));
|
List<ParameterValidator> rolePlaceNameValidator = Arrays.asList(MaxStringLengthValidator.max(AssignableRolePlace.ASSIGNABLE_PLACE_NAME_LIMIT));
|
||||||
Parameter rolePostName = Parameter.builder().name("name").validators(rolePlaceNameValidator).type(String.class).templated(true).build();
|
Parameter rolePostName = Parameter
|
||||||
Parameter channel = Parameter.builder().name("channel").type(TextChannel.class).templated(true).build();
|
.builder()
|
||||||
Parameter type = Parameter.builder().name("type").type(AssignableRolePlaceType.class).templated(true).optional(true).build();
|
.name("name")
|
||||||
|
.validators(rolePlaceNameValidator)
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter channel = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("channel")
|
||||||
|
.type(TextChannel.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter type = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("type")
|
||||||
|
.type(AssignableRolePlaceType.class)
|
||||||
|
.templated(true)
|
||||||
|
.optional(true)
|
||||||
|
.build();
|
||||||
List<ParameterValidator> rolePlaceDescriptionValidator = Arrays.asList(MaxStringLengthValidator.max(AssignableRolePlace.ASSIGNABLE_PLACE_NAME_LIMIT));
|
List<ParameterValidator> rolePlaceDescriptionValidator = Arrays.asList(MaxStringLengthValidator.max(AssignableRolePlace.ASSIGNABLE_PLACE_NAME_LIMIT));
|
||||||
Parameter text = Parameter.builder().name("text").validators(rolePlaceDescriptionValidator).type(String.class).templated(true).build();
|
Parameter text = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("text")
|
||||||
|
.validators(rolePlaceDescriptionValidator)
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
List<String> aliases = Arrays.asList("crRPl", "crAssRoPl");
|
List<String> aliases = Arrays.asList("crRPl", "crAssRoPl");
|
||||||
List<Parameter> parameters = Arrays.asList(rolePostName, channel, text, type);
|
List<Parameter> parameters = Arrays.asList(rolePostName, channel, text, type);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
.name("createAssignableRolePlace")
|
.name("createAssignableRolePlace")
|
||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
.aliases(aliases)
|
.aliases(aliases)
|
||||||
.help(helpInfo)
|
.help(helpInfo)
|
||||||
|
|||||||
@@ -41,7 +41,12 @@ public class DeactivateAssignableRolePlace extends AbstractConditionableCommand
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
Parameter rolePostName = Parameter.builder().name("name").type(String.class).templated(true).build();
|
Parameter rolePostName = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("name")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
List<Parameter> parameters = Arrays.asList(rolePostName);
|
List<Parameter> parameters = Arrays.asList(rolePostName);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
@@ -49,6 +54,7 @@ public class DeactivateAssignableRolePlace extends AbstractConditionableCommand
|
|||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
|
|||||||
@@ -41,7 +41,12 @@ public class DeleteAssignableRolePlace extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
Parameter rolePostName = Parameter.builder().name("name").type(String.class).templated(true).build();
|
Parameter rolePostName = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("name")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
List<Parameter> parameters = Arrays.asList(rolePostName);
|
List<Parameter> parameters = Arrays.asList(rolePostName);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
@@ -50,6 +55,7 @@ public class DeleteAssignableRolePlace extends AbstractConditionableCommand {
|
|||||||
.templated(true)
|
.templated(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.requiresConfirmation(true)
|
.requiresConfirmation(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
|
|||||||
@@ -46,15 +46,29 @@ public class EditAssignableRolePlaceText extends AbstractConditionableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
List<ParameterValidator> rolePlaceNameValidator = Arrays.asList(MaxStringLengthValidator.max(AssignableRolePlace.ASSIGNABLE_PLACE_NAME_LIMIT));
|
List<ParameterValidator> rolePlaceNameValidator = Arrays.asList(MaxStringLengthValidator.max(AssignableRolePlace.ASSIGNABLE_PLACE_NAME_LIMIT));
|
||||||
Parameter rolePostName = Parameter.builder().name("name").validators(rolePlaceNameValidator).type(String.class).templated(true).build();
|
Parameter rolePostName = Parameter
|
||||||
Parameter newText = Parameter.builder().name("newText").type(String.class).templated(true).build();
|
.builder().name("name")
|
||||||
|
.validators(rolePlaceNameValidator)
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter newText = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("newText")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
List<Parameter> parameters = Arrays.asList(rolePostName, newText);
|
List<Parameter> parameters = Arrays.asList(rolePostName, newText);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
.name("editAssignableRolePlaceText")
|
.name("editAssignableRolePlaceText")
|
||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public class MoveAssignableRolePlace extends AbstractConditionableCommand {
|
|||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
|
|||||||
@@ -35,15 +35,31 @@ public class RemoveAssignableRoleCondition extends AbstractConditionableCommand
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
Parameter placeName = Parameter.builder().name("name").type(String.class).templated(true).build();
|
Parameter placeName = Parameter
|
||||||
Parameter role = Parameter.builder().name("role").type(Role.class).templated(true).build();
|
.builder()
|
||||||
Parameter conditionKey = Parameter.builder().name("conditionKey").type(AssignableRoleConditionType.class).templated(true).build();
|
.name("name")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter role = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("role")
|
||||||
|
.type(Role.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter conditionKey = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("conditionKey")
|
||||||
|
.type(AssignableRoleConditionType.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
List<Parameter> parameters = Arrays.asList(placeName, role, conditionKey);
|
List<Parameter> parameters = Arrays.asList(placeName, role, conditionKey);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
.name("removeAssignableRoleCondition")
|
.name("removeAssignableRoleCondition")
|
||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
|
|||||||
@@ -44,16 +44,30 @@ public class RemoveRoleFromAssignableRolePlace extends AbstractConditionableComm
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
Parameter rolePostName = Parameter.builder().name("name").type(String.class).templated(true).build();
|
Parameter rolePostName = Parameter
|
||||||
Parameter role = Parameter.builder().name("role").type(ARole.class).templated(true).build();
|
.builder()
|
||||||
|
.name("name")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
Parameter role = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("role")
|
||||||
|
.type(ARole.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
List<Parameter> parameters = Arrays.asList(rolePostName, role);
|
List<Parameter> parameters = Arrays.asList(rolePostName, role);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
.name("removeRoleFromAssignableRolePlace")
|
.name("removeRoleFromAssignableRolePlace")
|
||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
.help(helpInfo)
|
.help(helpInfo)
|
||||||
|
|||||||
@@ -48,14 +48,23 @@ public class SetupAssignableRolePlace extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
Parameter rolePostName = Parameter.builder().name("name").type(String.class).templated(true).build();
|
Parameter rolePostName = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("name")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
List<Parameter> parameters = Arrays.asList(rolePostName);
|
List<Parameter> parameters = Arrays.asList(rolePostName);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
.name("setupAssignableRolePlace")
|
.name("setupAssignableRolePlace")
|
||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
|
|||||||
@@ -48,15 +48,24 @@ public class ShowAssignableRolePlaceConfig extends AbstractConditionableCommand
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
Parameter rolePostName = Parameter.builder().name("name").type(String.class).templated(true).build();
|
Parameter rolePostName = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("name")
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
List<Parameter> parameters = Arrays.asList(rolePostName);
|
List<Parameter> parameters = Arrays.asList(rolePostName);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
.name("showAssignableRolePlaceConfig")
|
.name("showAssignableRolePlaceConfig")
|
||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
.causesReaction(false)
|
.causesReaction(false)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
.help(helpInfo)
|
.help(helpInfo)
|
||||||
|
|||||||
@@ -45,11 +45,15 @@ public class ShowAssignableRolePlaces extends AbstractConditionableCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
.name("showAssignableRolePlaces")
|
.name("showAssignableRolePlaces")
|
||||||
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.help(helpInfo)
|
.help(helpInfo)
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<property name="assignableRoleModule" value="(SELECT id FROM module WHERE name = 'assignableRoles')"/>
|
<property name="assignableRoleModule" value="(SELECT id FROM module WHERE name = 'assignableRoles')"/>
|
||||||
<property name="assignableRoleFeature" value="(SELECT id FROM feature WHERE key = 'assignableRole')"/>
|
<property name="assignableRoleFeature" value="(SELECT id FROM feature WHERE key = 'assignableRole')"/>
|
||||||
<changeSet author="Sheldan" id="assignable_roles-commands">
|
<changeSet author="Sheldan" id="assignable_roles-commands">
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="feature.xml" relativeToChangelogFile="true"/>
|
<include file="feature.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="module.xml" relativeToChangelogFile="true"/>
|
<include file="module.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="command.xml" relativeToChangelogFile="true"/>
|
<include file="command.xml" relativeToChangelogFile="true"/>
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="assignable_role-feature-insertion">
|
<changeSet author="Sheldan" id="assignable_role-feature-insertion">
|
||||||
<insert tableName="feature">
|
<insert tableName="feature">
|
||||||
<column name="key" value="assignableRole"/>
|
<column name="key" value="assignableRole"/>
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="assignable_role-module-insertion">
|
<changeSet author="Sheldan" id="assignable_role-module-insertion">
|
||||||
<insert tableName="module">
|
<insert tableName="module">
|
||||||
<column name="name" value="assignableRoles"/>
|
<column name="name" value="assignableRoles"/>
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="assignable_role-table">
|
<changeSet author="Sheldan" id="assignable_role-table">
|
||||||
<createTable tableName="assignable_role">
|
<createTable tableName="assignable_role">
|
||||||
<column autoIncrement="true" name="id" type="BIGINT">
|
<column autoIncrement="true" name="id" type="BIGINT">
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="assignable_role_condition-table">
|
<changeSet author="Sheldan" id="assignable_role_condition-table">
|
||||||
<createTable tableName="assignable_role_condition">
|
<createTable tableName="assignable_role_condition">
|
||||||
<column autoIncrement="true" name="id" type="BIGINT">
|
<column autoIncrement="true" name="id" type="BIGINT">
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="assignable_role_place-table">
|
<changeSet author="Sheldan" id="assignable_role_place-table">
|
||||||
<createTable tableName="assignable_role_place">
|
<createTable tableName="assignable_role_place">
|
||||||
<column autoIncrement="true" name="id" type="BIGINT">
|
<column autoIncrement="true" name="id" type="BIGINT">
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="assigned_role_user-table">
|
<changeSet author="Sheldan" id="assigned_role_user-table">
|
||||||
<createTable tableName="assigned_role_user">
|
<createTable tableName="assigned_role_user">
|
||||||
<column name="id" type="BIGINT">
|
<column name="id" type="BIGINT">
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="assignable_role_place.xml" relativeToChangelogFile="true"/>
|
<include file="assignable_role_place.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="assignable_role.xml" relativeToChangelogFile="true"/>
|
<include file="assignable_role.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="assignable_role_condition.xml" relativeToChangelogFile="true"/>
|
<include file="assignable_role_condition.xml" relativeToChangelogFile="true"/>
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="assignableRoles-tables/tables.xml" relativeToChangelogFile="true"/>
|
<include file="assignableRoles-tables/tables.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="assignableRoles-seedData/data.xml" relativeToChangelogFile="true"/>
|
<include file="assignableRoles-seedData/data.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="assignable_role_place-add_type">
|
<changeSet author="Sheldan" id="assignable_role_place-add_type">
|
||||||
<addColumn tableName="assignable_role_place">
|
<addColumn tableName="assignable_role_place">
|
||||||
<column name="type" type="VARCHAR2(128)" defaultValue="DEFAULT"/>
|
<column name="type" type="VARCHAR2(128)" defaultValue="DEFAULT"/>
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="assignable_role_place.xml" relativeToChangelogFile="true"/>
|
<include file="assignable_role_place.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="1.0-assignableRoles/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.0-assignableRoles/collection.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="1.3.4/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.3.4/collection.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>assignable-roles</artifactId>
|
<artifactId>assignable-roles</artifactId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>assignable-roles-int</artifactId>
|
<artifactId>assignable-roles-int</artifactId>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>custom-command</artifactId>
|
<artifactId>custom-command</artifactId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package dev.sheldan.abstracto.customcommand.command;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.command.UtilityModuleDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||||
|
import dev.sheldan.abstracto.customcommand.config.CustomCommandFeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.customcommand.config.CustomCommandSlashCommandNames;
|
||||||
|
import dev.sheldan.abstracto.customcommand.service.management.CustomCommandService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class CreateCustomCommand extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
private static final String CREATE_CUSTOM_COMMAND_COMMAND = "createCustomCommand";
|
||||||
|
private static final String CUSTOM_COMMAND_NAME_PARAMETER = "commandName";
|
||||||
|
private static final String CUSTOM_COMMAND_CONTENT_PARAMETER = "response";
|
||||||
|
private static final String CREATE_CUSTOM_COMMAND_RESPONSE_TEMPLATE_KEY = "createCustomCommand_response";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SlashCommandParameterService slashCommandParameterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomCommandService customCommandService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
String name = slashCommandParameterService.getCommandOption(CUSTOM_COMMAND_NAME_PARAMETER, event, String.class);
|
||||||
|
String content = slashCommandParameterService.getCommandOption(CUSTOM_COMMAND_CONTENT_PARAMETER, event, String.class);
|
||||||
|
|
||||||
|
customCommandService.createCustomCommand(name, content, event.getMember());
|
||||||
|
return interactionService.replyEmbed(CREATE_CUSTOM_COMMAND_RESPONSE_TEMPLATE_KEY, event)
|
||||||
|
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return CustomCommandFeatureDefinition.CUSTOM_COMMAND;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
Parameter commandNameParameter = Parameter
|
||||||
|
.builder()
|
||||||
|
.name(CUSTOM_COMMAND_NAME_PARAMETER)
|
||||||
|
.templated(true)
|
||||||
|
.type(String.class)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Parameter commandContentParameter = Parameter
|
||||||
|
.builder()
|
||||||
|
.name(CUSTOM_COMMAND_CONTENT_PARAMETER)
|
||||||
|
.templated(true)
|
||||||
|
.type(String.class)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
List<Parameter> parameters = Arrays.asList(commandNameParameter, commandContentParameter);
|
||||||
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
|
.builder()
|
||||||
|
.enabled(true)
|
||||||
|
.rootCommandName(CustomCommandSlashCommandNames.CUSTOM_COMMAND)
|
||||||
|
.commandName("create")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name(CREATE_CUSTOM_COMMAND_COMMAND)
|
||||||
|
.module(UtilityModuleDefinition.UTILITY)
|
||||||
|
.templated(true)
|
||||||
|
.async(true)
|
||||||
|
.slashCommandOnly(true)
|
||||||
|
.slashCommandConfig(slashCommandConfig)
|
||||||
|
.causesReaction(true)
|
||||||
|
.supportsEmbedException(true)
|
||||||
|
.parameters(parameters)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,8 +45,16 @@ public class CustomCommandAlternative implements CommandAlternative {
|
|||||||
private CustomCommandFeatureConfig customCommandFeatureConfig;
|
private CustomCommandFeatureConfig customCommandFeatureConfig;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldExecute(UnParsedCommandParameter parameter, Guild guild) {
|
public boolean shouldExecute(UnParsedCommandParameter parameter, Guild guild, Message message) {
|
||||||
return featureFlagService.isFeatureEnabled(customCommandFeatureConfig, guild.getIdLong());
|
boolean featureEnabled = featureFlagService.isFeatureEnabled(customCommandFeatureConfig, guild.getIdLong());
|
||||||
|
if(featureEnabled) {
|
||||||
|
String contentStripped = message.getContentRaw();
|
||||||
|
List<String> parameters = Arrays.asList(contentStripped.split(" "));
|
||||||
|
String commandName = commandRegistry.getCommandName(parameters.get(0), message.getGuild().getIdLong());
|
||||||
|
Optional<CustomCommand> customCommandOptional = customCommandManagementService.getCustomCommandByName(commandName, message.getGuild().getIdLong());
|
||||||
|
return customCommandOptional.isPresent();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package dev.sheldan.abstracto.customcommand.command;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.command.UtilityModuleDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||||
|
import dev.sheldan.abstracto.customcommand.config.CustomCommandFeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.customcommand.config.CustomCommandSlashCommandNames;
|
||||||
|
import dev.sheldan.abstracto.customcommand.service.management.CustomCommandService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class DeleteCustomCommand extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
private static final String DELETE_CUSTOM_COMMAND_COMMAND = "deleteCustomCommand";
|
||||||
|
private static final String DELETE_CUSTOM_COMMAND_RESPONSE_TEMPLATE_KEY = "deleteCustomCommand_response";
|
||||||
|
private static final String CUSTOM_COMMAND_NAME_PARAMETER = "commandName";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SlashCommandParameterService slashCommandParameterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomCommandService customCommandService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
String name = slashCommandParameterService.getCommandOption(CUSTOM_COMMAND_NAME_PARAMETER, event, String.class);
|
||||||
|
|
||||||
|
customCommandService.deleteCustomCommand(name, event.getGuild());
|
||||||
|
return interactionService.replyEmbed(DELETE_CUSTOM_COMMAND_RESPONSE_TEMPLATE_KEY, event)
|
||||||
|
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
Parameter commandNameParameter = Parameter
|
||||||
|
.builder()
|
||||||
|
.name(CUSTOM_COMMAND_NAME_PARAMETER)
|
||||||
|
.templated(true)
|
||||||
|
.type(String.class)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
List<Parameter> parameters = Arrays.asList(commandNameParameter);
|
||||||
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
|
.builder()
|
||||||
|
.enabled(true)
|
||||||
|
.rootCommandName(CustomCommandSlashCommandNames.CUSTOM_COMMAND)
|
||||||
|
.commandName("delete")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name(DELETE_CUSTOM_COMMAND_COMMAND)
|
||||||
|
.module(UtilityModuleDefinition.UTILITY)
|
||||||
|
.templated(true)
|
||||||
|
.async(true)
|
||||||
|
.slashCommandConfig(slashCommandConfig)
|
||||||
|
.causesReaction(true)
|
||||||
|
.slashCommandOnly(true)
|
||||||
|
.supportsEmbedException(true)
|
||||||
|
.parameters(parameters)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return CustomCommandFeatureDefinition.CUSTOM_COMMAND;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package dev.sheldan.abstracto.customcommand.command;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.command.UtilityModuleDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandAutoCompleteService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||||
|
import dev.sheldan.abstracto.customcommand.config.CustomCommandFeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.customcommand.config.CustomCommandSlashCommandNames;
|
||||||
|
import dev.sheldan.abstracto.customcommand.model.command.CustomCommandResponseModel;
|
||||||
|
import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
||||||
|
import dev.sheldan.abstracto.customcommand.service.management.CustomCommandService;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class GetCustomCommand extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
private static final String GET_CUSTOM_COMMAND_COMMAND = "getCustomCommand";
|
||||||
|
private static final String CUSTOM_COMMAND_NAME_PARAMETER = "commandName";
|
||||||
|
private static final String GET_CUSTOM_COMMAND_RESPONSE_TEMPLATE_KEY = "getCustomCommand_response";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SlashCommandParameterService slashCommandParameterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomCommandService customCommandService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SlashCommandAutoCompleteService slashCommandAutoCompleteService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
String name = slashCommandParameterService.getCommandOption(CUSTOM_COMMAND_NAME_PARAMETER, event, String.class);
|
||||||
|
CustomCommand customCommand = customCommandService.getCustomCommand(name, event.getGuild());
|
||||||
|
CustomCommandResponseModel model = CustomCommandResponseModel
|
||||||
|
.builder()
|
||||||
|
.additionalText(customCommand.getAdditionalMessage())
|
||||||
|
.build();
|
||||||
|
return interactionService.replyEmbed(GET_CUSTOM_COMMAND_RESPONSE_TEMPLATE_KEY, model, event)
|
||||||
|
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> performAutoComplete(CommandAutoCompleteInteractionEvent event) {
|
||||||
|
if(slashCommandAutoCompleteService.matchesParameter(event.getFocusedOption(), CUSTOM_COMMAND_NAME_PARAMETER)) {
|
||||||
|
String input = event.getFocusedOption().getValue();
|
||||||
|
return customCommandService.getCustomCommandsStartingWith(input, event.getGuild())
|
||||||
|
.stream()
|
||||||
|
.map(CustomCommand::getName)
|
||||||
|
.limit(25)
|
||||||
|
.toList();
|
||||||
|
} else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return CustomCommandFeatureDefinition.CUSTOM_COMMAND;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
Parameter commandNameParameter = Parameter
|
||||||
|
.builder()
|
||||||
|
.name(CUSTOM_COMMAND_NAME_PARAMETER)
|
||||||
|
.templated(true)
|
||||||
|
.supportsAutoComplete(true)
|
||||||
|
.type(String.class)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
List<Parameter> parameters = Arrays.asList(commandNameParameter);
|
||||||
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
|
.builder()
|
||||||
|
.enabled(true)
|
||||||
|
.rootCommandName(CustomCommandSlashCommandNames.CUSTOM_COMMAND_PUBLIC)
|
||||||
|
.commandName("get")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name(GET_CUSTOM_COMMAND_COMMAND)
|
||||||
|
.module(UtilityModuleDefinition.UTILITY)
|
||||||
|
.templated(true)
|
||||||
|
.async(true)
|
||||||
|
.slashCommandOnly(true)
|
||||||
|
.slashCommandConfig(slashCommandConfig)
|
||||||
|
.causesReaction(true)
|
||||||
|
.supportsEmbedException(true)
|
||||||
|
.parameters(parameters)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package dev.sheldan.abstracto.customcommand.command;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.command.UtilityModuleDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||||
|
import dev.sheldan.abstracto.core.service.PaginatorService;
|
||||||
|
import dev.sheldan.abstracto.customcommand.config.CustomCommandFeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.customcommand.config.CustomCommandSlashCommandNames;
|
||||||
|
import dev.sheldan.abstracto.customcommand.model.command.ListCustomCommandsResponseModel;
|
||||||
|
import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
||||||
|
import dev.sheldan.abstracto.customcommand.service.management.CustomCommandService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class ListCustomCommands extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
private static final String CREATE_CUSTOM_COMMAND_COMMAND = "listCustomCommands";
|
||||||
|
private static final String LIST_CUSTOM_COMMANDS_TEMPLATE_KEY = "listCustomCommands_response";
|
||||||
|
private static final String NO_CUSTOM_COMMANDS_TEMPLATE_KEY = "listCustomCommands_no_commands_response";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomCommandService customCommandService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PaginatorService paginatorService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
List<CustomCommand> customCommands = customCommandService.getCustomCommands(event.getGuild());
|
||||||
|
if(customCommands.isEmpty()) {
|
||||||
|
return interactionService.replyEmbed(NO_CUSTOM_COMMANDS_TEMPLATE_KEY, event)
|
||||||
|
.thenApply(interactionHook -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
ListCustomCommandsResponseModel model = ListCustomCommandsResponseModel.fromCommands(customCommands);
|
||||||
|
return paginatorService.createPaginatorFromTemplate(LIST_CUSTOM_COMMANDS_TEMPLATE_KEY, model, event)
|
||||||
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return CustomCommandFeatureDefinition.CUSTOM_COMMAND;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
|
.builder()
|
||||||
|
.enabled(true)
|
||||||
|
.rootCommandName(CustomCommandSlashCommandNames.CUSTOM_COMMAND_PUBLIC)
|
||||||
|
.commandName("list")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name(CREATE_CUSTOM_COMMAND_COMMAND)
|
||||||
|
.module(UtilityModuleDefinition.UTILITY)
|
||||||
|
.templated(true)
|
||||||
|
.async(true)
|
||||||
|
.slashCommandOnly(true)
|
||||||
|
.slashCommandConfig(slashCommandConfig)
|
||||||
|
.causesReaction(true)
|
||||||
|
.supportsEmbedException(true)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,9 +5,13 @@ import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
|||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface CustomCommandRepository extends JpaRepository<CustomCommand, Long> {
|
public interface CustomCommandRepository extends JpaRepository<CustomCommand, Long> {
|
||||||
Optional<CustomCommand> getByNameIgnoreCaseAndServer(String name, AServer server);
|
Optional<CustomCommand> getByNameIgnoreCaseAndServer(String name, AServer server);
|
||||||
|
void deleteByNameAndServer(String name, AServer server);
|
||||||
|
List<CustomCommand> findByServer(AServer server);
|
||||||
|
List<CustomCommand> findByNameStartsWithIgnoreCaseAndServer(String prefix, AServer server);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package dev.sheldan.abstracto.customcommand.service;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
|
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||||
|
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||||
|
import dev.sheldan.abstracto.customcommand.exception.CustomCommandExistsException;
|
||||||
|
import dev.sheldan.abstracto.customcommand.exception.CustomCommandNotFoundException;
|
||||||
|
import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
||||||
|
import dev.sheldan.abstracto.customcommand.service.management.CustomCommandManagementService;
|
||||||
|
import dev.sheldan.abstracto.customcommand.service.management.CustomCommandService;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CustomCommandServiceBean implements CustomCommandService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserInServerManagementService userInServerManagementService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomCommandManagementService customCommandManagementService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ServerManagementService serverManagementService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomCommand createCustomCommand(String name, String content, Member creator) {
|
||||||
|
if(customCommandManagementService.getCustomCommandByName(name, creator.getGuild().getIdLong()).isPresent()) {
|
||||||
|
throw new CustomCommandExistsException();
|
||||||
|
}
|
||||||
|
AUserInAServer creatorUser = userInServerManagementService.loadOrCreateUser(creator);
|
||||||
|
return customCommandManagementService.createCustomCommand(name, content, creatorUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteCustomCommand(String name, Guild guild) {
|
||||||
|
if(customCommandManagementService.getCustomCommandByName(name, guild.getIdLong()).isEmpty()) {
|
||||||
|
throw new CustomCommandNotFoundException();
|
||||||
|
}
|
||||||
|
AServer server = serverManagementService.loadServer(guild);
|
||||||
|
customCommandManagementService.deleteCustomCommand(name, server);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CustomCommand> getCustomCommands(Guild guild) {
|
||||||
|
AServer server = serverManagementService.loadServer(guild);
|
||||||
|
return customCommandManagementService.getCustomCommands(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomCommand getCustomCommand(String name, Guild guild) {
|
||||||
|
return customCommandManagementService.getCustomCommandByName(name, guild.getIdLong())
|
||||||
|
.orElseThrow(CustomCommandNotFoundException::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CustomCommand> getCustomCommandsStartingWith(String prefix, Guild guild) {
|
||||||
|
AServer server = serverManagementService.loadServer(guild);
|
||||||
|
return customCommandManagementService.getCustomCommandsStartingWith(prefix, server);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
package dev.sheldan.abstracto.customcommand.service.management;
|
package dev.sheldan.abstracto.customcommand.service.management;
|
||||||
|
|
||||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||||
import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
||||||
import dev.sheldan.abstracto.customcommand.repository.CustomCommandRepository;
|
import dev.sheldan.abstracto.customcommand.repository.CustomCommandRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -23,4 +25,32 @@ public class CustomCommandManagementServiceBean implements CustomCommandManageme
|
|||||||
AServer server = serverManagementService.loadServer(serverId);
|
AServer server = serverManagementService.loadServer(serverId);
|
||||||
return repository.getByNameIgnoreCaseAndServer(name, server);
|
return repository.getByNameIgnoreCaseAndServer(name, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomCommand createCustomCommand(String name, String content, AUserInAServer creator) {
|
||||||
|
CustomCommand customCommand = CustomCommand
|
||||||
|
.builder()
|
||||||
|
.name(name)
|
||||||
|
.additionalMessage(content)
|
||||||
|
.server(creator.getServerReference())
|
||||||
|
.creator(creator)
|
||||||
|
.build();
|
||||||
|
return repository.save(customCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteCustomCommand(String name, AServer server) {
|
||||||
|
repository.deleteByNameAndServer(name, server);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CustomCommand> getCustomCommands(AServer server) {
|
||||||
|
return repository.findByServer(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CustomCommand> getCustomCommandsStartingWith(String prefix, AServer server) {
|
||||||
|
return repository.findByNameStartsWithIgnoreCaseAndServer(prefix, server);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="feature.xml" relativeToChangelogFile="true"/>
|
<include file="feature.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="custom_command-feature-insertion">
|
<changeSet author="Sheldan" id="custom_command-feature-insertion">
|
||||||
<insert tableName="feature">
|
<insert tableName="feature">
|
||||||
<column name="key" value="customCommand"/>
|
<column name="key" value="customCommand"/>
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="custom_command-table">
|
<changeSet author="Sheldan" id="custom_command-table">
|
||||||
<createTable tableName="custom_command">
|
<createTable tableName="custom_command">
|
||||||
<column name="id" type="BIGINT">
|
<column name="id" type="BIGINT">
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="custom_command.xml" relativeToChangelogFile="true"/>
|
<include file="custom_command.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<property name="utilityModule" value="(SELECT id FROM module WHERE name = 'utility')"/>
|
||||||
|
<property name="customCommandFeature" value="(SELECT id FROM feature WHERE key = 'customCommand')"/>
|
||||||
|
|
||||||
|
<changeSet author="Sheldan" id="customCommand-commands">
|
||||||
|
<insert tableName="command">
|
||||||
|
<column name="name" value="createCustomCommand"/>
|
||||||
|
<column name="module_id" valueComputed="${utilityModule}"/>
|
||||||
|
<column name="feature_id" valueComputed="${customCommandFeature}"/>
|
||||||
|
</insert>
|
||||||
|
<insert tableName="command">
|
||||||
|
<column name="name" value="deleteCustomCommand"/>
|
||||||
|
<column name="module_id" valueComputed="${utilityModule}"/>
|
||||||
|
<column name="feature_id" valueComputed="${customCommandFeature}"/>
|
||||||
|
</insert>
|
||||||
|
<insert tableName="command">
|
||||||
|
<column name="name" value="getCustomCommand"/>
|
||||||
|
<column name="module_id" valueComputed="${utilityModule}"/>
|
||||||
|
<column name="feature_id" valueComputed="${customCommandFeature}"/>
|
||||||
|
</insert>
|
||||||
|
<insert tableName="command">
|
||||||
|
<column name="name" value="listCustomCommands"/>
|
||||||
|
<column name="module_id" valueComputed="${utilityModule}"/>
|
||||||
|
<column name="feature_id" valueComputed="${customCommandFeature}"/>
|
||||||
|
</insert>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<include file="command.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<changeSet author="Sheldan" id="custom_command-add_auto_increment">
|
||||||
|
<sql>
|
||||||
|
create sequence custom_command_id_seq;
|
||||||
|
alter table custom_command alter id set default nextval('custom_command_id_seq');
|
||||||
|
</sql>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
|
<include file="custom_command.xml" relativeToChangelogFile="true"/>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="1.4.0/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.4.0/collection.xml" relativeToChangelogFile="true"/>
|
||||||
|
<include file="1.5.8/collection.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>custom-command</artifactId>
|
<artifactId>custom-command</artifactId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package dev.sheldan.abstracto.customcommand.config;
|
||||||
|
|
||||||
|
public class CustomCommandSlashCommandNames {
|
||||||
|
public static final String CUSTOM_COMMAND = "cc";
|
||||||
|
public static final String CUSTOM_COMMAND_PUBLIC = "customCommands";
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.sheldan.abstracto.customcommand.exception;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||||
|
|
||||||
|
public class CustomCommandExistsException extends AbstractoTemplatableException {
|
||||||
|
@Override
|
||||||
|
public String getTemplateName() {
|
||||||
|
return "custom_command_exists_exception";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getTemplateModel() {
|
||||||
|
return new Object();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.sheldan.abstracto.customcommand.exception;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
|
||||||
|
|
||||||
|
public class CustomCommandNotFoundException extends AbstractoTemplatableException {
|
||||||
|
@Override
|
||||||
|
public String getTemplateName() {
|
||||||
|
return "custom_command_not_found_exception";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getTemplateModel() {
|
||||||
|
return new Object();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package dev.sheldan.abstracto.customcommand.model.command;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
||||||
|
import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
public class ListCustomCommandModel {
|
||||||
|
private String name;
|
||||||
|
private String content;
|
||||||
|
private MemberDisplay creator;
|
||||||
|
|
||||||
|
public static ListCustomCommandModel fromCustomCommand(CustomCommand customCommand) {
|
||||||
|
return ListCustomCommandModel
|
||||||
|
.builder()
|
||||||
|
.name(customCommand.getName())
|
||||||
|
.content(customCommand.getAdditionalMessage())
|
||||||
|
.creator(MemberDisplay.fromAUserInAServer(customCommand.getCreator()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package dev.sheldan.abstracto.customcommand.model.command;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
public class ListCustomCommandsResponseModel {
|
||||||
|
private List<ListCustomCommandModel> customCommands;
|
||||||
|
|
||||||
|
public static ListCustomCommandsResponseModel fromCommands(List<CustomCommand> customCommands) {
|
||||||
|
return ListCustomCommandsResponseModel
|
||||||
|
.builder()
|
||||||
|
.customCommands(customCommands
|
||||||
|
.stream()
|
||||||
|
.map(ListCustomCommandModel::fromCustomCommand)
|
||||||
|
.collect(Collectors.toList()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,16 @@
|
|||||||
package dev.sheldan.abstracto.customcommand.service.management;
|
package dev.sheldan.abstracto.customcommand.service.management;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public interface CustomCommandManagementService {
|
public interface CustomCommandManagementService {
|
||||||
Optional<CustomCommand> getCustomCommandByName(String name, Long serverId);
|
Optional<CustomCommand> getCustomCommandByName(String name, Long serverId);
|
||||||
|
CustomCommand createCustomCommand(String name, String content, AUserInAServer creator);
|
||||||
|
void deleteCustomCommand(String name, AServer server);
|
||||||
|
List<CustomCommand> getCustomCommands(AServer server);
|
||||||
|
List<CustomCommand> getCustomCommandsStartingWith(String prefix, AServer server);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.sheldan.abstracto.customcommand.service.management;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.customcommand.model.database.CustomCommand;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CustomCommandService {
|
||||||
|
CustomCommand createCustomCommand(String name, String content, Member creator);
|
||||||
|
void deleteCustomCommand(String name, Guild guild);
|
||||||
|
List<CustomCommand> getCustomCommands(Guild guild);
|
||||||
|
CustomCommand getCustomCommand(String name, Guild guild);
|
||||||
|
List<CustomCommand> getCustomCommandsStartingWith(String prefix, Guild guild);
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<artifactId>dynamic-activity</artifactId>
|
<artifactId>dynamic-activity</artifactId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
<include file="tables/tables.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="activity_job-insert">
|
<changeSet author="Sheldan" id="activity_job-insert">
|
||||||
<insert tableName="scheduler_job">
|
<insert tableName="scheduler_job">
|
||||||
<column name="name" value="activityJob"/>
|
<column name="name" value="activityJob"/>
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="activity_job.xml" relativeToChangelogFile="true"/>
|
<include file="activity_job.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<changeSet author="Sheldan" id="activity-table">
|
<changeSet author="Sheldan" id="activity-table">
|
||||||
<createTable tableName="activity">
|
<createTable tableName="activity">
|
||||||
<column autoIncrement="true" name="id" type="BIGINT">
|
<column autoIncrement="true" name="id" type="BIGINT">
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="activity.xml" relativeToChangelogFile="true"/>
|
<include file="activity.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,6 @@
|
|||||||
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog-ext dbchangelog.xsd
|
|
||||||
http://www.liquibase.org/xml/ns/pro dbchangelog.xsd" >
|
|
||||||
<include file="1.3.1/collection.xml" relativeToChangelogFile="true"/>
|
<include file="1.3.1/collection.xml" relativeToChangelogFile="true"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>dynamic-activity</artifactId>
|
<artifactId>dynamic-activity</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>abstracto-modules</artifactId>
|
<artifactId>abstracto-modules</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,12 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>entertainment</artifactId>
|
<artifactId>entertainment</artifactId>
|
||||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||||
<version>1.5.6</version>
|
<version>1.5.30</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>entertainment-impl</artifactId>
|
<artifactId>entertainment-impl</artifactId>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -57,6 +52,12 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>dev.sheldan.abstracto.scheduling</groupId>
|
||||||
|
<artifactId>scheduling-int</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,140 @@
|
|||||||
|
package dev.sheldan.abstracto.entertainment.command;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.SlashCommandConfig;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.slash.parameter.SlashCommandParameterService;
|
||||||
|
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||||
|
import dev.sheldan.abstracto.core.service.ConfigService;
|
||||||
|
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||||
|
import dev.sheldan.abstracto.core.utils.ParseUtils;
|
||||||
|
import dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.entertainment.config.EntertainmentModuleDefinition;
|
||||||
|
import dev.sheldan.abstracto.entertainment.config.EntertainmentSlashCommandNames;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.command.PressFPromptModel;
|
||||||
|
import dev.sheldan.abstracto.entertainment.service.EntertainmentService;
|
||||||
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import static dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureConfig.PRESS_F_DEFAULT_DURATION_SECONDS;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PressFCommand extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
public static final String TEXT_PARAMETER = "text";
|
||||||
|
public static final String DURATION_PARAMETER = "duration";
|
||||||
|
|
||||||
|
private static final String RESPONSE_TEMPLATE = "pressF_response";
|
||||||
|
public static final String PRESS_F_COMMAND_NAME = "pressF";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SlashCommandParameterService slashCommandParameterService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConfigService configService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntertainmentService entertainmentService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ChannelService channelService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
|
||||||
|
String text = (String) commandContext.getParameters().getParameters().get(0);
|
||||||
|
Long defaultDurationSeconds = configService.getLongValueOrConfigDefault(PRESS_F_DEFAULT_DURATION_SECONDS, commandContext.getGuild().getIdLong());
|
||||||
|
Duration duration = Duration.ofSeconds(defaultDurationSeconds);
|
||||||
|
PressFPromptModel pressFModel = entertainmentService.getPressFModel(text);
|
||||||
|
List<CompletableFuture<Message>> messages = channelService.sendEmbedTemplateInMessageChannelList(RESPONSE_TEMPLATE, pressFModel, commandContext.getChannel());
|
||||||
|
return FutureUtils.toSingleFutureGeneric(messages)
|
||||||
|
.thenAccept(unused -> entertainmentService.persistPressF(text, duration, commandContext.getAuthor(),
|
||||||
|
pressFModel.getPressFComponentId(), commandContext.getChannel(), messages.get(0).join().getIdLong()))
|
||||||
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<CommandResult> executeSlash(SlashCommandInteractionEvent event) {
|
||||||
|
String text = slashCommandParameterService.getCommandOption(TEXT_PARAMETER, event, String.class);
|
||||||
|
Duration duration;
|
||||||
|
if(slashCommandParameterService.hasCommandOption(DURATION_PARAMETER, event)) {
|
||||||
|
String durationString = slashCommandParameterService.getCommandOption(DURATION_PARAMETER, event, String.class);
|
||||||
|
duration = ParseUtils.parseDuration(durationString);
|
||||||
|
} else {
|
||||||
|
Long defaultDurationSeconds = configService.getLongValueOrConfigDefault(PRESS_F_DEFAULT_DURATION_SECONDS, event.getGuild().getIdLong());
|
||||||
|
duration = Duration.ofSeconds(defaultDurationSeconds);
|
||||||
|
}
|
||||||
|
PressFPromptModel pressFModel = entertainmentService.getPressFModel(text);
|
||||||
|
return interactionService.replyEmbed(RESPONSE_TEMPLATE, pressFModel, event)
|
||||||
|
.thenCompose(interactionHook -> interactionHook.retrieveOriginal().submit())
|
||||||
|
.thenAccept(message -> {
|
||||||
|
entertainmentService.persistPressF(text, duration, event.getMember(), pressFModel.getPressFComponentId(), event.getGuildChannel(), message.getIdLong());
|
||||||
|
})
|
||||||
|
.thenApply(unused -> CommandResult.fromSuccess());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
List<Parameter> parameters = new ArrayList<>();
|
||||||
|
Parameter textParameter = Parameter
|
||||||
|
.builder()
|
||||||
|
.name(TEXT_PARAMETER)
|
||||||
|
.type(String.class)
|
||||||
|
.templated(true)
|
||||||
|
.remainder(true)
|
||||||
|
.build();
|
||||||
|
parameters.add(textParameter);
|
||||||
|
Parameter durationParameter = Parameter
|
||||||
|
.builder()
|
||||||
|
.name(DURATION_PARAMETER)
|
||||||
|
.type(Duration.class)
|
||||||
|
.slashCommandOnly(true)
|
||||||
|
.optional(true)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
parameters.add(durationParameter);
|
||||||
|
HelpInfo helpInfo = HelpInfo
|
||||||
|
.builder()
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SlashCommandConfig slashCommandConfig = SlashCommandConfig
|
||||||
|
.builder()
|
||||||
|
.enabled(true)
|
||||||
|
.rootCommandName(EntertainmentSlashCommandNames.ENTERTAINMENT)
|
||||||
|
.commandName("pressf")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name(PRESS_F_COMMAND_NAME)
|
||||||
|
.module(EntertainmentModuleDefinition.ENTERTAINMENT)
|
||||||
|
.templated(true)
|
||||||
|
.causesReaction(false)
|
||||||
|
.async(true)
|
||||||
|
.slashCommandConfig(slashCommandConfig)
|
||||||
|
.supportsEmbedException(true)
|
||||||
|
.parameters(parameters)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return EntertainmentFeatureDefinition.ENTERTAINMENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,14 +52,28 @@ public class React extends AbstractConditionableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public CommandConfiguration getConfiguration() {
|
public CommandConfiguration getConfiguration() {
|
||||||
List<Parameter> parameters = new ArrayList<>();
|
List<Parameter> parameters = new ArrayList<>();
|
||||||
parameters.add(Parameter.builder().name("message").type(Message.class).templated(true).build());
|
Parameter messageParameter = Parameter
|
||||||
parameters.add(Parameter.builder().name("text").type(String.class).remainder(true).templated(true).build());
|
.builder()
|
||||||
|
.name("message")
|
||||||
|
.type(Message.class)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
parameters.add(messageParameter);
|
||||||
|
Parameter textParameter = Parameter
|
||||||
|
.builder()
|
||||||
|
.name("text")
|
||||||
|
.type(String.class)
|
||||||
|
.remainder(true)
|
||||||
|
.templated(true)
|
||||||
|
.build();
|
||||||
|
parameters.add(textParameter);
|
||||||
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||||
return CommandConfiguration.builder()
|
return CommandConfiguration.builder()
|
||||||
.name("react")
|
.name("react")
|
||||||
.module(EntertainmentModuleDefinition.ENTERTAINMENT)
|
.module(EntertainmentModuleDefinition.ENTERTAINMENT)
|
||||||
.templated(true)
|
.templated(true)
|
||||||
.causesReaction(true)
|
.causesReaction(true)
|
||||||
|
.messageCommandOnly(true)
|
||||||
.async(true)
|
.async(true)
|
||||||
.supportsEmbedException(true)
|
.supportsEmbedException(true)
|
||||||
.parameters(parameters)
|
.parameters(parameters)
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package dev.sheldan.abstracto.entertainment.job;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.entertainment.service.EntertainmentService;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.quartz.DisallowConcurrentExecution;
|
||||||
|
import org.quartz.JobExecutionContext;
|
||||||
|
import org.quartz.PersistJobDataAfterExecution;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@DisallowConcurrentExecution
|
||||||
|
@Component
|
||||||
|
@PersistJobDataAfterExecution
|
||||||
|
public class PressFEvaluationJob extends QuartzJobBean {
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Long pressFId;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EntertainmentService entertainmentService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void executeInternal(JobExecutionContext context) {
|
||||||
|
try {
|
||||||
|
log.info("Executing press f evaluation job for pressf instance {}.", pressFId);
|
||||||
|
entertainmentService.evaluatePressF(pressFId);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
log.error("Press f evaluation job failed.", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package dev.sheldan.abstracto.entertainment.listener.interaction;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.core.config.ListenerPriority;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.InteractionService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.button.listener.ButtonClickedListener;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.button.listener.ButtonClickedListenerModel;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.button.listener.ButtonClickedListenerResult;
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
|
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
|
||||||
|
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||||
|
import dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureDefinition;
|
||||||
|
import dev.sheldan.abstracto.entertainment.exception.AlreadyPressedFException;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.PressFPayload;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.command.PressFJoinModel;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.database.PressF;
|
||||||
|
import dev.sheldan.abstracto.entertainment.service.EntertainmentServiceBean;
|
||||||
|
import dev.sheldan.abstracto.entertainment.service.management.PressFManagementService;
|
||||||
|
import dev.sheldan.abstracto.entertainment.service.management.PressFPresserManagementServiceBean;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class PressFClickedListener implements ButtonClickedListener {
|
||||||
|
|
||||||
|
private static final String PRESS_F_CLICK_RESPONSE_TEMPLATE_KEY = "pressF_join";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PressFPresserManagementServiceBean pressFPresserManagementServiceBean;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PressFManagementService pressFManagementService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserInServerManagementService userInServerManagementService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InteractionService interactionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PressFClickedListener self;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean handlesEvent(ButtonClickedListenerModel model) {
|
||||||
|
return EntertainmentServiceBean.PRESS_F_BUTTON_ORIGIN.equals(model.getOrigin());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ButtonClickedListenerResult execute(ButtonClickedListenerModel model) {
|
||||||
|
PressFPayload payload = (PressFPayload) model.getDeserializedPayload();
|
||||||
|
Optional<PressF> pressFOptional = pressFManagementService.getPressFById(payload.getPressFId());
|
||||||
|
pressFOptional.ifPresent(pressF -> {
|
||||||
|
Member presserMember = model.getEvent().getMember();
|
||||||
|
AUserInAServer presser = userInServerManagementService.loadOrCreateUser(presserMember);
|
||||||
|
Long userInServerId = presser.getUserInServerId();
|
||||||
|
if(!pressFPresserManagementServiceBean.didUserAlreadyPress(pressF, presser)) {
|
||||||
|
PressFJoinModel joinModel = PressFJoinModel
|
||||||
|
.builder()
|
||||||
|
.messageId(pressF.getMessageId())
|
||||||
|
.memberDisplay(MemberDisplay.fromMember(presserMember))
|
||||||
|
.build();
|
||||||
|
interactionService.replyEmbed(PRESS_F_CLICK_RESPONSE_TEMPLATE_KEY, joinModel, model.getEvent().getInteraction()).thenAccept(interactionHook -> {
|
||||||
|
self.persistPresser(payload.getPressFId(), userInServerId);
|
||||||
|
log.info("Send message about pressing to user {} for pressF {}.", presserMember.getIdLong(), payload.getPressFId());
|
||||||
|
}).exceptionally(throwable -> {
|
||||||
|
log.error("Failed to send message or persist press user {} in pressF {}.", presserMember.getIdLong(), payload.getPressFId(), throwable);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
log.debug("User {} already pressed for pressF {}.", presserMember.getIdLong(), payload.getPressFId());
|
||||||
|
throw new AlreadyPressedFException();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return ButtonClickedListenerResult.ACKNOWLEDGED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void persistPresser(Long pressFId, Long userInServerId) {
|
||||||
|
log.info("Persisting pressing of user {} for pressF {}.", userInServerId, pressFId);
|
||||||
|
AUserInAServer presser = userInServerManagementService.loadOrCreateUser(userInServerId);
|
||||||
|
Optional<PressF> pressFByIdOptional = pressFManagementService.getPressFById(pressFId);
|
||||||
|
pressFByIdOptional.ifPresent(pressF -> {
|
||||||
|
pressFPresserManagementServiceBean.addPresser(pressF, presser);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureDefinition getFeature() {
|
||||||
|
return EntertainmentFeatureDefinition.ENTERTAINMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getPriority() {
|
||||||
|
return ListenerPriority.MEDIUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean autoAcknowledgeEvent() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package dev.sheldan.abstracto.entertainment.model;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.interaction.button.ButtonPayload;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
public class PressFPayload implements ButtonPayload {
|
||||||
|
private Long pressFId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package dev.sheldan.abstracto.entertainment.repository;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.database.PressFPresser;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.database.embed.PressFPresserId;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface PressFPresserRepository extends JpaRepository<PressFPresser, PressFPresserId> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package dev.sheldan.abstracto.entertainment.repository;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.database.PressF;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface PressFRepository extends JpaRepository<PressF, Long> {
|
||||||
|
}
|
||||||
@@ -9,8 +9,6 @@ import dev.sheldan.abstracto.entertainment.dto.CreditGambleResult;
|
|||||||
import dev.sheldan.abstracto.entertainment.dto.PayDayResult;
|
import dev.sheldan.abstracto.entertainment.dto.PayDayResult;
|
||||||
import dev.sheldan.abstracto.entertainment.dto.SlotsResult;
|
import dev.sheldan.abstracto.entertainment.dto.SlotsResult;
|
||||||
import dev.sheldan.abstracto.entertainment.exception.NotEnoughCreditsException;
|
import dev.sheldan.abstracto.entertainment.exception.NotEnoughCreditsException;
|
||||||
import dev.sheldan.abstracto.entertainment.exception.PayDayCooldownException;
|
|
||||||
import dev.sheldan.abstracto.entertainment.exception.SlotsCooldownException;
|
|
||||||
import dev.sheldan.abstracto.entertainment.model.command.CreditsLeaderboardEntry;
|
import dev.sheldan.abstracto.entertainment.model.command.CreditsLeaderboardEntry;
|
||||||
import dev.sheldan.abstracto.entertainment.model.database.EconomyLeaderboardResult;
|
import dev.sheldan.abstracto.entertainment.model.database.EconomyLeaderboardResult;
|
||||||
import dev.sheldan.abstracto.entertainment.model.database.EconomyUser;
|
import dev.sheldan.abstracto.entertainment.model.database.EconomyUser;
|
||||||
@@ -19,14 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.temporal.ChronoUnit;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static dev.sheldan.abstracto.entertainment.config.EconomyFeatureConfig.PAYDAY_COOLDOWN_CONFIG_KEY;
|
|
||||||
import static dev.sheldan.abstracto.entertainment.config.EconomyFeatureConfig.SLOTS_COOLDOWN_CONFIG_KEY;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class EconomyServiceBean implements EconomyService {
|
public class EconomyServiceBean implements EconomyService {
|
||||||
|
|
||||||
@@ -70,42 +62,6 @@ public class EconomyServiceBean implements EconomyService {
|
|||||||
private static final Integer TRIPLE_FACTOR = 10;
|
private static final Integer TRIPLE_FACTOR = 10;
|
||||||
private static final Integer DOUBLE_FACTOR = 2;
|
private static final Integer DOUBLE_FACTOR = 2;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canTriggerPayDay(AUserInAServer aUserInAServer) {
|
|
||||||
Optional<EconomyUser> userOptional = economyUserManagementService.getUser(aUserInAServer);
|
|
||||||
return userOptional.map(this::canTriggerPayDay).orElse(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canTriggerSlots(AUserInAServer aUserInAServer) {
|
|
||||||
Optional<EconomyUser> userOptional = economyUserManagementService.getUser(aUserInAServer);
|
|
||||||
return userOptional.map(this::canTriggerSlots).orElse(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canTriggerPayDay(EconomyUser economyUser) {
|
|
||||||
return slotsTriggerIn(economyUser).isNegative();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canTriggerSlots(EconomyUser economyUser) {
|
|
||||||
return payDayTriggerIn(economyUser).isNegative();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Duration payDayTriggerIn(EconomyUser economyUser) {
|
|
||||||
Long cooldownSeconds = configService.getLongValueOrConfigDefault(PAYDAY_COOLDOWN_CONFIG_KEY, economyUser.getServer().getId());
|
|
||||||
Instant minTimeStamp = Instant.now().minus(cooldownSeconds, ChronoUnit.SECONDS);
|
|
||||||
return Duration.between(economyUser.getLastPayDay(), minTimeStamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Duration slotsTriggerIn(EconomyUser economyUser) {
|
|
||||||
Long cooldownSeconds = configService.getLongValueOrConfigDefault(SLOTS_COOLDOWN_CONFIG_KEY, economyUser.getServer().getId());
|
|
||||||
Instant minTimeStamp = Instant.now().minus(cooldownSeconds, ChronoUnit.SECONDS);
|
|
||||||
return Duration.between(economyUser.getLastSlots(), minTimeStamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EconomyUser addCredits(AUserInAServer aUserInAServer, Long credits) {
|
public EconomyUser addCredits(AUserInAServer aUserInAServer, Long credits) {
|
||||||
Optional<EconomyUser> existingUserOptional = economyUserManagementService.getUser(aUserInAServer);
|
Optional<EconomyUser> existingUserOptional = economyUserManagementService.getUser(aUserInAServer);
|
||||||
@@ -137,11 +93,6 @@ public class EconomyServiceBean implements EconomyService {
|
|||||||
Long creditsToAdd = configService.getLongValueOrConfigDefault(EconomyFeatureConfig.PAYDAY_CREDITS_CONFIG_KEY,
|
Long creditsToAdd = configService.getLongValueOrConfigDefault(EconomyFeatureConfig.PAYDAY_CREDITS_CONFIG_KEY,
|
||||||
aUserInAServer.getServerReference().getId());
|
aUserInAServer.getServerReference().getId());
|
||||||
EconomyUser economyUser = addCredits(aUserInAServer, creditsToAdd);
|
EconomyUser economyUser = addCredits(aUserInAServer, creditsToAdd);
|
||||||
Duration durationForPayday = payDayTriggerIn(economyUser);
|
|
||||||
if (durationForPayday.isNegative()) {
|
|
||||||
throw new PayDayCooldownException(durationForPayday.abs());
|
|
||||||
}
|
|
||||||
economyUser.setLastPayDay(Instant.now());
|
|
||||||
return PayDayResult
|
return PayDayResult
|
||||||
.builder()
|
.builder()
|
||||||
.currentCredits(economyUser.getCredits())
|
.currentCredits(economyUser.getCredits())
|
||||||
@@ -160,17 +111,12 @@ public class EconomyServiceBean implements EconomyService {
|
|||||||
if(user.getCredits() < bid) {
|
if(user.getCredits() < bid) {
|
||||||
throw new NotEnoughCreditsException();
|
throw new NotEnoughCreditsException();
|
||||||
}
|
}
|
||||||
Duration durationForSlots = slotsTriggerIn(user);
|
|
||||||
if (durationForSlots.isNegative()) {
|
|
||||||
throw new SlotsCooldownException(durationForSlots.abs());
|
|
||||||
}
|
|
||||||
SlotGame slotGame = playSlots();
|
SlotGame slotGame = playSlots();
|
||||||
Integer factor = slotGame.getResultFactor();
|
Integer factor = slotGame.getResultFactor();
|
||||||
Long creditChange = bid * factor;
|
Long creditChange = bid * factor;
|
||||||
addCredits(user, -bid);
|
addCredits(user, -bid);
|
||||||
addCredits(user, creditChange);
|
addCredits(user, creditChange);
|
||||||
|
|
||||||
user.setLastSlots(Instant.now());
|
|
||||||
return SlotsResult
|
return SlotsResult
|
||||||
.builder()
|
.builder()
|
||||||
.bid(bid)
|
.bid(bid)
|
||||||
|
|||||||
@@ -2,12 +2,33 @@ package dev.sheldan.abstracto.entertainment.service;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.ComponentPayloadService;
|
||||||
|
import dev.sheldan.abstracto.core.interaction.ComponentService;
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
|
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||||
import dev.sheldan.abstracto.core.service.ConfigService;
|
import dev.sheldan.abstracto.core.service.ConfigService;
|
||||||
|
import dev.sheldan.abstracto.core.service.MessageService;
|
||||||
|
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||||
|
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||||
|
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||||
|
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||||
|
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||||
import dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureConfig;
|
import dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureConfig;
|
||||||
import dev.sheldan.abstracto.entertainment.exception.ReactDuplicateCharacterException;
|
import dev.sheldan.abstracto.entertainment.exception.ReactDuplicateCharacterException;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.PressFPayload;
|
||||||
import dev.sheldan.abstracto.entertainment.model.ReactMapping;
|
import dev.sheldan.abstracto.entertainment.model.ReactMapping;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.command.PressFPromptModel;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.command.PressFResultModel;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.database.PressF;
|
||||||
|
import dev.sheldan.abstracto.entertainment.service.management.PressFManagementService;
|
||||||
|
import dev.sheldan.abstracto.scheduling.model.JobParameters;
|
||||||
|
import dev.sheldan.abstracto.scheduling.service.SchedulerService;
|
||||||
|
import jakarta.transaction.Transactional;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
@@ -17,7 +38,10 @@ import javax.annotation.PostConstruct;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -30,6 +54,9 @@ public class EntertainmentServiceBean implements EntertainmentService {
|
|||||||
"DONT_COUNT", "REPLY_NO", "SOURCES_NO", "OUTLOOK_NOT_GOOD", "DOUBTFUL" // negative
|
"DONT_COUNT", "REPLY_NO", "SOURCES_NO", "OUTLOOK_NOT_GOOD", "DOUBTFUL" // negative
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public static final String PRESS_F_BUTTON_ORIGIN = "PRESS_F_BUTTON";
|
||||||
|
private static final String PRESS_F_RESULT_TEMPLATE_KEY = "pressF_result";
|
||||||
|
|
||||||
private ReactMapping reactMapping;
|
private ReactMapping reactMapping;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -38,6 +65,33 @@ public class EntertainmentServiceBean implements EntertainmentService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ConfigService configService;
|
private ConfigService configService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ComponentService componentService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PressFManagementService pressFManagementService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserInServerManagementService userInServerManagementService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SchedulerService schedulerService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ComponentPayloadService componentPayloadService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ChannelManagementService channelManagementService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ChannelService channelService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TemplateService templateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MessageService messageService;
|
||||||
|
|
||||||
@Value("classpath:react_mappings.json")
|
@Value("classpath:react_mappings.json")
|
||||||
private Resource reactMappingSource;
|
private Resource reactMappingSource;
|
||||||
|
|
||||||
@@ -91,6 +145,66 @@ public class EntertainmentServiceBean implements EntertainmentService {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PressFPromptModel getPressFModel(String text) {
|
||||||
|
String pressFComponent = componentService.generateComponentId();
|
||||||
|
return PressFPromptModel
|
||||||
|
.builder()
|
||||||
|
.pressFComponentId(pressFComponent)
|
||||||
|
.text(text)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void persistPressF(String text, Duration duration, Member executingMember, String componentId, GuildMessageChannel guildMessageChannel, Long messageId) {
|
||||||
|
Instant targetDate = Instant.now().plus(duration);
|
||||||
|
log.info("Persisting pressF started by {} in server {} with due date {}.", executingMember.getIdLong(), executingMember.getGuild().getIdLong(), targetDate);
|
||||||
|
AUserInAServer creator = userInServerManagementService.loadOrCreateUser(executingMember);
|
||||||
|
AChannel channel = channelManagementService.loadChannel(guildMessageChannel);
|
||||||
|
PressF pressF = pressFManagementService.createPressF(text, targetDate, creator, channel, messageId);
|
||||||
|
HashMap<Object, Object> parameters = new HashMap<>();
|
||||||
|
parameters.put("pressFId", pressF.getId().toString());
|
||||||
|
JobParameters jobParameters = JobParameters
|
||||||
|
.builder()
|
||||||
|
.parameters(parameters)
|
||||||
|
.build();
|
||||||
|
log.debug("Starting scheduled job for pressF {}", pressF.getId());
|
||||||
|
schedulerService.executeJobWithParametersOnce("pressFEvaluationJob", "entertainment", jobParameters, Date.from(targetDate));
|
||||||
|
PressFPayload pressFPayload = PressFPayload
|
||||||
|
.builder()
|
||||||
|
.pressFId(pressF.getId())
|
||||||
|
.build();
|
||||||
|
log.debug("Persisting payload for pressF {}", pressF.getId());
|
||||||
|
componentPayloadService.createButtonPayload(componentId, pressFPayload, PRESS_F_BUTTON_ORIGIN, creator.getServerReference());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public CompletableFuture<Void> evaluatePressF(Long pressFId) {
|
||||||
|
Optional<PressF> pressFOptional = pressFManagementService.getPressFById(pressFId);
|
||||||
|
if(pressFOptional.isPresent()) {
|
||||||
|
log.info("Evaluating pressF with id {}", pressFId);
|
||||||
|
PressF pressF = pressFOptional.get();
|
||||||
|
PressFResultModel model = PressFResultModel
|
||||||
|
.builder()
|
||||||
|
.userCount((long) pressF.getPresser().size())
|
||||||
|
.text(pressF.getText())
|
||||||
|
.messageId(pressF.getMessageId())
|
||||||
|
.build();
|
||||||
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(PRESS_F_RESULT_TEMPLATE_KEY, model);
|
||||||
|
Long serverId = pressF.getServer().getId();
|
||||||
|
Long channelId = pressF.getPressFChannel().getId();
|
||||||
|
Long messageId = pressF.getMessageId();
|
||||||
|
return FutureUtils.toSingleFutureGeneric(channelService.sendMessageEmbedToSendToAChannel(messageToSend, pressF.getPressFChannel()))
|
||||||
|
.thenCompose(unused -> messageService.loadMessage(serverId, channelId, messageId).thenCompose(message -> {
|
||||||
|
log.info("Clearing buttons from pressF {} in with message {} in channel {} in server {}.", pressFId, pressFId, channelId, serverId);
|
||||||
|
return componentService.clearButtons(message);
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
throw new AbstractoRunTimeException(String.format("PressF with id %s not found.", pressFId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> convertTextToEmojis(String text) {
|
public List<String> convertTextToEmojis(String text) {
|
||||||
return convertTextToEmojis(text, false);
|
return convertTextToEmojis(text, false);
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ public class EconomyUserManagementServiceBean implements EconomyUserManagementSe
|
|||||||
.builder()
|
.builder()
|
||||||
.id(aUserInAServer.getUserInServerId())
|
.id(aUserInAServer.getUserInServerId())
|
||||||
.server(aUserInAServer.getServerReference())
|
.server(aUserInAServer.getServerReference())
|
||||||
.lastPayDay(Instant.now().minus(1, ChronoUnit.DAYS))
|
|
||||||
.lastSlots(Instant.now().minus(1, ChronoUnit.DAYS))
|
|
||||||
.credits(0L)
|
.credits(0L)
|
||||||
.user(aUserInAServer)
|
.user(aUserInAServer)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package dev.sheldan.abstracto.entertainment.service.management;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.database.PressF;
|
||||||
|
import dev.sheldan.abstracto.entertainment.repository.PressFRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PressFManagementServiceBean implements PressFManagementService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PressFRepository pressFRepository;
|
||||||
|
@Override
|
||||||
|
public PressF createPressF(String text, Instant targetDate, AUserInAServer creator, AChannel channel, Long messageId) {
|
||||||
|
PressF pressF = PressF
|
||||||
|
.builder()
|
||||||
|
.server(creator.getServerReference())
|
||||||
|
.creator(creator)
|
||||||
|
.messageId(messageId)
|
||||||
|
.pressFChannel(channel)
|
||||||
|
.text(text)
|
||||||
|
.targetDate(targetDate)
|
||||||
|
.build();
|
||||||
|
return pressFRepository.save(pressF);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<PressF> getPressFById(Long pressFId) {
|
||||||
|
return pressFRepository.findById(pressFId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package dev.sheldan.abstracto.entertainment.service.management;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.database.PressF;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.database.PressFPresser;
|
||||||
|
import dev.sheldan.abstracto.entertainment.model.database.embed.PressFPresserId;
|
||||||
|
import dev.sheldan.abstracto.entertainment.repository.PressFPresserRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PressFPresserManagementServiceBean implements PressFPresserManagementService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PressFPresserRepository repository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PressFPresser addPresser(PressF pressF, AUserInAServer presser) {
|
||||||
|
PressFPresser pressFPresser = PressFPresser
|
||||||
|
.builder()
|
||||||
|
.presser(presser)
|
||||||
|
.id(new PressFPresserId(presser.getUserInServerId(), pressF.getId()))
|
||||||
|
.build();
|
||||||
|
return repository.save(pressFPresser);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean didUserAlreadyPress(PressF pressF, AUserInAServer aUserInAServer) {
|
||||||
|
return repository.existsById(new PressFPresserId(aUserInAServer.getUserInServerId(), pressF.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,19 +4,15 @@ abstracto.systemConfigs.rouletteBullets.longValue=6
|
|||||||
abstracto.systemConfigs.rollDefaultHigh.name=rollDefaultHigh
|
abstracto.systemConfigs.rollDefaultHigh.name=rollDefaultHigh
|
||||||
abstracto.systemConfigs.rollDefaultHigh.longValue=6
|
abstracto.systemConfigs.rollDefaultHigh.longValue=6
|
||||||
|
|
||||||
|
abstracto.systemConfigs.pressFDefaultDurationSeconds.name=pressFDefaultDurationSeconds
|
||||||
|
abstracto.systemConfigs.pressFDefaultDurationSeconds.longValue=90
|
||||||
|
|
||||||
abstracto.featureFlags.entertainment.featureName=entertainment
|
abstracto.featureFlags.entertainment.featureName=entertainment
|
||||||
abstracto.featureFlags.entertainment.enabled=false
|
abstracto.featureFlags.entertainment.enabled=false
|
||||||
|
|
||||||
abstracto.systemConfigs.paydayCredits.name=paydayCredits
|
abstracto.systemConfigs.paydayCredits.name=paydayCredits
|
||||||
abstracto.systemConfigs.paydayCredits.longValue=120
|
abstracto.systemConfigs.paydayCredits.longValue=120
|
||||||
|
|
||||||
# maybe replace this by command cooldowns which are globally on the server, instead of only channel group based
|
|
||||||
abstracto.systemConfigs.paydayCooldown.name=paydayCooldown
|
|
||||||
abstracto.systemConfigs.paydayCooldown.longValue=300
|
|
||||||
|
|
||||||
abstracto.systemConfigs.slotsCooldown.name=slotsCooldown
|
|
||||||
abstracto.systemConfigs.slotsCooldown.longValue=30
|
|
||||||
|
|
||||||
abstracto.featureFlags.economy.featureName=economy
|
abstracto.featureFlags.economy.featureName=economy
|
||||||
abstracto.featureFlags.economy.enabled=false
|
abstracto.featureFlags.economy.enabled=false
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user