Compare commits

..

776 Commits

Author SHA1 Message Date
release-bot
40d66df9b0 [maven-release-plugin] prepare for next development iteration 2024-08-02 20:40:14 +00:00
release-bot
92508d7a1d [maven-release-plugin] prepare release v1.5.41 2024-08-02 20:40:12 +00:00
Sheldan
ccbf6147e9 [AB-xxx] changing github actions image version to a concrete version and upgrading to docker compose 2024-08-02 22:36:04 +02:00
release-bot
a3545c4af0 [maven-release-plugin] prepare for next development iteration 2024-08-02 20:25:03 +00:00
release-bot
fa187f8817 [maven-release-plugin] prepare release v1.5.40 2024-08-02 20:25:00 +00:00
Sheldan
c39b7ebeec [AB-xxx] increasing version due to failed release 2024-08-02 22:22:35 +02:00
release-bot
5cbad801ff [maven-release-plugin] prepare for next development iteration 2024-08-02 20:09:33 +00:00
release-bot
826bee1f81 [maven-release-plugin] prepare release v1.5.39 2024-08-02 20:09:26 +00:00
Sheldan
99bf9a9be0 [AB-xxx] fixed send message action sending for every level change 2024-07-31 00:11:57 +02:00
Sheldan
5b5e4973a7 [AB-117] increasing length of supported reminder text 2024-07-30 21:24:44 +02:00
Sheldan
65e956827c [AB-xxx] adding generic input format exception handling
adding level_action to send a message to a channel once a level is reached
2024-07-27 19:51:49 +02:00
release-bot
b258a8bc54 Commit from GitHub Actions (Publishes a new version of abstracto) 2024-06-13 16:33:09 +00:00
release-bot
9864b7d875 [maven-release-plugin] prepare for next development iteration 2024-06-13 16:21:34 +00:00
release-bot
27466b7333 [maven-release-plugin] prepare release v1.5.38 2024-06-13 16:21:31 +00:00
Sheldan
bfb8969d1f [AB-xxx] fixing passing wrong ID in contact slash command 2024-06-13 18:18:51 +02:00
Sheldan
0097ff801a [AB-xxx] changing hikari max live time 2024-06-12 20:07:55 +02:00
Sheldan
b6a188c04d [AB-xxx] using the suggestion message as the thread starter for suggestion threads 2024-06-03 22:24:35 +02:00
release-bot
2fa1adde02 Commit from GitHub Actions (Publishes a new version of abstracto) 2024-05-30 23:29:17 +00:00
release-bot
cb8b64cc01 [maven-release-plugin] prepare for next development iteration 2024-05-30 23:19:23 +00:00
release-bot
3b3dd0dbb7 [maven-release-plugin] prepare release v1.5.37 2024-05-30 23:19:22 +00:00
Sheldan
388fead2a6 [AB-xxx] typo change
java doc update
removal of todo
2024-05-31 01:14:26 +02:00
Sheldan
336c3d0bd8 [AB-xxx] adding modmail support for ban appeals
refactoring modmail to use user objects instead of member in various places
2024-05-31 01:14:26 +02:00
Sheldan
4991ad8f1c [AB-xxx] making intents, cache policies, and cache flags configurable 2024-05-18 18:22:33 +02:00
Sheldan
c5136a1808 [AB-xxx] removing example implementation repository from readme 2024-05-17 17:34:33 +02:00
release-bot
446d882eec Commit from GitHub Actions (Publishes a new version of abstracto) 2024-05-05 22:24:18 +00:00
release-bot
b3e207a967 [maven-release-plugin] prepare for next development iteration 2024-05-05 22:12:03 +00:00
release-bot
5c25345cf8 [maven-release-plugin] prepare release v1.5.36 2024-05-05 22:12:01 +00:00
Sheldan
a01a5055a0 [AB-xxx] refactoring handling of bans and mutes: commands actively log, the reason for this is that the command is the only place who actually knows how executed the command. the event itself only sees the bot performing the action
adding event based logging of kicks
2024-05-06 00:07:24 +02:00
Sheldan
234aae3783 [AB-xxx] reworking ban logging to use audit log instead of actively logging or using the banned event
partially fixing broken infraction handling
adding CompletableFutureMap to handle futures easier
updating user display object to also hold name
replaced some references to UserObjects in models with UserDisplay objects
2024-05-05 01:58:26 +02:00
Sheldan
ca45137cc6 [AB-xxx] reworking mute logging to use audit log events instead of active logging and member update events 2024-05-04 20:35:56 +02:00
Sheldan
bc3d16b40e [AB-xxx] fixing using the wrong user for unmute notifications 2024-05-03 18:24:10 +02:00
Sheldan
66e212d30c [AB-xxx] updating documentation 2024-05-03 18:07:29 +02:00
Sheldan
b69811479f [AB-xxx] adding more documentation in the moderation area
removing not used feature modes from configuration
2024-04-19 23:57:33 +02:00
Sheldan
43c5d041ef [AB-xxx] adding/updating documentation for core and experience module
updating asciidoctor plugin version
adding check to not allow duplicate level action configurations
limiting experience level up notification toggle command to be only available if the feature mode is enabled
2024-04-18 23:09:56 +02:00
Sheldan
dfe9792330 [AB-xxx] fixing combined parameters not providing the appropriate option types for slash commands 2024-04-13 00:20:02 +02:00
Sheldan
250df57bd0 [AB-xxx] adding tests for command management services
some code improvements
2024-04-07 14:59:22 +02:00
Sheldan
02b8ed2b5d [AB-xxx] adding unit test for server controller
refactoring parameter parsing tests to use assertj
2024-04-07 11:49:06 +02:00
Sheldan
71c1445439 [AB-112] adding command parameter alternatives to bonk/pat to use the message author the command was replied to 2024-04-05 17:30:06 +02:00
release-bot
d86299cdf6 Commit from GitHub Actions (Publishes a new version of abstracto) 2024-04-05 13:22:47 +00:00
release-bot
1b86fba3e0 [maven-release-plugin] prepare for next development iteration 2024-04-05 13:08:51 +00:00
release-bot
3ee7c92cdd [maven-release-plugin] prepare release v1.5.35 2024-04-05 13:08:49 +00:00
Sheldan
6c6cd130aa [AB-xxx] changing types of ids to be string instead for javascript purposes 2024-04-05 15:06:10 +02:00
release-bot
65a1d44069 Commit from GitHub Actions (Publishes a new version of abstracto) 2024-04-05 12:43:58 +00:00
release-bot
11312a5e27 [maven-release-plugin] prepare for next development iteration 2024-04-05 12:29:23 +00:00
release-bot
6b13958ac0 [maven-release-plugin] prepare release v1.5.34 2024-04-05 12:29:20 +00:00
Sheldan
3142daafd3 [AB-xxx] renaming leaderboard url property 2024-04-05 01:58:43 +02:00
Sheldan
4bef78f847 [AB-xxx] adding link to the leaderboard to the leaderboard command response 2024-04-05 01:40:06 +02:00
Sheldan
82be86e086 [AB-xxx] adding locking mechanism for role assignments to work around discord lack of role update locking 2024-04-04 22:54:18 +02:00
Sheldan
bff505ef25 [AB-xxx] fixing not using the ban reason for moderation actions 2024-03-27 23:17:06 +01:00
release-bot
533f5671c2 [maven-release-plugin] prepare for next development iteration 2024-03-27 21:26:56 +00:00
release-bot
8c7547b485 [maven-release-plugin] prepare release v1.5.33 2024-03-27 21:26:54 +00:00
Sheldan
741c194bb8 [AB-xxx] changing styling for smaller screens for member display to truncate the name
prepare for release
2024-03-27 22:24:38 +01:00
release-bot
d2bdfd8dac [maven-release-plugin] prepare for next development iteration 2024-03-26 22:54:50 +00:00
release-bot
36c67fbe20 [maven-release-plugin] prepare release v1.5.32 2024-03-26 22:54:47 +00:00
Sheldan
8fd1aede2a [AB-xxx] changing style of leaderboard table
preparing for release
2024-03-26 23:48:22 +01:00
release-bot
287ae1f0b1 [maven-release-plugin] prepare for next development iteration 2024-03-26 21:40:02 +00:00
release-bot
903361cb58 [maven-release-plugin] prepare release v1.5.31 2024-03-26 21:39:59 +00:00
Sheldan
c8cf412a4a [AB-xxx] changing style of leaderboard table
preparing for release
2024-03-26 22:37:47 +01:00
release-bot
affc249012 [maven-release-plugin] prepare for next development iteration 2024-03-26 21:17:03 +00:00
release-bot
653671ea79 [maven-release-plugin] prepare release v1.5.30 2024-03-26 21:17:00 +00:00
Sheldan
7185908682 [AB-xxx] prepare for release 2024-03-26 22:13:42 +01:00
Sheldan
675da8d5d8 [AB-xxx] adding rank to leaderboard page
changing design of leaderboard page
fixing role not having an id
2024-03-26 22:13:18 +01:00
release-bot
e91becee0d [maven-release-plugin] prepare for next development iteration 2024-03-26 01:10:22 +00:00
release-bot
18732efe75 [maven-release-plugin] prepare release v1.5.29 2024-03-26 01:10:20 +00:00
Sheldan
63897fd914 [AB-xxx] prepare for release 2024-03-26 02:08:06 +01:00
Sheldan
9b865af43b [AB-xxx] fixing not serving static files 2024-03-26 02:07:25 +01:00
release-bot
b78275734c [maven-release-plugin] prepare for next development iteration 2024-03-26 00:36:30 +00:00
release-bot
00a6b0d1f8 [maven-release-plugin] prepare release v1.5.28 2024-03-26 00:36:28 +00:00
Sheldan
13fe6f5e51 [AB-xxx] prepare for release 2024-03-26 01:31:53 +01:00
Sheldan
bc0c3a18d7 [AB-xxx] initial experience leaderboard version 2024-03-26 01:28:56 +01:00
release-bot
8f9b7eba16 Commit from GitHub Actions (Publishes a new version of abstracto) 2024-03-17 12:10:52 +00:00
release-bot
48eacb2e1c [maven-release-plugin] prepare for next development iteration 2024-03-17 12:02:17 +00:00
release-bot
2168814814 [maven-release-plugin] prepare release v1.5.27 2024-03-17 12:02:16 +00:00
Sheldan
972a2829d7 [AB-xxx] updating JDA version 2024-03-17 12:59:16 +01:00
Sheldan
dbf5d99622 [AB-111] adding ability to perform moderation actions on various logging/report messages 2024-03-17 12:37:30 +01:00
Sheldan
f45721ba42 [AB-xxx] fixing schema name for scheduling not being configurable 2024-03-11 22:32:09 +01:00
Sheldan
9034968868 [AB-xxx] only executing level actions if the user changes level 2024-03-01 23:14:13 +01:00
release-bot
bcb9bacea5 [maven-release-plugin] prepare for next development iteration 2024-02-28 20:31:20 +00:00
release-bot
4b922da294 [maven-release-plugin] prepare release v1.5.26 2024-02-28 20:31:18 +00:00
Sheldan
6d90314492 [AB-xxx] prepare for release 2024-02-28 21:27:35 +01:00
Sheldan
93b02d37ed [AB-47] adding feature to define custom actions once members reach a certain level 2024-02-28 21:26:42 +01:00
Sheldan
c11ddd84ab [AB-xxx] adding character replacement to amongus text for ß 2024-02-24 10:41:03 +01:00
Sheldan
518355a68a [AB-xxx] adding creation of release to release job 2024-02-19 01:45:39 +01:00
release-bot
74ebeb4844 [maven-release-plugin] prepare for next development iteration 2024-02-18 23:22:57 +00:00
release-bot
7d872c815c [maven-release-plugin] prepare release v1.5.25 2024-02-18 23:22:55 +00:00
Sheldan
4ebcbeb753 [AB-xxx] prepare for release 2024-02-19 00:20:30 +01:00
Sheldan
53b0c91360 [AB-XXX] replacing packaged xsd for liquibase with reference
using logging module for db and template deployment
updating deployment container dependencies
2024-02-19 00:18:06 +01:00
Sheldan
59575e0b49 [AB-xxx] adding sticky roles module 2024-02-12 22:52:29 +01:00
release-bot
94a18559d3 [maven-release-plugin] prepare for next development iteration 2024-02-09 22:24:13 +00:00
release-bot
b0c90ee8e2 [maven-release-plugin] prepare release v1.5.24 2024-02-09 22:24:11 +00:00
Sheldan
c20c7321ea [AB-xxx] prepare for release 2024-02-09 23:21:38 +01:00
Sheldan
11914d1be5 [AB-xxx] adding check to limit the join duration of users being banned by honeypot 2024-02-09 23:17:12 +01:00
Sheldan
1689fcdae9 [AB-xxx] removing old release workflow 2024-02-04 20:48:26 +01:00
Sheldan
fc887d2f36 [AB-xxx] adding configuration to allow people to click on the honey pot based on an experience level 2024-02-04 20:46:03 +01:00
release-bot
485782ff16 Commit from GitHub Actions (Publishes a new version of abstracto) 2024-02-03 17:00:30 +00:00
release-bot
6460d2c5b7 [maven-release-plugin] prepare for next development iteration 2024-02-03 16:52:12 +00:00
release-bot
e92b7320bd [maven-release-plugin] prepare release v1.5.23 2024-02-03 16:52:10 +00:00
Sheldan
4af47ce086 [AB-xxx] adding manual release pipeline 2024-02-03 17:45:37 +01:00
Sheldan
3f2f3a9c1b [AB-xxx] adding honeypot feature against bots
removing not necessary liquibase xsd from moderation
2024-02-03 15:56:42 +01:00
Sheldan
fe1f03833b [AB-xxx] fixing umlaut handling for amongusText and removing \ 2024-01-24 21:57:56 +01:00
Sheldan
f2522d5a47 [maven-release-plugin] prepare for next development iteration 2024-01-24 08:26:15 +01:00
Sheldan
61450a6a00 [maven-release-plugin] prepare release v1.5.22 2024-01-24 08:26:11 +01:00
Sheldan
05ea4d7dd3 [AB-xxx] prepare for release 2024-01-24 08:20:07 +01:00
Sheldan
71c18f8348 [AB-xxx] adding amongusText image generation 2024-01-24 08:18:36 +01:00
Sheldan
6030904d21 [AB-xxx] fixing not considering allowed mentions for interactions 2023-12-29 15:32:39 +01:00
Sheldan
2fd636a39e [maven-release-plugin] prepare for next development iteration 2023-12-29 00:21:06 +01:00
Sheldan
a94b9293f7 [maven-release-plugin] prepare release v1.5.21 2023-12-29 00:21:02 +01:00
Sheldan
3c4edf5671 [AB-xxx] fixing check in case no wikipedia article was found 2023-12-29 00:19:29 +01:00
Sheldan
f02f1eac4c [maven-release-plugin] prepare for next development iteration 2023-12-28 22:30:45 +01:00
Sheldan
373ed4cde5 [maven-release-plugin] prepare release v1.5.20 2023-12-28 22:30:41 +01:00
Sheldan
5eb9a0e674 [AB-xxx] preparing for release 2023-12-28 22:29:14 +01:00
Sheldan
d4f07bd719 [AB-xxx] adding wikipedia and dictionary features 2023-12-28 22:27:33 +01:00
Sheldan
8924b75530 [AB-xxx] adding check in case the modmail thread has been closed, this is needed because in thread mode one could potentially still execute commands
removing some message command implementations
refactoring the way modmail threads are loaded
2023-12-28 10:57:07 +01:00
Sheldan
25bdc98944 [maven-release-plugin] prepare for next development iteration 2023-12-26 21:04:49 +01:00
Sheldan
062581fce5 [maven-release-plugin] prepare release v1.5.19 2023-12-26 21:04:45 +01:00
Sheldan
be41551529 [AB-xxx] preparing for release 2023-12-26 21:03:11 +01:00
Sheldan
af8206c529 [AB-xxx] adding bonk image generation command
fixing offline streamer handling not being able to handle streamer without current sessions
2023-12-26 15:42:02 +01:00
Sheldan
8efedf6f6f [AB-xxx] renaming pat sprite png 2023-12-25 23:44:43 +01:00
Sheldan
80aff40054 [AB-xxx] adding pat gif generator command 2023-12-25 23:43:34 +01:00
Sheldan
c71f5f004d [AB-xxx] changing displayed user for already existing user in modmail to be the target user 2023-12-25 12:58:47 +01:00
Sheldan
350a634f50 [maven-release-plugin] prepare for next development iteration 2023-12-25 01:07:26 +01:00
Sheldan
f5de74c1e4 [maven-release-plugin] prepare release v1.5.18 2023-12-25 01:07:21 +01:00
Sheldan
6e3809bfd9 [AB-xxx] prepare for release 2023-12-25 01:06:02 +01:00
Sheldan
8e6339a99b [AB-109] fixing streamers not being marked online if the post target is disabled 2023-12-25 01:00:54 +01:00
Sheldan
befef1f61d [AB-xxx] refactoring modmail to offer a feature mode to use threads instead of channels
adding various utilities for thread channels in core
fixing enable feature not showing validation messages
restructuring feature mode collection to be a startup listener, because postconstruct might not have the appropriate values available, and therefore not initialize the map correctly
2023-12-24 23:25:03 +01:00
Sheldan
1f0bc493d9 [maven-release-plugin] prepare for next development iteration 2023-12-23 23:18:06 +01:00
Sheldan
48fa7a99dc [maven-release-plugin] prepare release v1.5.17 2023-12-23 23:18:02 +01:00
Sheldan
d12497753d [AB-xxx] preparing for release 2023-12-23 23:16:39 +01:00
Sheldan
20a6e29f1b [AB-xxx] fixing custom command alternative to filter when it should be executed more accurately 2023-12-23 23:16:01 +01:00
Sheldan
d2231b0934 [maven-release-plugin] prepare for next development iteration 2023-12-23 21:09:36 +01:00
Sheldan
0464afb7db [maven-release-plugin] prepare release v1.5.16 2023-12-23 21:09:32 +01:00
Sheldan
c473ca74d4 [AB-xxx] prepare for release 2023-12-23 21:08:20 +01:00
Sheldan
a70ac5aa94 [AB-xxx] fixing path for env file loading 2023-12-23 21:05:59 +01:00
Sheldan
d10faf4d3d [maven-release-plugin] prepare for next development iteration 2023-12-23 20:45:33 +01:00
Sheldan
a346e1372c [maven-release-plugin] prepare release v1.5.15 2023-12-23 20:45:28 +01:00
Sheldan
9a7c769e8f [AB-xxx] prepare for release 2023-12-23 20:43:57 +01:00
Sheldan
980ca9380c [AB-70] moving image generation functionality to separate image generation module
removing doge image generation from default base
split rest-api into separate modules (base and extensions)
2023-12-23 20:41:25 +01:00
Sheldan
e9d14ac417 [AB-xxx] refactoring rest-api to not be a maven project and restructuring python tool file structure 2023-12-20 21:05:22 +01:00
Sheldan
474e632fed [AB-xxx] adding rest-api base to abstracto with capability to load custom code if necessary 2023-12-19 01:25:07 +01:00
Sheldan
2e5c2c26b9 [maven-release-plugin] prepare for next development iteration 2023-12-12 19:18:51 +01:00
Sheldan
a8ca9a8055 [maven-release-plugin] prepare release v1.5.14 2023-12-12 19:18:46 +01:00
Sheldan
453ccf2e27 [AB-xxx] prepare for release 2023-12-12 19:17:33 +01:00
Sheldan
52c805f4ea [AB-63] adding pressF command
fixing not setting the won flag for giveaway participants
2023-12-11 01:26:07 +01:00
Sheldan
4b3038078e [maven-release-plugin] prepare for next development iteration 2023-12-10 14:32:10 +01:00
Sheldan
af5f9a8361 [maven-release-plugin] prepare release v1.5.13 2023-12-10 14:32:05 +01:00
Sheldan
e84b5ecbb5 [AB-30] adding giveaway feature 2023-12-10 14:25:08 +01:00
Sheldan
1ba8219d7b [AB-xxx] fixing using wrong parameter for unSuggest command 2023-11-15 01:06:30 +01:00
Sheldan
60d2c669a2 [maven-release-plugin] prepare for next development iteration 2023-10-29 18:23:09 +01:00
Sheldan
3a122a72e5 [maven-release-plugin] prepare release v1.5.12 2023-10-29 18:23:03 +01:00
Sheldan
d53126e5a5 [AB-xxx] actively limiting auto complete responses to the max allowed values
changing interface of slash command parameter service to be more applicable
adding utility functions to slash command auto complete service bean
2023-10-29 18:21:29 +01:00
Sheldan
208d9a28ed [maven-release-plugin] prepare for next development iteration 2023-10-23 01:27:29 +02:00
Sheldan
6643359953 [maven-release-plugin] prepare release v1.5.11 2023-10-23 01:27:22 +02:00
Sheldan
bd7149d159 [AB-xxx] prepare for release 2023-10-23 01:26:12 +02:00
Sheldan
c0b6a19bca [AB-82] adding instant for cooldown exception model
removing not needed models for payday and slots cooldown exceptions
2023-10-04 23:34:16 +02:00
Sheldan
58eece0814 [AB-xxx] setting duration to zero if it was not provided, for infraction storage 2023-10-04 22:45:51 +02:00
Sheldan
abfd2c9591 [AB-xxx] ignore slash command only commands for message commands 2023-09-26 23:37:04 +02:00
Sheldan
a71a448b4b [maven-release-plugin] prepare for next development iteration 2023-09-26 22:51:02 +02:00
Sheldan
4d1ce7158f [maven-release-plugin] prepare release v1.5.10 2023-09-26 22:50:58 +02:00
Sheldan
9bbb9430d9 [AB-xxx] preparing for release 2023-09-26 22:49:00 +02:00
Sheldan
a608fba082 [AB-106] renaming deletion days to deletion duration 2023-09-26 00:58:01 +02:00
Sheldan
f97fe42e65 [AB-106] adding ability to specify deletion duration on ban command
removing banDelete command
updating jda version
2023-09-26 00:56:15 +02:00
Sheldan
f12581f322 [AB-xxx] adding information whether a command is slash/message command only to help output
resizing template content column
2023-09-20 02:01:09 +02:00
Sheldan
e8f630c94c [AB-xxx] never using the interaction in echo when a channel is provided 2023-09-09 23:58:31 +02:00
Sheldan
14f35caede [AB-xxx] never using the interaction in echo when a channel is provided 2023-09-09 23:57:23 +02:00
Sheldan
915eb8ced9 [AB-xxx] fixing not limiting custom commands for auto complete 2023-09-08 00:17:43 +02:00
Sheldan
148c10f250 [maven-release-plugin] prepare for next development iteration 2023-09-07 23:30:10 +02:00
Sheldan
74e5154e29 [maven-release-plugin] prepare release v1.5.9 2023-09-07 23:30:05 +02:00
Sheldan
baad696a20 [AB-xxx] adding auto complete to custom command get 2023-09-07 22:57:51 +02:00
Sheldan
b7b5dc7b6a [AB-xxx] fixing installer version 2023-09-07 21:11:22 +02:00
Sheldan
f27f59c0b3 [maven-release-plugin] prepare for next development iteration 2023-09-07 21:10:31 +02:00
Sheldan
ccd7ace8d9 [maven-release-plugin] prepare release v1.5.8 2023-09-07 21:10:26 +02:00
Sheldan
73a73dc4f2 [AB-104] adding server wide member individual command cooldown and commands to set/reset this cooldown configuration on a command level
removing custom cooldown handling from payday and slots commands
2023-09-06 01:23:55 +02:00
Sheldan
156725afa6 [AB-97] adding wind speed to weather command
fixing command failing non gracefully in case the location for weather was not found
2023-09-05 01:44:01 +02:00
Sheldan
b369b56823 [AB-103] adding ability to create/delete/list/retrieve custom commands 2023-09-05 01:22:31 +02:00
Sheldan
7482bf545d [maven-release-plugin] prepare for next development iteration 2023-09-03 13:42:07 +02:00
Sheldan
9804d165ca [maven-release-plugin] prepare release v1.5.7 2023-09-03 13:42:03 +02:00
Sheldan
59ddb0b27d [AB-xxx] fixing random string not set when updating twitch notifications 2023-09-03 13:40:00 +02:00
Sheldan
9aea9d2b4f [AB-xxx] preparing for next release 2023-09-03 01:22:39 +02:00
Sheldan
b042e586a7 [maven-release-plugin] prepare for next development iteration 2023-09-03 00:51:48 +02:00
Sheldan
91e2bea2fc [maven-release-plugin] prepare release v1.5.6 2023-09-03 00:51:44 +02:00
Sheldan
f03bee8b1e [AB-94] adding command to show the state of a server poll 2023-09-03 00:19:35 +02:00
Sheldan
f3144eb094 [AB-99] changing the way roles are added/removed for experience system, as discord has a race condition in which quick additions/removals cause unexpected problems 2023-09-02 22:22:33 +02:00
Sheldan
2396bf300b [AB-101] adding random string to twitch stream preview image to invalidate cache 2023-09-02 21:42:28 +02:00
Sheldan
06ebf4c882 [AB-102] adding redirect to echo command 2023-09-02 21:20:36 +02:00
Sheldan
ff534c03ac [maven-release-plugin] prepare for next development iteration 2023-08-27 22:39:07 +02:00
Sheldan
67c76487e2 [maven-release-plugin] prepare release v1.5.5 2023-08-27 22:39:03 +02:00
Sheldan
9a2f47e244 [AB-xxx] increasing installer version to match abstracto version 2023-08-27 22:37:33 +02:00
Sheldan
2f33d19171 [maven-release-plugin] prepare for next development iteration 2023-08-27 21:46:27 +02:00
Sheldan
f6fc02e758 [maven-release-plugin] prepare release v1.5.4 2023-08-27 21:46:23 +02:00
Sheldan
007929cfa5 [AB-xxx] setting working dir for docker build 2023-08-27 21:45:09 +02:00
Sheldan
77e2eec3d1 [maven-release-plugin] prepare for next development iteration 2023-08-27 21:21:57 +02:00
Sheldan
74c8cf7b6b [maven-release-plugin] prepare release v1.5.3 2023-08-27 21:21:53 +02:00
Sheldan
c8739b90ec [AB-xxx] fixing .env file path 2023-08-27 21:18:57 +02:00
Sheldan
d39a303207 [maven-release-plugin] prepare for next development iteration 2023-08-27 20:58:00 +02:00
Sheldan
3e326fe47e [maven-release-plugin] prepare release v1.5.2 2023-08-27 20:57:55 +02:00
Sheldan
a1d460973c [AB-xxx] removing releaseProfiles 2023-08-27 20:56:02 +02:00
Sheldan
d2475179e6 [AB-xxx] removing duplicate release plugin declaration 2023-08-27 20:54:33 +02:00
Sheldan
5adc304e77 [AB-xxx] fixing release pipeline format 2023-08-27 20:28:39 +02:00
Sheldan
4940577383 [AB-xxx] changing tag format 2023-08-27 19:41:58 +02:00
Sheldan
bba0a2ace6 [AB-xxx] restructuring installer module to be outside of maven
split liquibase and template deployment
adding various features to the deployment images
2023-08-27 19:18:12 +02:00
Sheldan
b7c427026d [AB-xxx] adding serialization for instant and offset datetime for gson payload storage 2023-07-27 20:00:01 +02:00
Sheldan
cee10de915 [maven-release-plugin] prepare for next development iteration 2023-07-22 18:07:17 +02:00
Sheldan
1786231e11 [maven-release-plugin] prepare release abstracto-application-1.5.1 2023-07-22 18:07:13 +02:00
Sheldan
2231fdf289 [AB-xxx] changing class loader helper class, because sometimes the class is not found with the default one 2023-07-22 17:50:19 +02:00
Sheldan
a46e22b5b2 [AB-xxx] also stopping the triggers if a server poll is closed 2023-07-10 20:29:45 +02:00
Sheldan
1c9b9af833 [maven-release-plugin] prepare for next development iteration 2023-07-09 23:13:53 +02:00
Sheldan
3cafc95ceb [maven-release-plugin] prepare release abstracto-application-1.5.0 2023-07-09 23:13:48 +02:00
Sheldan
6409bbaa1d [AB-98] adding twitch support
upgrading to java 17
upgrade of dependencies
2023-07-09 23:06:52 +02:00
Sheldan
346e462185 [AB-xxx] fixing exact temperatures not leading to an appropriate color for weather service 2023-06-22 22:49:47 +02:00
Sheldan
46baa79d3e [maven-release-plugin] prepare for next development iteration 2023-06-04 21:17:29 +02:00
Sheldan
650d062808 [maven-release-plugin] prepare release abstracto-application-1.4.26 2023-06-04 21:17:25 +02:00
Sheldan
bac9832819 [AB-90] adding poll functionality
adding select menu functionality
not automatically acknowledging button interactions
adding ability to define positions for components
adding method to remove components to channel service
always replacing message contents with edit message in a channel
adding ability to reply a modal to a button interaction
moving post target specific methods from server management service to post target management
2023-06-04 21:12:46 +02:00
Sheldan
efbcb5c84b [maven-release-plugin] prepare for next development iteration 2023-05-19 00:27:06 +02:00
Sheldan
fd70e6ac90 [maven-release-plugin] prepare release abstracto-application-1.4.25 2023-05-19 00:27:02 +02:00
Sheldan
29bde70796 [AB-93] fixing setting attached files to null 2023-05-19 00:24:45 +02:00
Sheldan
ecd4feabb2 [maven-release-plugin] prepare for next development iteration 2023-05-18 23:45:59 +02:00
Sheldan
abf60409f1 [maven-release-plugin] prepare release abstracto-application-1.4.24 2023-05-18 23:45:55 +02:00
Sheldan
080733957f [AB-93] fixing not initializing the attached files 2023-05-18 23:43:34 +02:00
Sheldan
8a41f366ae [maven-release-plugin] prepare for next development iteration 2023-05-18 22:53:56 +02:00
Sheldan
dbf478c44c [maven-release-plugin] prepare release abstracto-application-1.4.23 2023-05-18 22:53:52 +02:00
Sheldan
3df688571f [AB-93] changing how MessageToSend handles attached plaintext files 2023-05-18 22:32:56 +02:00
Sheldan
ca530949c6 [AB-92] fixing not providing member display object for modmail thread already exists embed 2023-05-18 01:23:42 +02:00
Sheldan
724930e5a4 [AB-xxx] updating readme
upgrading JDA version to 5.0.0-beta.5
2023-03-20 23:16:52 +01:00
Sheldan
2875da117a [AB-91] adding location id to the available information for weather model 2023-03-19 10:54:54 +01:00
Sheldan
f95ba6c28f [maven-release-plugin] prepare for next development iteration 2023-03-19 00:14:21 +01:00
Sheldan
1b2e7654f9 [maven-release-plugin] prepare release abstracto-application-1.4.22 2023-03-19 00:14:16 +01:00
Sheldan
54976ed1d4 [AB-89] adding command to retrieve weather data 2023-03-19 00:09:43 +01:00
Sheldan
735816f5dd [AB-xxx] adding feature to split field value by configurable amount
using larger images for member avatar
2023-03-05 13:49:32 +01:00
Sheldan
a984bdb84e [AB-86] fixing exception in case of a re-joining user without experience role 2023-02-26 14:16:27 +01:00
Sheldan
21add6585d [maven-release-plugin] prepare for next development iteration 2023-02-26 10:58:01 +01:00
Sheldan
99e72245f3 [maven-release-plugin] prepare release abstracto-application-1.4.21 2023-02-26 10:57:57 +01:00
Sheldan
9d184ff560 [AB-85] adding feature mode to automatically create a thread for suggestions
reworking post target service to function with optionals
fixing trying to add reactions for suggestions if there was no message created
not showing votes in case the buttons feature mode is active
2023-02-26 10:50:36 +01:00
Sheldan
97895f5c56 [AB-84] fixing incorrect calculation for agreement percentage 2023-02-25 18:33:02 +01:00
Sheldan
f091559c49 [AB-84] adding necessary information to suggestion update message 2023-02-25 18:19:01 +01:00
Sheldan
fa7730975e [maven-release-plugin] prepare for next development iteration 2023-02-15 00:05:59 +01:00
Sheldan
03d7b9e2e2 [maven-release-plugin] prepare release abstracto-application-1.4.20 2023-02-15 00:05:51 +01:00
Sheldan
a0bff12263 [AB-xxx] adding default value for user experience object 2023-02-14 23:54:42 +01:00
Sheldan
70e708601e [AB-xxx] exception logging improvements for experience tracking 2023-02-14 21:14:18 +01:00
Sheldan
f01418d0de [AB-xxx] upgrading JDA version to version 5.0.0-beta.3 2023-02-04 20:57:02 +01:00
Sheldan
ad539adb2a [maven-release-plugin] prepare for next development iteration 2023-02-04 18:26:38 +01:00
Sheldan
3c9fec989f [maven-release-plugin] prepare release abstracto-application-1.4.19 2023-02-04 18:26:33 +01:00
Sheldan
21db3e3ee5 [AB-xxx] fixing compatible versions for installer 2023-02-04 18:22:06 +01:00
Sheldan
5b1ad2e075 [maven-release-plugin] prepare for next development iteration 2023-02-04 17:23:34 +01:00
Sheldan
63b3f68bdb [maven-release-plugin] prepare release abstracto-application-1.4.18 2023-02-04 17:23:29 +01:00
Sheldan
7c1537c4a7 Revert "[maven-release-plugin] prepare release abstracto-application-1.4.14"
This reverts commit 9836998087.
2023-02-04 17:21:15 +01:00
Sheldan
9836998087 [maven-release-plugin] prepare release abstracto-application-1.4.14 2023-02-04 17:13:57 +01:00
Sheldan
8a1bb4cad8 [AB-xxx] small installer logging improvement 2023-02-04 17:11:57 +01:00
Sheldan
a9dadec8ef [maven-release-plugin] prepare for next development iteration 2023-02-04 14:52:26 +01:00
Sheldan
3eaffaef87 [maven-release-plugin] prepare release abstracto-application-1.4.17 2023-02-04 14:52:20 +01:00
Sheldan
b3a943e155 [AB-20] adding level up notification configuration possibility 2023-01-28 13:13:38 +01:00
Sheldan
06dd4af131 [maven-release-plugin] prepare for next development iteration 2023-01-12 01:37:16 +01:00
Sheldan
0d51469975 [maven-release-plugin] prepare release abstracto-application-1.4.16 2023-01-12 01:37:12 +01:00
Sheldan
aa10c88588 [AB-81] adding support for choices in slash command parameters 2023-01-12 01:34:30 +01:00
Sheldan
db27f64832 [AB-80] fixing not cleaning up emote record when changing emote 2023-01-10 19:15:27 +01:00
Sheldan
3903039aac [AB-79] fixing test 2022-12-27 13:12:10 +01:00
Sheldan
41f42ee110 [AB-79] fix not applying role for re-joining users upon sync 2022-12-27 13:03:59 +01:00
Sheldan
74f54e1257 [maven-release-plugin] prepare for next development iteration 2022-12-21 13:27:21 +01:00
Sheldan
a72e48f690 [maven-release-plugin] prepare release abstracto-application-1.4.15 2022-12-21 13:27:16 +01:00
Sheldan
a813af8b1f [AB-xxx] fixing issue of not providing percentage to rank correctly 2022-12-21 01:34:32 +01:00
Sheldan
abee7b2732 [AB-xxx] providing more information in the rank model 2022-12-20 22:15:05 +01:00
Sheldan
4c71ffbb7e [maven-release-plugin] prepare for next development iteration 2022-12-10 16:54:36 +01:00
Sheldan
18050e2a8a [maven-release-plugin] prepare release abstracto-application-1.4.14 2022-12-10 16:54:32 +01:00
Sheldan
a0d83763d4 [AB-78] fixing users with previous experience not awarding the experience role if they join and are pending 2022-12-10 15:44:09 +01:00
Sheldan
0461c8e4ec [AB-77] deferring the reply for report with context interactions
do not defer the interaction all the time for modal interactions
2022-12-10 12:59:47 +01:00
Sheldan
072f32975a [maven-release-plugin] prepare for next development iteration 2022-12-03 20:17:11 +01:00
Sheldan
6810d28c50 [maven-release-plugin] prepare release abstracto-application-1.4.13 2022-12-03 20:16:57 +01:00
Sheldan
650a9099c4 [AB-66] fixing not reducing the bid on mines
fixing reaction report sometimes running into a timeout
2022-12-03 20:14:18 +01:00
Sheldan
1217e03725 [maven-release-plugin] prepare for next development iteration 2022-12-02 21:20:57 +01:00
Sheldan
2e837d8738 [maven-release-plugin] prepare release abstracto-application-1.4.12 2022-12-02 21:20:53 +01:00
Sheldan
9ddd386c6f [AB-66] adding min mines ratio and other input restrictions for mines game which should avoid some too easy setups 2022-12-02 21:16:32 +01:00
Sheldan
4e1db26df7 [AB-xxx] fixing java version in build file 2022-12-02 01:58:48 +01:00
Sheldan
de335a1e2a [AB-xxx] updating versions of GitHub actions in release/build job 2022-12-02 01:55:36 +01:00
Sheldan
9ba0ed711e [maven-release-plugin] prepare for next development iteration 2022-12-02 01:36:51 +01:00
Sheldan
b7376bf522 [maven-release-plugin] prepare release abstracto-application-1.4.11 2022-12-02 01:36:46 +01:00
Sheldan
0d6182c5d5 [AB-66] adding mines game
fixing suggestion evaluation job not getting the correct parameters
adding feature dependent parameters
2022-12-02 01:33:38 +01:00
Sheldan
96c38763b1 [maven-release-plugin] prepare for next development iteration 2022-11-20 23:22:21 +01:00
Sheldan
97b3099156 [maven-release-plugin] prepare release abstracto-application-1.4.10 2022-11-20 23:22:16 +01:00
Sheldan
a0b2fc9c31 [AB-25] artificial delay 2022-11-20 23:20:07 +01:00
Sheldan
2db36ef96b [maven-release-plugin] prepare for next development iteration 2022-11-20 22:39:40 +01:00
Sheldan
08b3913b04 [maven-release-plugin] prepare release abstracto-application-1.4.9 2022-11-20 22:39:36 +01:00
Sheldan
7a7ec5654f [AB-25] changing member loading to be partitioned 2022-11-20 22:37:10 +01:00
Sheldan
74679c2ccc [maven-release-plugin] prepare for next development iteration 2022-11-20 19:53:42 +01:00
Sheldan
063581ba1a [maven-release-plugin] prepare release abstracto-application-1.4.8 2022-11-20 19:53:38 +01:00
Sheldan
5c7b018b2a [AB-25] refactoring experience collection to work instantly instead of delayed job
adding level up notification for experience
2022-11-20 19:49:34 +01:00
Sheldan
d315113395 [AB-76] adding evaluation job for suggestions 2022-11-11 00:06:16 +01:00
Sheldan
ea2f62b721 [AB-74] adding more information to output of transfer credits command 2022-11-09 22:53:36 +01:00
Sheldan
1a91275a2d [maven-release-plugin] prepare for next development iteration 2022-10-27 20:56:03 +02:00
Sheldan
e76b22ca59 [maven-release-plugin] prepare release abstracto-application-1.4.7 2022-10-27 20:55:58 +02:00
Sheldan
5a21f9642c [CCR] fixing order of execution for updating suggestion
using edit components instead of full message edit in message service bean
2022-10-27 20:49:36 +02:00
Sheldan
e3dd89b0ef [AB-75] adding thread reader command 2022-10-22 14:55:18 +02:00
Sheldan
4fe81c0ea2 [maven-release-plugin] prepare for next development iteration 2022-10-16 13:24:50 +02:00
Sheldan
ab55f5ee07 [maven-release-plugin] prepare release abstracto-application-1.4.6 2022-10-16 13:24:46 +02:00
Sheldan
92cec30898 [AB-xx] fixing version 2022-10-16 13:22:38 +02:00
Sheldan
3a40ccccda [maven-release-plugin] prepare release abstracto-application-1.4.5 2022-10-16 13:19:35 +02:00
Sheldan
e6802a0851 [AB-xx] fixing javadoc 2022-10-16 13:16:50 +02:00
Sheldan
ce90370b9c [maven-release-plugin] prepare for next development iteration 2022-10-16 12:04:14 +02:00
Sheldan
b21afce1ad [maven-release-plugin] prepare release abstracto-application-1.4.5 2022-10-16 12:04:10 +02:00
Sheldan
58fd11a561 [AB-xx] upgrade to JDA 5.0.0-alpha.21 2022-10-16 12:02:10 +02:00
Sheldan
3e38085a25 [AB-xx] upgrade to JDA 5.0.0-alpha.21 2022-10-16 11:54:23 +02:00
Sheldan
48f62f8bdf [AB-xx] make close log by default 2022-10-08 11:39:55 +02:00
Sheldan
ad92ccd181 [AB-71] adding cache flag to cached message 2022-10-06 00:34:22 +02:00
Sheldan
8ab0eaedda [AB-73] refactoring reminder notification model to not use entities 2022-10-06 00:10:32 +02:00
Sheldan
e2a7d3b9e8 [AB-72] adding joined reminders to list of reminders
refactored reminder display to not use entities
2022-10-06 00:01:48 +02:00
Sheldan
8c101793a3 [AB-8] fixing test 2022-09-18 16:00:38 +02:00
Sheldan
4e1f9e0018 [AB-8] upgrading to new JDA alpha version 19
cleaning up imports
2022-09-18 15:51:49 +02:00
Sheldan
102209aaca [maven-release-plugin] prepare for next development iteration 2022-09-02 15:48:29 +02:00
Sheldan
9a64da480b [maven-release-plugin] prepare release abstracto-application-1.4.4 2022-09-02 15:48:25 +02:00
Sheldan
11c36691ce [AB-xx] fixing reaction reports being stored when they should not be 2022-09-02 15:41:18 +02:00
Sheldan
337ef87e47 [maven-release-plugin] prepare for next development iteration 2022-08-28 23:30:52 +02:00
Sheldan
056a7fe297 [maven-release-plugin] prepare release abstracto-application-1.4.3 2022-08-28 23:30:47 +02:00
Sheldan
82383449c0 [AB-55] fixing custom command not considering feature flag
ignoring case for custom command
2022-08-28 23:24:08 +02:00
Sheldan
30655dbfef [AB-65] adding ability to join a reminder via button 2022-08-28 23:13:40 +02:00
Sheldan
a43725df39 [AB-69] adding additional info to userInfo command 2022-08-27 14:44:46 +02:00
Sheldan
9a0bff154b [AB-67] adding missing tracking trigger for infraction parameter 2022-08-25 00:41:37 +02:00
Sheldan
4d54b11400 [AB-68] adding message context menu and slash command for mock 2022-08-25 00:33:14 +02:00
Sheldan
9c621954c8 adding more logging for lash command exceptions 2022-08-19 15:56:23 +02:00
Sheldan
f24552fdf2 [maven-release-plugin] prepare for next development iteration 2022-08-01 23:02:25 +02:00
Sheldan
e643080516 [maven-release-plugin] prepare release abstracto-application-1.4.2 2022-08-01 23:02:20 +02:00
Sheldan
b747516881 fixing command alternatives being required
fixing filename for export emote stats
fixing reaction report message update
2022-08-01 22:59:48 +02:00
Sheldan
0a4238c9f5 [maven-release-plugin] prepare for next development iteration 2022-07-27 22:20:45 +02:00
Sheldan
99fe84914b [maven-release-plugin] prepare release abstracto-application-1.4.1 2022-07-27 22:20:41 +02:00
Sheldan
f9b85feeaf enabling auto complete for youtube command 2022-07-27 22:13:48 +02:00
Sheldan
51edb50eee fixing null handling for server channel message 2022-07-25 19:13:39 +02:00
Sheldan
43a78a4989 [AB-8] adding slash command and message context commands to metrics 2022-07-25 18:23:44 +02:00
Sheldan
e3e0ad98ba [maven-release-plugin] prepare for next development iteration 2022-07-23 10:33:34 +02:00
Sheldan
9c02be7299 [maven-release-plugin] prepare release abstracto-application-1.4.0 2022-07-23 10:33:31 +02:00
Sheldan
9954515db0 [AB-53] adding economy related commands
adding runtime exception to root command handling
adding simple custom command module
disabling slash command for show emote the utility is not given (the bot cannot show any emotes from servers its not in)
fixing post target setup not allowing threads
fixing post targets not supporting threads
fixing interactions not considering the actual amount of embeds
fixing some cases for events which are not in a guild
2022-07-23 10:20:41 +02:00
Sheldan
68cae74819 [AB-52] upgrading to alpha 12
adding anonymous reporting
reworking message context commands
refactoring interaction packages
adding post execution handling for message context commands and modals
reworking feature mode response
fixing setup using component ids
storing infraction parameters, for example mute duration, with every infraction
adding infractions for more moderation actions
creating general method to format a duration string
adding infractions command
reworking muting to use built-in functionality of discord
enabling chunking of members
removing manual unmuting feature mode
adding ability to update infractions with a command
implemented infraction listeners for ban and warn
refactored infraction notifications
storing log messages to the infraction for editing said log messages
2022-07-18 21:52:12 +02:00
Sheldan
1a1fde0800 [AB-11] fixing still considering bots when calculating the star amount
fixes #11
2022-06-21 00:15:47 +02:00
Sheldan
74cee39f1a [AB-12] fixing not ignoring ignored starboard posts in starstats
fixes #12
2022-06-20 23:50:39 +02:00
dependabot[bot]
5ad3e30cc1 Bump gson from 2.8.6 to 2.8.9 in /abstracto-application
Bumps [gson](https://github.com/google/gson) from 2.8.6 to 2.8.9.
- [Release notes](https://github.com/google/gson/releases)
- [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/gson/compare/gson-parent-2.8.6...gson-parent-2.8.9)

---
updated-dependencies:
- dependency-name: com.google.code.gson:gson
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-20 23:35:23 +02:00
Sheldan
c02bf4aa8e [AB-10] attempt to fix the race condition when creating a starboard post
fixes #10
2022-06-20 23:32:33 +02:00
Sheldan
c84a76b6a3 [maven-release-plugin] prepare for next development iteration 2022-06-20 00:20:23 +02:00
Sheldan
120df02dd0 [maven-release-plugin] prepare release abstracto-application-1.4.0.RC2 2022-06-20 00:20:18 +02:00
Sheldan
61f43f6bc9 [AB-365] javadoc fixes 2022-06-20 00:18:26 +02:00
Sheldan
982cbb82d7 [maven-release-plugin] prepare for next development iteration 2022-06-20 00:11:37 +02:00
Sheldan
b4627d1ab0 [maven-release-plugin] prepare release abstracto-application-1.4.0.RC1 2022-06-20 00:11:32 +02:00
Sheldan
1d6de3f1e8 [AB-365] introducing slash commands for a selection of commands
adding method for pinning a message
moving suggestion to correct deployment
2022-06-20 00:03:30 +02:00
Sheldan
1913bc930d [AB-xxx] adding issue templates 2022-05-29 23:51:26 +02:00
Sheldan
09450429dd [AB-358] upgrading to JDA 5
removal of jda-utils
adding message context commands
[AB-360] fixing confirmation buttons being triggered by somebody not the author
2022-05-17 00:27:30 +02:00
Sheldan
17470f9718 [maven-release-plugin] prepare for next development iteration 2022-05-15 17:38:21 +02:00
Sheldan
91a23f870c [maven-release-plugin] prepare release abstracto-application-1.3.13 2022-05-15 17:38:18 +02:00
Sheldan
b047d3eb49 [AB-xxx] adding another autoload macro for templates 2022-05-15 14:02:17 +02:00
Sheldan
db5b420f0a [maven-release-plugin] prepare for next development iteration 2022-04-07 22:27:00 +02:00
Sheldan
a7e60f6338 [maven-release-plugin] prepare release abstracto-application-1.3.12 2022-04-07 22:26:55 +02:00
Sheldan
eed90c1406 [AB-360] fixing warnings not being stored in case the message was not deliverable 2022-04-07 22:07:35 +02:00
Sheldan
78027ee980 [maven-release-plugin] prepare for next development iteration 2022-02-12 11:37:13 +01:00
Sheldan
e35071d8d5 [maven-release-plugin] prepare release abstracto-application-1.3.11 2022-02-12 11:37:08 +01:00
Sheldan
14865a32f2 [AB-xxx] fixing year 2022-02-12 11:34:41 +01:00
Sheldan
ae3c66384f [AB-xxx] not requiring async voice channel listeners
fixing duplicated error reporting for command received handler
2022-02-10 23:05:35 +01:00
Sheldan
986b65a1e4 [AB-347] adding support for multiple and generic attachments to modmail
fixing editing messages with multiple embeds
fixing message limit also bein imposed on pure embed count
2021-12-25 16:29:23 +01:00
Sheldan
cc898b27bb [AB-353] reducing chance of concurrent modification exception when registering a new metric on the fly 2021-12-25 10:53:55 +01:00
Sheldan
9ce07a1a4a [AB-352] removing conversion tests 2021-12-24 23:49:26 +01:00
Sheldan
ee01a3f07c [AB-352] adding caching to the loading of members for warnings/user notes/mutes. this becomes relevant as members which left the guild are not cached by jda, which means, we retry it again
improved models for templates to simplify the objects passed
2021-12-24 23:41:27 +01:00
Sheldan
9230a13218 [maven-release-plugin] prepare for next development iteration 2021-12-24 13:47:56 +01:00
Sheldan
c248351721 [maven-release-plugin] prepare release abstracto-application-1.3.10 2021-12-24 13:47:52 +01:00
Sheldan
b0376778fe [AB-xxx] adding utility function to change color of a role 2021-12-24 13:44:57 +01:00
Sheldan
7f5d17e4dc [AB-349] supporting multiple embeds in templating mechanism
fixing paginator without embeds
2021-12-08 16:26:11 +01:00
Sheldan
0e7ea25aef [AB-291] refactoring pagination to custom button pagination
adding mutes command
fixing edit message not considering components
reversing the origin comparison in a few button click listeners
fixing ordering of warnings and mutes from converter
2021-12-01 23:22:46 +01:00
Sheldan
f2aa7035aa [AB-307] enabling dependent features and including them into the setup wizard
this comes with the usual limitation, that dependent features must be referenced via importing
2021-11-28 13:19:17 +01:00
Sheldan
c10296251c [AB-327] adding a third state to the result of a system condition: Ignored, this means that the condition was not evaluated, and is neither true nor false, this is for example used when the feature the condition is about is disabled
adding server ID to has level condition parameters
2021-11-27 22:08:12 +01:00
Sheldan
15fb9d95a8 [AB-343] fixing link buttons not being properly supported in templates 2021-11-23 19:57:16 +01:00
Sheldan
79633d7a8e [AB-341] fixing unSuggest not working correctly in case there are votes on the suggestion 2021-11-20 11:44:07 +01:00
Sheldan
cef46737c5 [AB-170] adding emote stat command for single emote
fixing naming of fields in show tracked emotes
2021-10-27 00:25:10 +02:00
Sheldan
c7076795a2 [AB-340] fixing test 2021-10-26 13:59:48 +02:00
Sheldan
9e1527ccd1 [AB-340] adding timestamp support for serverInfo command 2021-10-26 13:53:13 +02:00
Sheldan
326d488059 [maven-release-plugin] prepare for next development iteration 2021-10-25 23:20:39 +02:00
Sheldan
a39b6695a6 [maven-release-plugin] prepare release abstracto-application-1.3.9 2021-10-25 23:20:31 +02:00
Sheldan
362d87778e [AB-339] repurposing the softban command for a ban command with deletion days 2021-10-25 01:11:32 +02:00
Sheldan
0514d355c7 [AB-167] adding warning created events and infraction counter
adding disabling of post targets
adding some logging for message sending failure consumer
2021-10-25 00:04:08 +02:00
Sheldan
8909e8ebe5 [AB-333] providing some dates as separate instants instead of relying on the member attributes
truncating date to day when displaying the date for export emote stats
fixing wrong message when confirming a command and adding missing exception handling
2021-10-14 01:31:52 +02:00
Sheldan
36ca9b11e4 [AB-334] adding vote result to suggestion reminder 2021-10-13 18:00:54 +02:00
Sheldan
4a66b7fc67 [AB-331] showing separate notifications for the decision on a suggestion 2021-09-28 22:20:11 +02:00
Sheldan
b2a94059e2 [AB-332] showing separate message in case there are no warnings 2021-09-28 22:05:51 +02:00
Sheldan
16e6caa1f0 [AB-196] adding confirmation requirement to various commands
refactoring command received handler in order to re-use when confirmation has been given
removing reaction from showSuggestion and remind command
adding log message for message deleted message, in case the member left
all commands from now on must work without the member field from the message, as this is not available when retrieving the message
2021-09-27 00:22:37 +02:00
Sheldan
da1a71ecdc [AB-319] splitting emotes into two separate fields (animated and static) for server info
adding emote display model
2021-09-10 00:41:15 +02:00
Sheldan
0646efe33d [AB-163] fixing printing all possible feature modes in case an unknown one was provided for enableMode/disableMode 2021-09-10 00:21:30 +02:00
Sheldan
db856f2647 [AB-xxx] improving documentation 2021-09-09 02:20:45 +02:00
Sheldan
1d85eb1e7e [AB-297] adding server names to invite deletion log (if available) 2021-09-08 23:04:35 +02:00
Sheldan
5e6999cd45 [AB-328] fixing case sensitivity of allowed invite links 2021-09-07 01:13:34 +02:00
Sheldan
9659a3487a [maven-release-plugin] prepare for next development iteration 2021-09-06 01:54:00 +02:00
Sheldan
6d27c487f2 [maven-release-plugin] prepare release abstracto-application-1.3.8 2021-09-06 01:53:55 +02:00
Sheldan
8ac3b327e4 [AB-268] adding button feature mode to suggestions which allows for hidden suggestion votes
moving gateway metric to separate service in case JDA is not ready yet
2021-09-06 01:39:27 +02:00
Sheldan
448332f24f [AB-318] adding a mention of the original message to link embed
updating JDA version
2021-09-04 16:30:16 +02:00
Sheldan
d7f889971d [AB-325] adding async command conditions - as this is required for some conditions
adding user parameter to immune user condition evaluation
2021-09-04 13:47:03 +02:00
Sheldan
69abff77fb [AB-xxx] fixing test 2021-08-21 16:05:01 +02:00
Sheldan
2c31fa1c1e [AB-xxx] not always creating a user instance in the experience listener
adding logging in case the warn decay notification fails
2021-08-21 15:50:11 +02:00
Sheldan
19a4858da1 [AB-323] improving logging when using whenComplete 2021-08-14 12:15:18 +02:00
Sheldan
3ed1f0c54a [AB-322] adding possibility to define a max age in days for messages to be eligible for stars 2021-08-14 09:45:25 +02:00
Sheldan
d01e46a9a6 [AB-xxx] fixing modmail sometimes failing to log messages 2021-08-14 08:02:04 +02:00
Sheldan
222250b795 [AB-321] changing caching policy
changing logging messages
2021-08-14 08:00:40 +02:00
Sheldan
9a87b75998 [maven-release-plugin] prepare for next development iteration 2021-08-09 23:52:49 +02:00
Sheldan
b16cef0d3c [maven-release-plugin] prepare release abstracto-application-1.3.7 2021-08-09 23:52:40 +02:00
Sheldan
cc55934ff2 [AB-xxx] fixing not removing component payloads for message embed cleanup job 2021-08-09 00:40:36 +02:00
Sheldan
168b4a52c8 [AB-xxx] changing some exception logging
fixing moderator member not re-used for reply command
2021-08-09 00:11:49 +02:00
Sheldan
73b5684a7e [maven-release-plugin] prepare for next development iteration 2021-07-26 01:37:38 +02:00
Sheldan
23ba9a88aa [maven-release-plugin] prepare release abstracto-application-1.3.6 2021-07-26 01:37:31 +02:00
Sheldan
a5664946e1 [AB-xxx] hotfix for component payload 2021-07-26 01:30:47 +02:00
Sheldan
ec16548cea [maven-release-plugin] prepare for next development iteration 2021-07-25 20:28:46 +02:00
Sheldan
9c9082034a [maven-release-plugin] prepare release abstracto-application-1.3.5 2021-07-25 20:28:37 +02:00
Sheldan
1486a0e9c3 [AB-314] forcing modmail messages being logged in certain order 2021-07-25 20:17:32 +02:00
Sheldan
533f1afcd5 [AB-313] removing restriction to string parameter for combined parameters 2021-07-25 17:28:42 +02:00
Sheldan
a6c3bb5aa2 [AB-313] ignoring referenced message parameter in parameter handler if not needed 2021-07-25 17:27:32 +02:00
Sheldan
5311cfcc2e [AB-xxx] fixing not showing assignable role actions in metrics 2021-07-25 15:18:54 +02:00
Sheldan
ee7f9180dc [AB-xxx] adding JDA metrics for all events
adding support to template environment variables in liquibase configuration
removing not needed column from component payload
2021-07-25 15:17:27 +02:00
Sheldan
3f67593ef4 [maven-release-plugin] prepare for next development iteration 2021-07-21 23:34:33 +02:00
Sheldan
0ccee3b211 [maven-release-plugin] prepare release abstracto-application-1.3.4 2021-07-21 23:34:25 +02:00
Sheldan
86b9ccb164 [AB-300] adding ability to determine the channel names for modmail 2021-07-21 01:38:04 +02:00
Sheldan
bc1eb0b55f [AB-305] fixing not correctly persisting removal of an assignable role from an assignable role place 2021-07-21 00:46:11 +02:00
Sheldan
92a8b5ba64 [AB-311] adding softban command 2021-07-20 02:02:42 +02:00
Sheldan
7535b2e66d [AB-xxx] make ban reason mandatory 2021-07-18 19:29:58 +02:00
Sheldan
7117ac26d3 [AB-308] adding a separate type for assignable role places to enable booster only places
adding more detailed logging to assignable roles
adding some fall through logic to the banned listener to always log at least the basic information
refactoring some command structure for showing configuration, so the command actually executes the message response
fixing potential exception case for starboard updates causing the message ID to not be persisted
2021-07-18 19:20:14 +02:00
Sheldan
32056cd6b9 [maven-release-plugin] prepare for next development iteration 2021-07-14 02:17:57 +02:00
Sheldan
efd6c23713 [maven-release-plugin] prepare release abstracto-application-1.3.3 2021-07-14 02:17:48 +02:00
Sheldan
794fc7ceac [AB-71] adding very simple anti raid feature to automatically mute member who mass mention users 2021-07-14 01:48:53 +02:00
Sheldan
6b5a255aa8 [maven-release-plugin] prepare for next development iteration 2021-07-13 01:19:43 +02:00
Sheldan
620ef0708a [maven-release-plugin] prepare release abstracto-application-1.3.2 2021-07-13 01:19:35 +02:00
Sheldan
3564075e7f [AB-xxx] fixing javadoc build 2021-07-13 01:13:58 +02:00
Sheldan
de5ac0e3f4 [maven-release-plugin] prepare for next development iteration 2021-07-13 00:56:29 +02:00
Sheldan
419ac3f994 [maven-release-plugin] prepare release abstracto-application-1.3.1 2021-07-13 00:56:20 +02:00
Sheldan
ac605e4791 [AB-303] adding scheduled configurable activity updates 2021-07-13 00:35:15 +02:00
Sheldan
c7514a6bad [AB-64] adding voice context channel feature 2021-07-12 00:56:15 +02:00
Sheldan
7e7591a4b3 [AB-302] refactoring assignable roles to use buttons instead of reactions
moved button related services to component service instead of message service
adding component type to component payload
renamed async role service methods
ignoring bot reactions in starboard
fixing rank not showing correct experience to next level for other members
2021-07-11 19:05:53 +02:00
Sheldan
c08134a150 [maven-release-plugin] prepare for next development iteration 2021-07-04 13:39:29 +02:00
Sheldan
c26bcc9a66 [maven-release-plugin] prepare release abstracto-application-1.3.0 2021-07-04 13:39:22 +02:00
Sheldan
bc276c0b12 [AB-299] fixing incorrect handling of ban notifications 2021-07-04 13:00:36 +02:00
Sheldan
18929c9a01 [AB-298] fixing various issues related to modmail:
fixing editing a message without messages but only embeds not possible in channel service
refactoring closing parameters to use an object instead of parameters always
adding a progress indicator to closing a modmail thread
adding a notification to contact in order to show where the thread was created
fixing configuration for category (this caused the setup to fail, because there was no default value) and threadMessage feature modes not being correct
refactored model for closing header and added additional information
refactored modmail message logging to use the message history instead of individually loading the messages
adding nicer exception in case the mod mail message update failed
adding creation of AUserInAServer in case the user did not interact on the server yet
changed ID of modmail thread to be identical to the channel it was created in, this is so we can load the channel easier
2021-07-04 12:14:04 +02:00
Sheldan
61eefd53c3 [AB-296] adding support for buttons
adding buttons for message embed via feature mode
2021-07-03 10:40:27 +02:00
Sheldan
bbc5918d88 [AB-xxx] upgrading to newer JDA version 2021-06-27 22:47:10 +02:00
Sheldan
67121b318d [AB-271] fixing tests 2021-06-27 19:57:38 +02:00
Sheldan
5a35137132 [AB-271] limiting certain arguments for commands to require the same server 2021-06-27 17:07:01 +02:00
Sheldan
e655adf95e [AB-295] adding hard limitations for field values, names, embed description and additional message lengths 2021-06-27 16:05:40 +02:00
Sheldan
ebf659fb14 [maven-release-plugin] prepare for next development iteration 2021-06-27 00:45:18 +02:00
Sheldan
8ef236ba19 [maven-release-plugin] prepare release abstracto-application-1.2.17 2021-06-27 00:45:09 +02:00
Sheldan
7e2477a321 [AB-xxx] adding support for automatic setup steps
reducing eventwaiter threads
adding abstracto templated exception
adding json validation service
increasing threads for scheduling
adding convenience method to retrieve users
2021-06-27 00:20:15 +02:00
Sheldan
942a20700e [AB-294] fixing test 2021-06-21 21:51:12 +02:00
Sheldan
0d25b9c384 [AB-294] fixing unmuting not cached members
adding logging and catches for unbanned listener
2021-06-21 21:47:23 +02:00
Sheldan
d5f572262f [AB-287] fixing members not being available breaking warning display converter 2021-06-09 12:56:01 +02:00
Sheldan
2c3b5fb651 [AB-290] fixing showing wrong active warning count in warn decay notification
fixing un mute log failing to render in case the mute did not come from a message
fixing notification failing with exception in case there were no warnings to decay
2021-06-09 12:18:36 +02:00
Sheldan
ba4d8f1da6 [AB-293] fixing wrong emote for 18 character 2021-06-09 12:02:37 +02:00
Sheldan
cd625a8907 [AB-292] fixing post target for suggestion reminder 2021-06-09 11:58:59 +02:00
Sheldan
51a835df06 [maven-release-plugin] prepare for next development iteration 2021-06-02 12:50:09 +02:00
Sheldan
78e226aa4c [maven-release-plugin] prepare release abstracto-application-1.2.16 2021-06-02 12:49:59 +02:00
Sheldan
82281cbd6c [AB-285] fixing interval of warn decay job
removing has example config from unban
enabling to change the configuration for cron scheduler job
adding HTTP method to okhttp logger
fixing unmute job parameters
changing to use cache when retrieving reactions for a message to cache it
2021-06-02 12:27:10 +02:00
Sheldan
432dc0ffae [maven-release-plugin] prepare for next development iteration 2021-06-02 00:45:59 +02:00
Sheldan
89a3afd10e [maven-release-plugin] prepare release abstracto-application-1.2.15 2021-06-02 00:45:51 +02:00
Sheldan
793a1c3657 [AB-284] resizing warn length and changing default date behaviour for mute 2021-06-02 00:36:36 +02:00
Sheldan
7fdb87ef1f [AB-284] adding warn decay notification
adding default mute reason
fixing incorrect muting user being stored
2021-06-01 23:38:06 +02:00
Sheldan
2f8e7c3947 [AB-282] adding okhttp interceptor to log requests 2021-06-01 21:44:03 +02:00
Sheldan
3bf761a2e5 [AB-281] adding ban and unban command
removing banId command in favor of the normal ban command
removing various feature modes for moderation for clearer configuration
2021-06-01 21:10:17 +02:00
Sheldan
55e0879e06 [AB-277] adding report mechanism via reactions 2021-05-30 21:00:49 +02:00
Sheldan
d69f597663 [AB-279] extending max level for experience gain to 150 2021-05-30 20:00:06 +02:00
Sheldan
148c25da4c [AB-275] fixing channel groups not being able to be found, because of upper/lowercase
adding performance improvements for experience listener
adding logging to when a user gains a level
fixing creating a user experience instance in the join listener, which was not persisted
2021-05-29 01:09:14 +02:00
Sheldan
f3bb9b9a69 [AB-276] enabling to cache more members in JDA to reduce requests 2021-05-29 00:56:02 +02:00
Sheldan
0366d48764 [maven-release-plugin] prepare for next development iteration 2021-05-26 21:51:42 +02:00
Sheldan
118b4c0e5d [maven-release-plugin] prepare release abstracto-application-1.2.14 2021-05-26 21:51:33 +02:00
Sheldan
95a639a733 [AB-272] improving leaderboard performance
fixing leaderboard returning wrong pages
making template cache update duration longer
2021-05-26 21:41:04 +02:00
Sheldan
919b52a607 [maven-release-plugin] prepare for next development iteration 2021-05-26 14:48:13 +02:00
Sheldan
a9229d4b28 [maven-release-plugin] prepare release abstracto-application-1.2.13 2021-05-26 14:48:06 +02:00
Sheldan
47ce03ac25 [AB-xxx] fixing version 2021-05-26 14:37:57 +02:00
Sheldan
cef96515aa Revert "[maven-release-plugin] prepare release abstracto-application-1.3.13"
This reverts commit 072d680e
2021-05-26 14:16:21 +02:00
Sheldan
23ac70bb69 [maven-release-plugin] prepare for next development iteration 2021-05-26 13:52:20 +02:00
Sheldan
072d680e2f [maven-release-plugin] prepare release abstracto-application-1.3.13 2021-05-26 13:52:11 +02:00
Sheldan
04b3e073aa [AB-270] fixing test 2021-05-26 11:51:45 +02:00
Sheldan
08e2a31f15 [AB-270] adding a channel group to define the channels in which experience gain is disabled
adding a service method to enable migration
2021-05-26 11:29:34 +02:00
Sheldan
184271ff7c [AB-247/AB-252] fixing issue with set experience role failing to consider the correct experience roles
adding levelRoles command
ignoring bots from experience gain
adding a bit more logging to user experience handling
2021-05-26 01:22:37 +02:00
Sheldan
c4fe73b3f8 [AB-251] adding optional member parameter to rank command to show the rank of another member 2021-05-25 00:24:07 +02:00
Sheldan
2dc73ef3b9 [AB-267] fixing some combinations of reaction characters being ignored 2021-05-24 19:05:41 +02:00
Sheldan
2dd02cdae8 [AB-266] fixing online status and activity not showing up in userinfo 2021-05-24 18:32:41 +02:00
Sheldan
d39ee4359f [AB-231] fixing parameter letting less than required commands to the commands, in case the parameters were not able to be parsed (expected emote got string), the check for parameter count as only done before actually parsing the parameters 2021-05-24 18:16:39 +02:00
Sheldan
d7cc7f579f [AB-254] fixing exception for unSuggest in case the suggestion message has been deleted 2021-05-24 17:53:58 +02:00
Sheldan
7d30afbd2c [AB-262] adding feature mode to suggestion to be automatically reminded of a suggestion after a configurable amount of time 2021-05-24 17:39:19 +02:00
Sheldan
f4c1dcb27f [maven-release-plugin] prepare for next development iteration 2021-05-23 23:26:29 +02:00
Sheldan
fda5262df0 [maven-release-plugin] prepare release abstracto-application-1.2.12 2021-05-23 23:26:21 +02:00
Sheldan
dc2479889a [AB-xxx] making regex checks ignore case 2021-05-23 23:17:29 +02:00
Sheldan
1fbd494590 [AB-xxx] fixing issues related to emote tracking 2021-05-23 22:27:52 +02:00
Sheldan
9dc1d73507 [AB-264] fixing profanity filter not considering message edits 2021-05-23 17:10:54 +02:00
Sheldan
23af59ab9d [AB-261] fixing invite filter only acting in the message received event 2021-05-23 16:45:36 +02:00
Sheldan
13a6e1fdca [AB-263] adding stricter not null checks to database, disabling updates/inserts for created and updated columns to only rely on triggers 2021-05-23 14:17:03 +02:00
Sheldan
04a7cfafd7 [AB-84] adding profanity filter with different feature modes
react command: adding additional mapping for character r
2021-05-16 23:44:50 +02:00
Sheldan
eca9e6ebf7 [AB-258] improving handling of request failures for urban dictionary 2021-05-12 15:38:57 +02:00
Sheldan
d4edbb0d94 [maven-release-plugin] prepare for next development iteration 2021-05-12 00:51:17 +02:00
Sheldan
aff7fda016 [maven-release-plugin] prepare release abstracto-application-1.2.11 2021-05-12 00:51:09 +02:00
Sheldan
976d4473cb [AB-xxx] adding 400 HTTP status to OkHttp metrics
adding convenience creation method to server user
2021-05-12 00:07:44 +02:00
Sheldan
9ebf0f08dd [AB-257] fixing link embed message being deleted while it still contains an attachment
adding more convenience methods to post target services
2021-05-11 12:58:39 +02:00
Sheldan
e31d257e6f [AB-240] changing invite filter to actively filter the server instead of only being based on the code
moving invite filter to separate module
updating to newer liquibase version
changing concept of immune roles which are directly associated to commands to immune roles which are immune against certain effects. these effects can be configured directly by the command (and a condition checks this effect), but they can be used in services as well, unrelated to commands
adding checks to not execute message received listeners for the wrong message types
adding metric support for 502 status
fixing duplicating help entries when two module definitions with the same key are present
2021-05-10 20:45:34 +02:00
Sheldan
9ae35a7e9d [AB-253] removing help example from reset config command 2021-05-04 13:21:27 +02:00
Sheldan
829c109466 [maven-release-plugin] prepare for next development iteration 2021-05-02 23:18:14 +02:00
Sheldan
bfe9b0d82b [maven-release-plugin] prepare release abstracto-application-1.2.10 2021-05-02 23:18:06 +02:00
Sheldan
3b2216201d [AB-174] fixing being unable to snooze unreminded reminders
changing new line handling for command parameters
2021-05-02 23:01:33 +02:00
Sheldan
a05393eb96 [AB-xxx] updating JDA version 2021-05-02 22:22:40 +02:00
Sheldan
da3ce01fc7 [AB-248] rejecting the everyone role as a valid parameter for a role parameter 2021-05-02 21:54:54 +02:00
dependabot[bot]
0683c92782 Bump commons-io from 2.6 to 2.7 in /abstracto-application
Bumps commons-io from 2.6 to 2.7.

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-02 20:36:46 +02:00
Sheldan
a35cc0ab61 [AB-246] fixing new lines being removed from parameters
creating javadoc profile to only build javadoc on release builds
2021-05-02 20:33:23 +02:00
Sheldan
bbae3575f8 [AB-246] skipping parameters after the mandatory have been parsed 2021-05-02 19:50:00 +02:00
Sheldan
2a5c462c35 [AB-246] changing parameter handling to only actually evaluate the necessary parameter handlers, this helps avoiding providing the wrong parameter to the actual command 2021-05-02 17:40:52 +02:00
Sheldan
23dd02312a [AB-250] showing nicer exception in case there is no tracked experience yet 2021-05-02 01:26:39 +02:00
Sheldan
ad15538b67 [AB-244] fixing experience service related test 2021-05-02 00:22:03 +02:00
Sheldan
4c1470b148 [AB-245] roles are required to be sorted when syncing users, this led to incorrect role assignments 2021-05-01 12:55:47 +02:00
Sheldan
3559a823fc [AB-244] always loading the member for giving experience, members are not in cache just for writing a message 2021-05-01 12:52:45 +02:00
Sheldan
fa864f85dd [AB-243] when loading messages we ignore embed links part of a channel/guild which are not available anymore 2021-05-01 12:31:27 +02:00
Sheldan
5a6fac640e [AB-xxx] increasing caching duration for messages 2021-04-29 01:05:27 +02:00
Sheldan
020cc58c4a [AB-242] refactoring suggestions
adding veto and unsuggest command
adding support for configuration whether or not a reply mentions the message
adding support to reply to a message via template
changed default mention config to exclude role mentions
2021-04-29 01:00:27 +02:00
Sheldan
dec398c3f1 [AB-241] fixing test 2021-04-25 21:32:26 +02:00
Sheldan
f097342fed [AB-241] fixing low cooldowns leading to NPE in command cooldown condition
adding more info to command not found exception
2021-04-25 21:27:29 +02:00
Sheldan
68e2dad2ae [AB-174] adding command to re-schedule reminders 2021-04-25 14:46:59 +02:00
Sheldan
2c2e5c02b1 [maven-release-plugin] prepare for next development iteration 2021-04-24 22:12:43 +02:00
Sheldan
39653574e3 [maven-release-plugin] prepare release abstracto-application-1.2.9 2021-04-24 22:12:35 +02:00
Sheldan
460a4663d7 [AB-xxx] fixing string command parameters in combination with attachments, the attachment was still part of the parameters and used normally, if the parameter type is string, attachments are being skipped 2021-04-24 21:50:41 +02:00
Sheldan
eb79522843 [AB-xxx] minor logging updates 2021-04-24 19:54:30 +02:00
Sheldan
40eb516ddf [AB-237] adding job to clean up the cooldown storage 2021-04-24 19:07:02 +02:00
Sheldan
53bef3fdb3 [AB-233] adding feature to handle removed attachments in message edited events
now cloning the cached message for the listeners, in order to not influence the objects when updating it
2021-04-24 18:03:06 +02:00
Sheldan
27763e985d [AB-232] moving logging to separate module
refactoring leave and join listener
2021-04-24 16:00:58 +02:00
Sheldan
fa4c455ca2 [AB-234] allow templates have individual (additional) allowed mention configurations
adding primary keys to command disabled and command cooldown group
exposing service method to retrieve the channel for a post target
2021-04-24 02:05:15 +02:00
Sheldan
49a9598062 [AB-128] adding command cooldowns on server/channel group and member level
fixing channel group names being made lower case before storing
changing channel group deleted to be sync instead
refactoring exceptions and adding exception message to a few
fixing channel group incorrect type using the wrong template
showing more information in list channel groups command
allowing commands to be in any channel group
adding concept of channel group types not allowing channels/commands to be in multiple of the same type
adding structure to retrieve information about channel groups
adding ability to disable channel groups
changing loading of member parameter handler to not use cache
2021-04-19 00:25:42 +02:00
Sheldan
d540ad80a8 [AB-xxx] fixing loading the incorrect message for cleaning up link embed reactions 2021-04-15 23:57:05 +02:00
Sheldan
537fd85be8 [AB-97] adding react command
we are now actively loading messages in case its a parameter, because the provided message is only partially available
2021-04-13 23:47:22 +02:00
Sheldan
23379e4498 [AB-228] fixing member sometimes unavailable in reaction events 2021-04-11 14:31:11 +02:00
Sheldan
b589e88ad4 [AB-xxx] adding documentation for uptime 2021-04-11 00:34:03 +02:00
Sheldan
f870f64137 [maven-release-plugin] prepare for next development iteration 2021-04-11 00:12:08 +02:00
Sheldan
aea3572fb5 [maven-release-plugin] prepare release abstracto-application-1.2.8 2021-04-11 00:12:01 +02:00
Sheldan
b578b0eb6d [AB-xxx] fixing reminders test 2021-04-10 23:57:12 +02:00
Sheldan
7a9aa32332 [AB-xxx] adding reminder display to reminders command to add a link to the existing reminder 2021-04-10 23:39:36 +02:00
Sheldan
8fea80328d [AB-59] adding command received handler test and fixed some scenarios 2021-04-10 22:29:11 +02:00
Sheldan
446a830514 [AB-xxx] adding alternative interface for creating reminders
fixing reminder IDs not being strings for the quartz job
fixing number handling for very large durations
2021-04-10 00:30:58 +02:00
Sheldan
15d2eb8bd9 [AB-229] exposing gateway ping for metrics 2021-04-08 00:37:49 +02:00
Sheldan
e2c86b98b6 [AB-222] adding uptime command
changed necessary intents
2021-04-08 00:07:31 +02:00
Sheldan
400181a280 [AB-225] adding parameter handler for messages
reworking parameter handling in command received handler
adding string parameter handler to explicitly parse strings
2021-04-07 23:16:25 +02:00
Sheldan
c56a037d28 [AB-226] adding caching of referenced messages (only one element on the chain) 2021-04-06 23:38:45 +02:00
Sheldan
dd97503238 [AB-172] updating to JDA 4.2.1_254 and removing deprecated code from guava 2021-04-06 21:11:36 +02:00
Sheldan
e7b1fbe9d1 [AB-209] adding cleanup job for old embedded messages, this job deletes the entries from the database and removes reactions
reducing thread count for listener executor and scheduling
fixing channel deletion listener not being part of a transaction
2021-04-06 20:23:26 +02:00
Sheldan
61d16d5985 [AB-224] fixing not properly ignoring ignored starboard posts leading to re-creation of them 2021-04-06 03:43:24 +02:00
Sheldan
1d3a85ff01 [AB-221] fixing creation of template for deleted users 2021-04-05 14:24:09 +02:00
Sheldan
09c7daf3e0 [maven-release-plugin] prepare for next development iteration 2021-04-05 01:48:20 +02:00
Sheldan
079436a2b6 [maven-release-plugin] prepare release abstracto-application-1.2.7 2021-04-05 01:48:14 +02:00
Sheldan
df1a0cfc02 [AB-xxx] fixing deployment of zip artifacts named the same name being deployed twice 2021-04-05 01:11:45 +02:00
Sheldan
ecc81884e6 [AB-221] fixing embeds and starboard posts not working correctly for deleted users 2021-04-04 23:51:25 +02:00
Sheldan
ff676b29e6 [AB-219] fixing cached message content not being updated
merging message updated listeners
adding clearing message cache to clear cache listener
2021-04-04 22:28:21 +02:00
Sheldan
d088a161ef [AB-xx] adding licenses for google api and youtube services 2021-04-04 18:38:23 +02:00
Sheldan
8258197bfc [AB-xx] replacing trace log with debug 2021-04-04 18:23:18 +02:00
Sheldan
19baf981f1 [AB-217] adding documentation for profanity regex and renaming command for deleting profanity regex from a group 2021-04-04 18:04:23 +02:00
Sheldan
602f0d5bf4 [AB-217] adding profanity service
using profanity service to filter profanities in urban define
adding cache clearing listeners
fixing using 0 as default for maxMessages if not defined
2021-04-04 16:23:13 +02:00
Sheldan
d6bb269ffc [AB-218] fixing templating test 2021-03-30 22:25:46 +02:00
Sheldan
6375dbf463 [AB-218] adding ability to split the normal message as well according to custom configuration
adding ability to define the max amount of messages resulting from a template on a server and template base
fixing not always considering the server when rendering templates in various places
2021-03-30 20:29:13 +02:00
Sheldan
33959d696a [maven-release-plugin] prepare for next development iteration 2021-03-29 03:17:40 +02:00
Sheldan
3313daa3fa [maven-release-plugin] prepare release abstracto-application-1.2.6 2021-03-29 03:17:34 +02:00
Sheldan
8c026d3547 [AB-82] adding feature mode to make it configurable whether or not the youtube video will show details or not
adding convenience method to config service
2021-03-29 03:02:46 +02:00
Sheldan
8a8e6b2347 [maven-release-plugin] prepare for next development iteration 2021-03-29 01:38:28 +02:00
Sheldan
14b2d78a3b [maven-release-plugin] prepare release abstracto-application-1.2.5 2021-03-29 01:38:22 +02:00
Sheldan
45c1df0d44 [AB-82] adding urban dictionary api with a command
adding Instant handling to GSON
2021-03-29 01:13:46 +02:00
Sheldan
c2b413e4b9 [AB-82] adding youtube video search 2021-03-28 23:29:51 +02:00
Sheldan
9541f907b8 [AB-215] adding create alias and delete alias commands to create service specific aliases for commands
renaming package in commands package
defaulting to latest in docker compose build for deployment container
fixing jacoco configuration
changing that if there are no parameters required, parameters are accepted
2021-03-28 16:46:21 +02:00
Sheldan
a494d4d2f2 [AB-213] fixing not properly creating a channel in case the event is sent 2021-03-25 01:14:06 +01:00
Sheldan
9735f52df5 [maven-release-plugin] prepare for next development iteration 2021-03-24 22:14:03 +01:00
Sheldan
4410928136 [maven-release-plugin] prepare release abstracto-application-1.2.4 2021-03-24 22:13:56 +01:00
Sheldan
a756cbcf31 [AB-210] fixing bug related to loading users in cached reactions 2021-03-24 22:07:51 +01:00
Sheldan
14d3e37177 [maven-release-plugin] prepare for next development iteration 2021-03-24 20:55:35 +01:00
Sheldan
244000bbe4 [maven-release-plugin] prepare release abstracto-application-1.2.3 2021-03-24 20:55:27 +01:00
Sheldan
134f25955c [AB-210] improving performance of star stats 2021-03-24 20:11:32 +01:00
Sheldan
ddb256cf75 [AB-130] making the regex for link embeds more relaxed in order to allow embedding canary and ptb links 2021-03-24 17:40:05 +01:00
Sheldan
08edcbdf8e [AB-210] disabling cache for retrieval of users in reactions 2021-03-24 16:13:13 +01:00
Sheldan
fd9a446f9e [maven-release-plugin] prepare for next development iteration 2021-03-24 14:30:14 +01:00
Sheldan
d2c17cb1fc [maven-release-plugin] prepare release abstracto-application-1.2.2 2021-03-24 14:30:07 +01:00
Sheldan
9de7a59295 [AB-210] fixing some issues in which futures were not completed, when lists were empty
fixing async issue with caching reactions
adding a few more log statements to caching
2021-03-24 14:17:00 +01:00
Sheldan
f9d0e5fa00 [AB-208] fixing order of top starboard posts for individual members 2021-03-24 11:08:56 +01:00
Sheldan
ef421961ca [AB-211] fixing lovecalc having optional parameters 2021-03-24 11:03:51 +01:00
Sheldan
fe8519489c [maven-release-plugin] prepare for next development iteration 2021-03-23 22:19:14 +01:00
Sheldan
72c73b8b34 [maven-release-plugin] prepare release abstracto-application-1.2.1 2021-03-23 22:19:08 +01:00
Sheldan
2b3b0f42c4 [AB-207] fixing command being disabled, if its part of a channel group, but the given channel is not part of that channel group
fixing null pointer in channel group created listener
fixing connection string in config deploy tool
2021-03-23 22:08:08 +01:00
Sheldan
92b8e1dd8b [maven-release-plugin] prepare for next development iteration 2021-03-22 21:46:09 +01:00
Sheldan
b94801192e [maven-release-plugin] prepare release abstracto-application-1.2 2021-03-22 21:46:02 +01:00
Sheldan
f5f0cbcb1e [AB-206] fixing missing command channel group type
fixing not setting the server for creating a command in a channel
adding exceptions for incorrect channel group type
2021-03-22 21:35:28 +01:00
Sheldan
47f33758c9 [AB-204] setting wget to silent in docker file to reduce log output 2021-03-22 01:23:49 +01:00
Sheldan
0a79fe2318 [AB-204] fixing registry prefix in release job 2021-03-22 01:19:55 +01:00
Sheldan
da97f040f9 [maven-release-plugin] prepare for next development iteration 2021-03-22 00:53:40 +01:00
Sheldan
c0e01111fd [maven-release-plugin] prepare release abstracto-application-1.1 2021-03-22 00:53:33 +01:00
Sheldan
0b8e24f5f5 [AB-179] adding command to show documentation 2021-03-22 00:42:40 +01:00
Sheldan
84ddcbe54b [AB-202] duplicating the documentation to a current folder 2021-03-22 00:03:17 +01:00
Sheldan
f53f0cb66c [AB-205] making exception message for command not found configurable
making feature config classes more unified in the naming
2021-03-21 22:59:01 +01:00
Sheldan
5eefc3909e [AB-203] using task executors for the async listeners
fixing starboard post listener and service method
2021-03-21 21:00:21 +01:00
Sheldan
ebed1daadc [AB-204] adding docker container build to release job 2021-03-21 17:53:44 +01:00
Sheldan
b4e36efafb [AB-203] restructuring listeners to use more common code and common interfaces for listeners and models
restructuring entity listener to be async and added models
fixing usage of repository save method
adding interface dependencies to bundle dependency management
2021-03-21 16:26:06 +01:00
Sheldan
cfe7786d4d [AB-200] fixing link embeds not working for users who left the server
fixing some issues with optional dependencies (autowired creates null instances etc)
fixing roll and roulette using not the proper default values
fixing setPrefix not creating an instance, in case it originated from a default config
fixing too many configuration properties in utility
2021-03-16 01:18:31 +01:00
Sheldan
94d6497995 [maven-release-plugin] prepare for next development iteration 2021-03-13 02:42:20 +01:00
Sheldan
a79479e4e2 [maven-release-plugin] prepare release abstracto-application-1.0 2021-03-13 02:39:31 +01:00
Sheldan
a36a884ae9 [AB-199] adding build of sources and javadoc
fixing javadoc as various places
adding release plugin
adding developer connection to scm
updating release pipeline to new action versions
2021-03-13 02:02:27 +01:00
Sheldan
2ed456c164 [AB-197] splitting utility maven module into separate maven modules
aligning some package names
removing some unnecessary computed values from liquibase
2021-03-12 18:48:56 +01:00
Sheldan
e2da800d84 [AB-124] adding admin mode 2021-03-10 01:10:27 +01:00
Sheldan
e780b0e75c [AB-137] fixing occurrences for templates in cases entities do not exist anymore
fixing feature mode retrieval to adapt to lowercase
fixing disable exp role creation and retrieval
removing ansible code
2021-03-09 21:39:29 +01:00
Sheldan
d0c06538e3 [AB-xx] fixing build 2021-03-08 01:32:48 +01:00
Sheldan
66061b7719 [AB-xx] improving scheduling interface
moving renaming module to int
removing duplicated starboard feature validator
sonar fixes
2021-03-08 01:27:50 +01:00
Sheldan
9c6333281b [AB-60] improving java doc for assignable role module 2021-03-03 23:51:26 +01:00
Sheldan
373dfac001 [AB-60] improving java doc for experience module 2021-03-03 16:35:06 +01:00
Sheldan
821971523e [AB-165] removing mocking utils and general test improvements 2021-03-01 01:57:13 +01:00
Sheldan
5f6746d742 [AB-149] adding command to reset configuration to default values
removing listener to create system config instances
adding default value retrieval to appropriate places
making config key handling case insensitive
changing exp multiplier to double value
refactoring experience service bean test
2021-02-27 23:56:38 +01:00
Sheldan
20b6b37151 [AB-74] changing description and field splitting leading to no fractured texts, decision is based on the last space
removing "safeFieldIteration" as its not necessary anymore
splitting up embeds for the embed size limit
2021-02-21 17:36:22 +01:00
Sheldan
9db5889160 [AB-94] adding possibility to reference member/role/channel via name for parameters
showing an embed for parameter handling exceptions
adding discord webhook for build status
2021-02-21 00:16:32 +01:00
Sheldan
a20fe82e15 Merge pull request #3 from Sheldan/dependabot/maven/abstracto-application/junit-junit-4.13.1
Bump junit from 4.13 to 4.13.1 in /abstracto-application
2021-02-20 13:31:32 +01:00
dependabot[bot]
0e851021e7 Bump junit from 4.13 to 4.13.1 in /abstracto-application
Bumps [junit](https://github.com/junit-team/junit4) from 4.13 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.13.1.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.13...r4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-20 12:30:58 +00:00
Sheldan
43eca33113 [AB-77] moving the templating module into the core module
adding a possibility to overlay specific templates for particular servers
adding commands to configure templates
adding file parameter support
2021-02-20 13:29:09 +01:00
Sheldan
909dc87d94 [AB-182] added member parameter to starStats to show the starboard statistics for an individual member 2021-02-15 01:23:46 +01:00
Sheldan
876fbc01d9 [AB-120] adding jump link to modmail notification 2021-02-14 19:56:05 +01:00
Sheldan
cb7e904d29 [AB-81] adding notification message to feature setup in case the setup confirmation was denied 2021-02-14 19:26:55 +01:00
Sheldan
a536a0c2b3 [AB-191] grouping invite links in invite link deletion notification 2021-02-14 19:09:53 +01:00
Sheldan
94532be54d [AB-112] adding star levels to setup feature wizard
moving star level configuration to only be instantiated when needed
2021-02-14 17:04:37 +01:00
Sheldan
23bdf4e906 [AB-69] adding templating support to help modules 2021-02-14 14:20:01 +01:00
Sheldan
34b9bca7ac [AB-192] removing second level cache
changing assignable role place module name
fixing starboard retrieving the starstats incorrectly
fixing removing user assigned roles when removing a role from assignable role place
fixing not being able to remove external emote for assignable role place
2021-02-13 16:16:50 +01:00
Sheldan
047c574319 [AB-190] migrating default config (featureMode, system config, post targets, feature flags) from tables to property files
not longer immediately instantiating the feature flag instance when a new server is found, but only when its config is changed or when a feature mod has its config changed
2021-02-11 00:19:17 +01:00
Sheldan
ea12d67e5f [AB-62] adding server id to more tables for easier joins and fixing structure at more places 2021-02-08 02:06:43 +01:00
Sheldan
1352fac40f [AB-xxx] updating sonar key in readme 2021-02-07 23:12:43 +01:00
Sheldan
038d5c3832 [AB-103] adding triggers to update created and updating attributes on tables
fixing error handling in installer
merging change sets to larger operations
adding check constraints
fixing suggestion id handling
applying naming conventions to various columns
adding indices to tables
adding user in server and user locking
2021-02-07 22:58:06 +01:00
Sheldan
dac3b0887f [AB-xxx] updating sonar key 2021-02-06 19:07:00 +01:00
Sheldan
7aa5cbe304 [AB-177] adding ability to restrict the allowed mentions and configure them via commands on a server basis, default is defined via property file 2021-02-06 18:58:16 +01:00
Sheldan
b838678c15 [AB-184] adding various metrics to the system, organizing imports, changing some transactional behaviour
adding okhttp metrics, split bot service into multiple services (guild, message), unified some places that services are used in order to interact with the api, and not directly the objects (this is to make it easier for metric to be accurate)
2021-02-03 03:16:51 +01:00
Sheldan
2a2a3aea70 [AB-68] adding invite filter with commands to allow/disallow invites, remove stored filtered invite links and show filtered invite links
removing database entities from command context
2021-01-24 22:34:01 +01:00
Sheldan
fb3ed69650 [AB-154] split up private and guild message received handler, split handlers into async and sync handlers
adapting the tests and improving tests to reduce usage of MockUtils
adding some util methods to message bean
extending cache for cached messages
enabling to build cached messages from messages in DM channels (they are not part of the message cache)
splitting multiple listeners to different beans, for better overview (emote updated)
adding convenience service for reactions specifically
split cached reaction and cached reactions, singular only contains one user, while the later contains all users
fixing liquibase configuration for assigned role user
fixing assignable role not having a transaction
moved caching update a bit earlier in various methods
fixing bug that a manual unmute caused duplicate unmute notification
fixing short scheduled unmute not checking the new mute state
limiting parameters for roll
2021-01-23 11:40:41 +01:00
Sheldan
69aa82e26e [AB-63] adding fun and entertainment related commands commands: roll, roulette, lovecalc, choose, 8ball 2020-12-14 22:33:10 +01:00
Sheldan
325264a325 [AB-150] creating repost detection feature including configuration and documentation
adding http and hash service
adding ability to add default emotes to a message to message service
adding message embedded listener to wrap the embedded event
adding custom channel groups which can be defined by modules, in case a change on a channel group (only created and updated) happens a listener is available in order to sync the state in dependant areas
changing command receiver re-throwing abstracto runtime exceptions in order to display them better
changing channel group parameter handler to throw an exception in case the channel group was not found
adding User in a server parameter handler
split channel not found exception to be able to differentiate between not found in database and not found in guild
changing exception handling in command received handler to handle the case for only one parameter handler future which failed (the whole single future failed, which was not reported)
changing parameter type of `removeFromChannelGroup` to AChannel in order to be able to delete channels in the database via ID
moving method to mock utils for mocking consumer
removing parameter validation from commands, as it should be done in the command received handler and parameter handlers anyway
2020-12-13 01:50:09 +01:00
Sheldan
e966c710ce [AB-60] added java doc for statistic module, added feature mode limitations to emote listener, replaced redundant Embeddable with ServerSpecificId 2020-11-23 21:58:24 +01:00
Sheldan
b05a834b59 [AB-161] fixed composite foreign keys for multiple tables 2020-11-22 18:45:00 +01:00
Sheldan
1d9f2595db [AB-166] added locking for runtime storage 2020-11-22 14:43:42 +01:00
Sheldan
448d555dba [AB-166] refactored conditions to not use exceptions for their regular case, split up feature mode exception into condition and exception, if the conditions need to be checked somewhere else, a separate exception is required, fixed command not being disabled properly in channels 2020-11-21 22:28:24 +01:00
Sheldan
04f1db2408 [AB-80] added tracking of emotes used by server members and configuration
updated sonar scanner version
changed some commands to be silent instead of adding a check reaction
2020-11-19 00:21:05 +01:00
Sheldan
c60cdb9d98 [AB-152] adding optional parameter to deploy config script in order to deploy template config 2020-11-02 15:42:43 +01:00
Sheldan
a5b2e40c6b [AB-155] removing ansible dependency from installer, restructuring deployment container to be packaged with the respective versions, removing build for docker container from maven, for now
fixing liquibase setup for feature mode
2020-11-02 13:03:18 +01:00
Sheldan
389b38f4f0 [AB-151] adding ability to define a priority in order to define which listener is executed before another 2020-10-20 21:58:04 +02:00
Sheldan
dca98c2953 [AB-96] adding ability to edit/delete modmail messages via editing/deleting the original message causing the message,
adding featuremode to modmail to define whether or not there is a separate message posted to the mod mail thread, to see it easier, renaming modmail related tables to singular, adding some necessary methods (caching) to all entities
2020-10-20 00:03:13 +02:00
Sheldan
1b98436736 [AB-73] adding different feature modes to define whether or not certain actions should be logged, changing name of setup, disable and enable command to show that they are supposed to be for features 2020-10-17 16:35:20 +02:00
Sheldan
44dfdca6e6 Merge pull request #2 from Sheldan/dependabot/maven/abstracto-application/junit-junit-4.13.1
Bump junit from 4.13 to 4.13.1 in /abstracto-application
2020-10-16 21:10:46 +02:00
dependabot[bot]
a342fac783 Bump junit from 4.13 to 4.13.1 in /abstracto-application
Bumps [junit](https://github.com/junit-team/junit4) from 4.13 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.13.1.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.13...r4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-16 18:57:30 +00:00
Sheldan
0aa7d3f036 [AB-78] adding new concept of feature modes, with splitting it up to new commands and default mode concept
refactoring command received handler to only load the entities in the same thread as the actual executed commands, so that user initiated context contains valid references from the same thread
updating documentation
fixing issue when the result of role calculation result in no experience role id
2020-10-16 20:42:29 +02:00
Sheldan
bc9afc9bfc [AB-135] adding a template to describe the parameter validators for help texts, fixing assignable roles not available as module 2020-10-12 11:52:28 +02:00
Sheldan
36d11371cb [AB-139] changing the places at which there might be an uncached member object
fixing integer validator
fixing syncing roles not working if the role did not change in the database
fixing warn id being flipped
fixing star stats model
2020-10-12 01:12:11 +02:00
Sheldan
1d3c414d6b [AB-144] fixing command key parameter handler and assignable post refreshing 2020-10-07 20:42:19 +02:00
Sheldan
b8d19ab1e1 [AB-143] fixing incorrect parameter exception message, replacing incorrect parameter exception 2020-10-07 16:06:20 +02:00
Sheldan
0145e7670d [AB-138] improving logging at various places fixing various issues regarding async commands and exception handling, fixing role role calculation being done twice 2020-10-07 12:57:25 +02:00
Sheldan
a391381ff6 [AB-136] replacing some rare occurrences where fake objects where used for actual database operations
replacing a few sync commands with async commands
refactoring parameters in assignable role place service bean
fixing emote parameter handler to also consider default emojis
removing unused description in command
replacing some ARole parameters with Role parameters, so we can be sure they exists
added a few TODOs marking exception changes required
2020-10-03 15:32:23 +02:00
Sheldan
0f6f6a1e49 [AB-54] adding various command parameter handlers
removing old parameter length validation
2020-10-03 10:50:03 +02:00
Sheldan
f0d517af22 [SONAR] fixing major sonar issues 2020-09-30 01:31:21 +02:00
Sheldan
8e05bc90ea [AB-70] adding concept of command parameter validators and applied them at various places, this has the intention for commands to fail early
removing duplicated command for assignable role places
2020-09-30 00:46:41 +02:00
Sheldan
0f9a0dc143 [AB-132] fixing experience job not creating user experience records in the database
fixing setup command not being considered templated
changing column name for counters
fixing liquibase configuration for creating postgres functions
fixing duration format expcetion model not available in the template
enabling builds for hotfix/bugfix branches
2020-09-27 01:28:20 +02:00
Sheldan
5081c3174f [AB-76] replaced usage templates for commands with a generated usage string, removed possibility to define the usage directly on the help
added Google guava dependency
minor fixes in documentation
fixed versions in main pom
2020-09-24 03:11:01 +02:00
Sheldan
76adda90a3 [AB-57] [AB-61] reworked commands and services to work with completable futures and moved the database operations to the very last operation so we have transaction safety in more areas
added some cache annotations to the default repository functions
reworked how the undo cations are processed within commands, they are executed in a post command listener when the state is error
added a counter id to generate ids to be unique within servers, changed a few tables to be unique within a server
added future utils class for wrapping a list of futures into one
moved abstracto tables to separate schema in the installer
refactored experience gain to work with more futures and delayed database access
2020-09-22 00:28:09 +02:00
Sheldan
552ecc26b8 [AB-99/AB-66] changed commands to use embeds for exceptions instead of direct messages
added models instead of using HashMaps for exceptions
added a lot of exceptions for different cases
refactored a few commands to be fully async instead of fire and forget
2020-08-29 12:55:48 +02:00
Sheldan
fbb36ae9d5 created concept of auto load macros, these are macro files which are loaded automatically on startup and can be used in any template
changed assignable post config to be a full emote instead
2020-08-16 12:40:41 +02:00
Sheldan
fd4d784081 added assignable role place module including: setting up, configuring, deleting commands and documentation
upgraded JDA version to 4.2.0
refactored multiple interfaces to be more convenient/contain more information (reaction added/removed now gets the actual event)
added generic way to check for conditions. these conditions are provided by modules and are loosely connected via condition context and a condition name
added changeable flag to emotes to indicate that they can be updated via setEmote
refactored emote parsing in command parameters, the command parameters will now contain a fake emote
added feature to embed templates for fields to force a new message regardless of the discord limit
added some more functionality to message and channel service regarding field edit/embed sending
introduced the full emote parameter, to have both the emote (if custom) and a fake aemote at hand
refactored some methods to already throw exceptions within the retrieval methods, instead of optionals which need to be dealt outside
changed getEmotes to getEmotesBag to have duplicates of emotes
fixed setEmote to behave correctly with new parameter types
fixed creation of emotes, which previously created additional instances
fixed templating multiple fields handling
refactored command handling to allow async commands, they are the same interface, but configuration dicates whether or not it is async
added generic exception reporting for async commands
refactored a bunch of service methods to be named optional, and the non optional methods throw exceptions in case nothing is found
added a few more customized exceptions
added clearing freemarker internal template cache to clear cache
added feature to skip, not use, embeds if they look to be empty (no fields, no description, no attachment)
added virtual env to gitignore
fixed initial sync of roles un-marking roles as deleted
added some convenience methods to remove reactions from users directly
fixed post command handling in case it is not a templatable instance
fixed exceptions without cause in generic exception model
2020-08-12 20:01:15 +02:00
Sheldan
5317199bf4 added more technologies to readme and updated licenses 2020-07-17 21:56:33 +02:00
Sheldan
9374dfb912 added liquibase for setup of databases and initial values
fixed some table names to be singular
migrated templates to separate repository
added seed data to initial version in liquibase migrations instead of property files (post targets, emotes etc) and created some default tables containing those default values
added separate artifacts to be used containing only the liquibase config
added shell script as a wrapper for ansible deployment, to handle an environment variable defining whether or not the deployment should be executed
added logback scan period
added licenses for ansible, liquibase, docker and docker-compose
2020-07-17 21:48:23 +02:00
Sheldan
e8767429bf update JDA and jda Utilities version
fixed typos in the code
2020-06-28 12:04:34 +02:00
Sheldan
c44eb80fc5 added message to user initiated context
fixed templates for ban and kick logging
refactored kicking service
fixed guild not found exception template
added command validator to be used for unit testing commands
added default values for command configuration
changed some interfaces to message channel instead of text channel
added separate executor service for un-mutes, which is shared
updated spring boot version to 2.3.1
removed database connection string from properties
added logback configuration
changed some future logic in purge
refactored error message for un mute, when there is no active mute
refactored listener interface and removed usage of context utils
added tests for moderation services
2020-06-28 11:13:56 +02:00
Sheldan
8acd4f818d Fixed multiple server handling for rank command, without this the rank was global, and did not limit the rank to the server
defined the name table name for AUserInAServer
2020-06-19 00:36:41 +02:00
Sheldan
19a7d09576 updated javadoc for experience tracking
added/changed some javadoc for mod mail
some small interface changes
changed a few methods to actually use the exists mechanic, instead of checking for null values
added some templates instead of hard coded strings
fixed some bugs related to mod mail
2020-06-18 23:30:39 +02:00
Sheldan
e76351ddc1 added first version of readme 2020-06-10 18:01:33 +02:00
Sheldan
ac93440546 added tests for utility module
refactored various commands and services
optimized code for message embeds
removed emoteUtils completely and moved to service
removed suggestion validation, because its now done via feature config
fixed regex for discord links
changed template to handle the case in which a member which suggested it originally left the server
added suggestion update exception in cases the message to edit, does not qualify as a suggestion
added check to not allow cross server quoting and added test case
refactored mocking for jda objects
2020-06-10 13:04:39 +02:00
Sheldan
a577932c42 removed instance specific modules from code base
fixed user experience object not being created
removed top module, because it does not serve a purpose anymore
2020-06-06 16:22:43 +02:00
Sheldan
d14e917329 added overview to existing post targets if no parameter is provided for the post target command 2020-06-05 17:51:06 +02:00
Sheldan
601c4b7121 added configuration to deploy documentation to GitHub pages when a release is happening
adapted documentation configuration
2020-06-05 13:50:51 +02:00
Sheldan
db8afde7ea added job and configuration for publishing the artifacts on github packages 2020-06-03 21:32:46 +02:00
Sheldan
1091e66013 added purge command to delete messages via bulk delete
adapted api of status message service
added concept of self destruct command results, these will cause the command message to be deleted
2020-06-03 19:47:50 +02:00
Sheldan
072072dffc added commands to documentation
small improvements in the documentation
added alias to listDisabledExperienceRoles command
2020-06-02 16:35:02 +02:00
Sheldan
563564aabe added tests for experience tracking module
refactored some things in experience tracking
changed the paging behaviour for leader board and added check for negative numbers
fixed rank not being correct for further pages
added test-common module to have some common code für tests
fixed command creation
2020-06-02 15:07:27 +02:00
Sheldan
62de5c2255 Added template service tests 2020-05-29 23:55:23 +02:00
Sheldan
f4edf7a77d added template service, template management service bean, freemarker methods and template loading tests
added templating exception
changed embed configuration to have builders
enabled mocking of final classes for mockito
2020-05-29 23:45:05 +02:00
Sheldan
f61cc8e1ff added feature branches to github action 2020-05-27 23:56:12 +02:00
Sheldan
af63f384d9 fixed jacoco configuration for coverage 2020-05-27 23:56:02 +02:00
Sheldan
3fa5edf67a addressed sonar code smells 2020-05-27 19:38:43 +02:00
Sheldan
175a92408c addressed some sonar issues 2020-05-27 18:41:31 +02:00
Sheldan
f05f088d58 changed sonar configuration 2020-05-27 18:07:47 +02:00
Sheldan
10b3b647e3 fixed build 2020-05-27 15:59:21 +02:00
Sheldan
a826cda95a Added initial version of github action 2020-05-27 15:55:15 +02:00
Sheldan
8413bc8314 added possibility to the ID of a user instead of a mention for a member parameter 2020-05-27 15:39:12 +02:00
Sheldan
feb92698ef added command to show the avatar of member 2020-05-27 15:29:23 +02:00
Sheldan
de4eeeacca added serverInfo help
added userInfo command
added offsetDateTime to the custom date formatter
2020-05-27 15:10:54 +02:00
Sheldan
be97e825cc added serverinfo command
added freemarker extension in order to split up elements in fields at a point which makes sense (necessary for emotes to render)
added additional check to split fields if they are indeed over the max length
2020-05-27 13:07:51 +02:00
Sheldan
2aa55f6ab6 added java doc and some comments to scheduling module 2020-05-26 13:50:48 +02:00
Sheldan
b554419381 updated java doc in templating 2020-05-26 12:40:06 +02:00
Sheldan
6908a7da85 upgraded to newer jda version 2020-05-26 12:24:24 +02:00
Sheldan
a682428028 merged exceptions for setup steps to one common exception, which contains the concrete exception
added exception handling for incorrect mod mail category id
2020-05-26 11:48:12 +02:00
Sheldan
158d957eee added exception handling (with templated messages) for setup of post target and system config 2020-05-26 00:51:35 +02:00
Sheldan
7d18f51e08 added some post target descriptions 2020-05-25 23:18:06 +02:00
Sheldan
213f42ffbd added current values to post post target
added support for custom setup steps for each feature
added mod mail category setup step
2020-05-25 23:11:44 +02:00
Sheldan
3714fd2582 added default value handling to setup wizard
added table to store the default values of the whole system, to not require the property files
added ability to cancel setup wizard
2020-05-22 20:13:24 +02:00
Sheldan
992357b2cb added setup command which includes an interactive process in order to setup features
the current supported features are post targets and system config
the wizard includes a summary step where the user can confirm the changes
removed some unnecessary validators, which were basically just validating the system config from some features
fixed post target name
2020-05-22 17:25:44 +02:00
Sheldan
e2f71ef7a3 added possibility to define the text which is used for notifying the user when closing a thread 2020-05-20 01:13:45 +02:00
Sheldan
1e667686d3 introduced *all* intents abstracto requires in order to function...., because with the new version the guild members intent was not used, and various features were not functioning
added initial message also to be send
2020-05-20 00:31:43 +02:00
Sheldan
5b7d224fd9 added bundled third party licenses 2020-05-18 01:45:03 +02:00
Sheldan
b45f5abd8e added documentation of user notes 2020-05-17 23:18:49 +02:00
Sheldan
20f8e422a2 added commands to create/delete/list usernotes 2020-05-17 23:13:01 +02:00
Sheldan
0260862e8e added command to set roles for which experience gain is disabled
and separate command to remove them from the list again
added command to see all roles for which experience gain is disabled
2020-05-17 20:35:53 +02:00
Sheldan
cf1816597c added command to specifically disable/experience for a user 2020-05-17 01:24:27 +02:00
Sheldan
59ff1f1f40 added listener to listen for all reactions removed 2020-05-17 00:40:16 +02:00
Sheldan
db8edb26f0 upgraded to new JDA version and changed some deprecated methods 2020-05-16 23:40:02 +02:00
Sheldan
3bb6620cbe added a condition to check for the correct feature mode
merged mod mail logging back into the mod mail feature and set it up as a mode
2020-05-16 22:40:11 +02:00
Sheldan
b0ab88d143 added setMode to documentation, added error handling with templated exception for set mode and refactored some feature config related methods (changed the equal to be case insensitive) 2020-05-16 21:46:10 +02:00
Sheldan
d2264937b2 added the concept of feature modes, these are the modes in which a feature can operate, its basically a separate way how the feature does it jobs, for example mod mail might log or it might not. bot of these are different modes
refactored services for feature flag and feature config
2020-05-16 20:55:13 +02:00
Sheldan
cd80d27795 added command to completely silently close a mod mail thread (no logging, no notification)
this is part of the mod mai logging feature, because without logging the normal closeSilently behaves the same way by default
2020-05-16 11:06:48 +02:00
Sheldan
d5007e362b added support for example templates/direct strings to commands who need it
added example templates for some commands
added the examples to documentation as well
2020-05-16 01:20:23 +02:00
Sheldan
ddb540ccfe added columns for tracking created/updated 2020-05-16 00:21:53 +02:00
Sheldan
82c63d4825 added validation for emotes to features 2020-05-15 20:31:16 +02:00
Sheldan
b984129df6 added check for existing system config when a feature is enabled 2020-05-15 18:53:51 +02:00
Sheldan
f11232de05 moved post targets to an enum, in order to have more type safety, this might be changed in the future
added validation check when a feature is enabled, in order to notify which configuration is missing for this feature to function properly
2020-05-15 17:43:39 +02:00
Sheldan
e4efc26740 added templates parameters for help 2020-05-14 18:53:09 +02:00
Sheldan
3f6d980c4c added template for command not found, when disabling a command in a group 2020-05-14 01:02:31 +02:00
Sheldan
4c826676d0 pulled some more user facing strings into templates 2020-05-14 00:49:57 +02:00
Sheldan
40731157f7 restructured template config layout
moved some exception messages from module templates to template config
2020-05-14 00:28:50 +02:00
Sheldan
b591ae497d added more specific exceptions 2020-05-13 23:46:58 +02:00
Sheldan
cf04687f04 moved some more exceptions to templates
made more specific exceptions for certain cases
2020-05-13 23:25:52 +02:00
Sheldan
cb1abaed7d moved some more templates to template config
fixed usage of post target exceptions
2020-05-13 17:45:55 +02:00
Sheldan
80505d1014 migrated some exceptions to use templates
fixed missed hard coded value in template
fixed listing of channels in channel groups
fixed template loading
2020-05-13 17:04:21 +02:00
Sheldan
c429aa882b refactored channel exception to have a unified interface to form the exception message
replaced getOne with findById in order to get optionals and handle those
some places still have the general abstracto run time exception
2020-05-13 12:49:08 +02:00
Sheldan
5755d033eb fixed command and feature mapping
added a bunch of java doc to moderation interface
added check in case the text channel on the server was deleted while the mod mail thread was still open
This now returns an error to the user side and prompts to message the bot again in order to create a new mod mail thread
2020-05-12 22:44:44 +02:00
Sheldan
8d8f735672 fixed future handling in message cache, so methods return futures instead of requiring them as parameters
and adapted the code using this
fixed config loading still relying on double, where the values were changed to long
2020-05-12 09:32:18 +02:00
Sheldan
1634f5e9cc fixed link embedding not properly working with sessions 2020-05-12 08:59:08 +02:00
Sheldan
5639ca20b5 added check to not allow two channel groups with the same name 2020-05-12 00:55:45 +02:00
Sheldan
59c449f4d3 added evaluation of the allowed commands when executing help
added a note that a few commands are only available within a mod mail thread
2020-05-12 00:45:13 +02:00
Sheldan
c234266b7b restructured the duration formatting templates for easier translation 2020-05-11 21:14:55 +02:00
Sheldan
70428e6e03 added a first version of java doc for the templating module 2020-05-11 20:46:14 +02:00
Sheldan
e89c3b8796 added html output for documentation
restructured documentation
added more levels to table of contents
2020-05-11 19:05:59 +02:00
Sheldan
b13309a026 Split the logging of mod mail threads to a separate feature
fixed the default values of features in properties files
2020-05-11 16:15:02 +02:00
Sheldan
af15becf84 fixed the type of initial values for configuration 2020-05-11 15:42:54 +02:00
Sheldan
6b37b9e8b7 merged the config commands into one command for setting the appropriate value 2020-05-11 15:39:11 +02:00
Sheldan
e314ec178d added explanation about immune roles 2020-05-11 15:14:13 +02:00
Sheldan
9197fe0268 removed decay feature boolean from myWarnings, because only automatic decay is an additional feature
fixed post target for kicking
fixed casing for mod mail post targets
added initial version of the ascii doctor documentation
2020-05-11 15:00:00 +02:00
Sheldan
ba032194ce added bean configuration for event waiter to be used for paginator
fixed initial setup for server
fixed command in a server configuration
2020-05-10 20:29:32 +02:00
Sheldan
82186c8757 added command to delete a warning by id 2020-05-10 19:34:35 +02:00
Sheldan
860aa0eed7 added ability to configure paginators to be used
added paginator for warnings command
2020-05-09 21:31:31 +02:00
Sheldan
1e203c19e0 added command to check your own commands 2020-05-09 17:19:09 +02:00
Sheldan
aba98ef0c6 fixed jpa annotations for one to many 2020-05-09 16:21:48 +02:00
Sheldan
da8fea34da replaced a bunch of places where the database loaded objects were referenced across threads, this might have lead to problems when lazy loading them
fixed starboard post template
fixed starboard post deletion
2020-05-09 16:15:07 +02:00
Sheldan
8db1cead57 fixed some catch blocks to include all exceptions
fixed message sending undo action
2020-05-09 01:32:09 +02:00
Sheldan
0e7add826b added undo logic to mod mail logging
added some more logging when closing the mod mail thread
2020-05-09 01:10:46 +02:00
Sheldan
379db1ff73 added concept of undo actions
used undo actions to delete the mod mail thread channel, if it already reached a certain state when initially setting up the mod mail thread
2020-05-09 00:19:19 +02:00
Sheldan
271ea7364a fixed initial setup for mod mail category
fixed setup for locking
added exception message in case the modmail post target is not defined
2020-05-08 23:22:23 +02:00
Sheldan
d1f307837d added initial setting for the mod mail category in a listener, so it can be configured via command 2020-05-08 18:27:04 +02:00
Sheldan
1c67d96887 added subscribe and unsubscribe command 2020-05-08 17:02:22 +02:00
Sheldan
5ace3e2abb restructured templates for mod mail a bit 2020-05-08 12:27:08 +02:00
Sheldan
9fdca52005 added command to remove the role from mod mail configuration again
added convenience method to disallow a whole feature for a role
2020-05-08 12:11:35 +02:00
Sheldan
4236db7a5b updated mod mail help command texts 2020-05-08 11:23:02 +02:00
Sheldan
7699075b33 added mod mail thread notification, if a user initiates a mod mail thread
added the concept of a mod mail role, these are roles being pinged when a thread is opened, and they also are able to execute mod mail related commands
fixed past thread count in mod mail header
added convenience method to allow a role to execute a whole feature
2020-05-08 10:49:06 +02:00
Sheldan
ea6fe240f4 added anonymous message handling to modmail 2020-05-08 00:58:05 +02:00
Sheldan
c03788a065 added closesilently command for modmail
largely refactored modmail future handling and error handling in case:
no permission, unable to contact user
fixed help command template
2020-05-08 00:20:20 +02:00
Sheldan
95733c9b98 moved default close note to template, added notification if there are no servers available which have mod mail enabled, added check to only present the servers which have the feature mod mail enabled. 2020-05-07 20:20:40 +02:00
Sheldan
6cf69af438 added header message containing information about the user the mod mail thread has been opened for 2020-05-07 00:26:19 +02:00
Sheldan
cb1a14e46b added user facing message in case the initial modmail creation fails 2020-05-06 23:41:35 +02:00
Sheldan
feb9ce07ee fixed using the correct parameter for reply and anon reply (not the whole message, so we dont need to parse out the actual reply again)
added optional note parameter for close
fixed state not being saved in database for mod mail thread
changed logging of mod mail to be templated, instead of replaying the messages
added reaction to indicate the user, that the message was processes by modmail
fixed future handling for user message replies (we blocked)
added header for initial information about the user when he opens a thread
fixed duration formater resulting in new lines
2020-05-06 23:22:43 +02:00
Sheldan
ad1cbb54fd refactored the naming in channel service
added initial version of closing and logging the thread
2020-05-06 18:32:08 +02:00
Sheldan
54327c3e58 implemented contact command and added check if the thread already exists
added anon reply command
2020-05-06 15:36:13 +02:00
Sheldan
a06006d763 added jda utilities dependency
added modmail with some simple features (chat between user and moderator), and initial server selection (currently allows all servers, and does not consider the modmail feature)
added the initial commands, not all of them hold logic currently
added some checks to not crash when a command has null configuration
changed systemconfig to also have a long value, because double is not fit for all cases
added locking mechanism, to effectively lock the whole table without using the ... proper locking mechanism (needs to be reviewed)
changed interface in channel service to be a message channel instead of a textChannel
changed starboard post to be a user in a server instead of only user
2020-05-06 14:17:44 +02:00
Sheldan
cf713cc561 added unremind command 2020-05-01 23:24:05 +02:00
Sheldan
70365ca556 added logging to several places concerning futures 2020-05-01 22:56:21 +02:00
Sheldan
f2ce402256 introduced eh-cache as a caching provider instead of caffeine to be used in hibernate (only ram cache is currently possible)
added caching configuration for 2nd level caching in hibernate
added command to clear hibernate caches
changed some interfaces so the api looks a bit more consistent (return the created/updated value)
split user management and user in server management
added try catch block to message received listener execution, to make them independent
moved some feature flag methods to the feature flag service bean instead of the management service, as they used the FeatureEnum directly
fixed feature disable text always rendering
removed some non embed logging
fixed message embed template
added exception logging to message embedding
2020-05-01 22:42:12 +02:00
Sheldan
59dc8c602a refactored command responses to use a central place for configuration in an extra module
fixed makeAffected role parameter
made command check name case insensitive
added name to parameter for decayAllWarnings
removed simple log from message edited listener
2020-04-30 22:29:49 +02:00
Sheldan
d5482fabd4 renamed feature display to feature config
added concept of feature dependencies, if one feature depends on another feature, and it gets enabled, the other feature is enabled as well
changed some feature related apis
added ability to automatically decay warnings (separate feature)
added command to trigger the warn decay manually
added command to decay all active warnings
added method to scheduler service to directly start a cron job
2020-04-29 21:25:26 +02:00
Sheldan
85c47db5ed allowed the Arole parameter type to be either an id or the role mention
fixed adding/removing allowed roles, the compare did not work
changed a few commands to use the Arole parameter
2020-04-28 22:12:29 +02:00
Sheldan
6ed3a133e2 added allowed roles, immune roles and restriction status to help command 2020-04-28 21:32:20 +02:00
Sheldan
65b693be7b added alias support to help command 2020-04-28 20:22:27 +02:00
Sheldan
1fc459f65e added description/long help and usage to all the current commands and updated a few of existing ones
added help info objects to the commands who missed them
changed all commands to be templated and removed the hard coded strings to only rely on templates (other commands might only want to use the direct string)
fixed handling of null parameters/submodules in help command
fixed experience module not showing up in help command
2020-04-28 20:02:03 +02:00
Sheldan
93f587bf26 refactored help command 2020-04-28 15:39:47 +02:00
Sheldan
8e7bc7d98f fixed some code smells 2020-04-27 20:23:02 +02:00
Sheldan
e08086b6a9 added the concept of commands in server, to have a separate config for commands within a server
added server config listener, to create such commands
moved the command and feature creation to separate spring listener (they are dependant, a mechanism for dependencies is needed)
added a feature flag to the command table, so we know what the feature of a command is
added ability to restrict commands to certain roles/remove the restriction
added ability to make some roles not affected by a command/remove the immunity, this works by retrieving the first member from the command parameters, and checking if the member has the said role
commands in a server now have a restricted flag to indicate, if the role checks should be in effect (only affects role-to-execute restriction)
fixed initial prefix config
added the immune user check only to commands most likely needing it
2020-04-27 17:32:33 +02:00
Sheldan
05aa0815d6 added feature to dynamically adapt the prefix while the bot is running, multiple characters are supported 2020-04-26 12:11:28 +02:00
Sheldan
4800470f86 refactored features to be components instead, so we have more runtime config (for example template config etc), this can be done, because features depend on the code anyway and do not need to be done via property files, the property files only define the default values when starting up
fixed feature disabled message not being templated and refactored the way condition checks are handled by the command received handler, so we do not use exceptions for this, this handled by a specified state in the result and a separate post execution handler
added separate config module to the commands
added command to see which features are available, and their current state
fixed scheduler test
2020-04-26 11:38:27 +02:00
Sheldan
bd554537cc removed some unused autowired services
changed place to use the starboard post source channel instead of the message channel
2020-04-25 14:41:31 +02:00
Sheldan
7ac2f2ce08 added unmute command to end all mutes, and remove the current one, this also cancels all running jobs, so we need to store the triggers
enabled voice state cache, as its necessary for voice state operations
kick user out of voice chat, if they are in any
changed unmute date to the the effective date of the unmute, instead of the planned date
added possibility to stop a job via the trigger key
2020-04-25 11:10:59 +02:00
Sheldan
d4eeb2dadb added check to unmute user, in case the user left the guild
added checks if users being awarded a role are still in the guild
2020-04-24 20:49:06 +02:00
Sheldan
0f8a39a336 changed catch block in join listener for Exception, so the listener dont interrupt one another
fixed join template
added join listener to check if a joined user should be muted
changed cached message to be an intant instead
fixed wrong id in mute table
moved the timestamps for mute notifications to the footer
fixed a case for message embeds, when the embed does not have a description
2020-04-24 20:04:19 +02:00
Sheldan
b41a596acd added Arole to command received handler in order to handle it
restructured channel service calls a little bit
moved dm sending to message service
fixed log level configuration
added full user dto, to be used as a combination of a AUserInServer and Member, for operations which need both, to avoid converting and reloading the user
added mute command and mute role command
added mute table
added mute role table
added job to automatically unmute people at the given time period
restructured warn service
removed simple message log for warnings
added method to templating to support formatting instants
2020-04-24 18:02:05 +02:00
Sheldan
cf37d4adef added javadoc to experience tracking module
changed persistence configuration for entities, so cascade is more correct
changed the way channels get their server assigned
added feature to only change the exp role of a user, if he doesn't already have the new target role
added the name of the needed feature, to the message indicating that a feature has been disabled
updated unsetExpRole to have a status update message, because there might be a lot of users which need a role update
2020-04-23 23:39:05 +02:00
Sheldan
1a74924850 changed parameter for slowmode command to be a duration string instead of just seconds
added exception to duration parsing, in case there is a unknown duration indicator
2020-04-21 22:20:39 +02:00
Sheldan
ff8817f765 added duration field to reminder and restructured remind text
added general duration formatting to freemarker (its a builtin method currently
added source channel attribute to starboard post
added exception logging to immediate reminders
2020-04-21 21:54:47 +02:00
Sheldan
7b56b89157 added check to check if a role is in the server
added more log output
2020-04-21 19:25:12 +02:00
Sheldan
5edb2e4cc8 added command to set config double to a certain value, added command to scale the exp (separately)
renamed multiplier property, to be more descriptive
2020-04-12 23:46:36 +02:00
Sheldan
edb270e887 added command to sync roles for the whole server
added command to remove a role from the experience roles
added leaderboard command
added rank command
fixed missfire configuration for cron jobs (they should not be executed)
added ability to configure recovery for jobs
added tracking of message count
added join listener to automatically give the appropriate role for a joined user
added parameter to join listener containing the userInAServer
re-added command exception templates
added method to create a status message (basically only a single message is returned and expected)
added method to edit a single message in a channel to channel service
fixed cases in which there are no embeds, but we still used the embed principle of sending messages (only text was send)
added more functions to channel service to send messages with
moved joined listeners to their separate transaction
2020-04-12 19:35:42 +02:00
Sheldan
6a31dfde8a added experience tracking and automatic role assigning at given levels
includes: set role command to set a role to a given level (it clears out previous levels)
automatic level config generation on startup
min/max/multiplier configuration
job to persist the xp of the previous minute
added delayed scheduler start, so that events have a discord context in order to function
added role listener to automatically add and mark roles when they are created/deleted
fixed user in a server not being created correctly
added role service to give users role given by id
added server reference to role
2020-04-11 17:21:55 +02:00
Sheldan
87c97d5069 added exception in case the feature is not known to the system 2020-04-10 12:06:46 +02:00
Sheldan
e84e384706 added ability to define and use default emotes (introduced them in starboard/embed deletion/command reactions/suggestions)
fixed post target validation for suggestions
2020-04-10 11:24:16 +02:00
3598 changed files with 162446 additions and 9858 deletions

2
.env Normal file
View File

@@ -0,0 +1,2 @@
REGISTRY_PREFIX=harbor.sheldan.dev/abstracto/
VERSION=1.5.39

42
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Bug Report
description: Found a bug that needs fixing?
body:
- type: checkboxes
attributes:
label: General Troubleshooting
description: You confirm to have made the following checks first.
options:
- label: I have checked for similar issues on the Issue-tracker.
required: true
- label: I have updated to the latest version
required: true
- label: I have checked the branches or the maintainers' PRs for upcoming bug fixes.
required: true
- type: textarea
attributes:
label: "Description"
description: "General information about the bug"
placeholder: "..."
validations:
required: true
- type: textarea
attributes:
label: "Steps to reproduce"
description: "What happened when the bug occurred?"
placeholder: "1. ..."
validations:
required: true
- type: textarea
attributes:
label: "Expected behaviour"
description: "What should happen?"
placeholder: "It should..."
validations:
required: true
- type: textarea
attributes:
label: "Actual behaviour"
description: "What did happen instead?"
placeholder: "It actually ..."
validations:
required: true

36
.github/ISSUE_TEMPLATE/feature.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: Feature request
description: Want some functionality added?
body:
- type: checkboxes
attributes:
label: General Information
description: You confirm to have made the following checks first.
options:
- label: I have checked for similar issues on the Issue-tracker.
required: true
- label: I have updated to the latest version
required: true
- label: I have checked the branches or the maintainers' PRs for upcoming features fixes.
required: true
- type: textarea
attributes:
label: "Description"
description: "General description of the feature"
placeholder: "..."
validations:
required: true
- type: textarea
attributes:
label: "Feature worth and general use"
description: "Why should this be in abstracto?"
placeholder: "..."
validations:
required: true
- type: textarea
attributes:
label: "Suggestions for implementation"
description: "Any ideas about what the feature should behave/look like? Commands?"
placeholder: "It should..."
validations:
required: false

51
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,51 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Execute Build
on:
push:
branches:
- master
- feature/**
- hotfix/**
- bugfix/**
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
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: Build with Maven
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
- name: Send Webhook Notification
if: always()
env:
JOB_STATUS: ${{ job.status }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
HOOK_OS_NAME: ${{ runner.os }}
WORKFLOW_NAME: ${{ github.workflow }}
run: |
git clone https://github.com/DiscordHooks/github-actions-discord-webhook.git webhook
bash webhook/send.sh $JOB_STATUS $WEBHOOK_URL
shell: bash

78
.github/workflows/release_manual.yml vendored Normal file
View 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-24.04
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"

3
.gitignore vendored
View File

@@ -23,3 +23,6 @@ target/
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
venv/

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 Sheldan
Copyright (c) 2023 Sheldan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

33
README.md Normal file
View File

@@ -0,0 +1,33 @@
# Abstracto
![Build](https://github.com/Sheldan/abstracto/workflows/Execute%20Build/badge.svg)
[![GitHub license](https://img.shields.io/github/license/Sheldan/abstracto)](https://github.com/Sheldan/abstracto/blob/master/LICENSE)
Abstracto represents a framework to be used as a basis for a Discord bot. It uses [JDA](https://github.com/DV8FromTheWorld/JDA/) as an API wrapper underneath
and provides an extensive tool set to create new commands and a wide range of commands out of the box.
This repository does not provide the full functionality in order to start a discord bot, because it requires a Main class.
## Technologies
* [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)
* [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.
* [Ehcache](https://github.com/ehcache/ehcache3) is used as a caching implementation.
* [Lombok](https://github.com/rzwitserloot/lombok) is used as a framework in order to speed up creation of container classes and builders.
* [Quartz](https://github.com/quartz-scheduler/quartz) is used as a scheduling framework in order to provide functionalities which either require a scheduled or cronjob behaviour.
* [Docker](https://github.com/docker) is used to package the application into an image and [Docker Compose](https://github.com/docker/compose) is used to build the images
* [Liquibase](https://github.com/liquibase/liquibase) is used to manage changes to the database
## Documentation
A detailed documentation of the pure form of Abstracto including the terminology and commands in HTML form is available [here](https://sheldan.github.io/abstracto-docs/current). The PDF is available [here](https://sheldan.github.io/abstracto-docs/current/documentation.pdf)
If you want to view the documentation to an earlier released version you need to append the desired version to the URL. The current version will be available aforementioned URL, but it is not right now, because Abstracto has not been released yet.
## Issues
If you find any issue, feel free to create a GitHub issue.
## License
This project is licensed under the MIT license.

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>anti-raid</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.5.42-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>anti-raid-impl</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core-int</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>anti-raid-int</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/liquibase.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,18 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>liquibase</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>.</outputDirectory>
<directory>${project.basedir}/src/main/resources/migrations</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>

View File

@@ -0,0 +1,10 @@
package dev.sheldan.abstracto.antiraid.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource("classpath:antiRaid-config.properties")
public class AntiRaidProperties {
}

View File

@@ -0,0 +1,36 @@
package dev.sheldan.abstracto.antiraid.listener;
import dev.sheldan.abstracto.antiraid.config.AntiRaidFeatureDefinition;
import dev.sheldan.abstracto.antiraid.service.MassPingService;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
import dev.sheldan.abstracto.core.listener.async.jda.AsyncMessageReceivedListener;
import dev.sheldan.abstracto.core.models.listener.MessageReceivedModel;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class MassPingMessageListener implements AsyncMessageReceivedListener {
@Autowired
private MassPingService massPingService;
@Override
public DefaultListenerResult execute(MessageReceivedModel model) {
Message message = model.getMessage();
if(message.getAuthor().isBot() || message.isWebhookMessage() || !message.isFromGuild() || !message.isFromType(ChannelType.TEXT)) {
return DefaultListenerResult.IGNORED;
}
massPingService.processMessage(message);
return DefaultListenerResult.PROCESSED;
}
@Override
public FeatureDefinition getFeature() {
return AntiRaidFeatureDefinition.ANTI_RAID;
}
}

View File

@@ -0,0 +1,113 @@
package dev.sheldan.abstracto.antiraid.service;
import dev.sheldan.abstracto.antiraid.config.AntiRaidPostTarget;
import dev.sheldan.abstracto.antiraid.model.MassPingNotificationModel;
import dev.sheldan.abstracto.core.models.ConditionContextInstance;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
import dev.sheldan.abstracto.core.service.*;
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.moderation.service.MuteService;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
@Component
@Slf4j
public class MassPingServiceBean implements MassPingService {
private static final String MASS_PING_MUTE_NOTIFICATION_TEMPLATE_KEY = "massPing_mute_notification";
private static final String LEVEL_CONDITION_NAME = "HAS_LEVEL";
private static final String LEVEL_CONDITION_USER_ID_PARAMETER = "userId";
private static final String LEVEL_CONDITION_LEVEL_PARAMETER = "level";
private static final String LEVEL_CONDITION_SERVER_PARAMETER = "serverId";
@Autowired
private ConfigService configService;
@Autowired
private MuteService muteService;
@Autowired
private TemplateService templateService;
@Autowired
private MassPingServiceBean self;
@Autowired
private PostTargetService postTargetService;
@Autowired
private ConditionService conditionService;
@Value("${abstracto.massPing.maxAllowedMentions}")
private Integer maxAllowedMentions;
@Autowired
private UserInServerManagementService userInServerManagementService;
@Autowired
private MemberService memberService;
@Override
public CompletableFuture<Void> processMessage(Message message) {
if(message.getMentions().getUsers().size() > maxAllowedMentions) {
Integer level = configService.getLongValueOrConfigDefault(MassPingService.MAX_AFFECTED_LEVEL_KEY, message.getGuild().getIdLong()).intValue();
boolean allowed = allowedToMassMention(message, level);
if(!allowed) {
return memberService.timeoutUserMaxDuration(message.getMember())
.thenAccept(unused -> self.sendMassPingMuteNotification(message))
.thenAccept(unused -> log.info("Muted member {} in server {} because of too many member mentions. (> {}).",
message.getAuthor().getIdLong(), message.getGuild().getIdLong(), maxAllowedMentions));
} else {
log.info("User {} in server {} is allowed to mass mention, because of level (or lack of level configuration).",
message.getAuthor().getIdLong(), message.getGuild().getIdLong());
return CompletableFuture.completedFuture(null);
}
} else {
return CompletableFuture.completedFuture(null);
}
}
private boolean allowedToMassMention(Message message, Integer level) {
log.info("Checking if member {} is allowed to mention a lot of users in server {}.", message.getAuthor().getIdLong(), message.getGuild().getIdLong());
Map<String, Object> parameters = new HashMap<>();
AUserInAServer userInAServer = userInServerManagementService.loadOrCreateUser(message.getMember());
parameters.put(LEVEL_CONDITION_USER_ID_PARAMETER, userInAServer.getUserInServerId());
parameters.put(LEVEL_CONDITION_LEVEL_PARAMETER, level);
parameters.put(LEVEL_CONDITION_SERVER_PARAMETER, message.getGuild().getIdLong());
ConditionContextInstance contextInstance = ConditionContextInstance
.builder()
.conditionName(LEVEL_CONDITION_NAME)
.parameters(parameters)
.build();
SystemCondition.Result result = conditionService.checkConditions(contextInstance);
return SystemCondition.Result.consideredSuccessful(result);
}
@Transactional
public CompletableFuture<Void> sendMassPingMuteNotification(Message message) {
Member member = message.getMember();
MassPingNotificationModel model = MassPingNotificationModel
.builder()
.messageLink(message.getJumpUrl())
.mentionCount(message.getMentions().getUsers().size())
.messageContent(message.getContentRaw())
.memberDisplay(MemberDisplay.fromMember(member))
.build();
MessageToSend messageToSend = templateService.renderEmbedTemplate(MASS_PING_MUTE_NOTIFICATION_TEMPLATE_KEY, model, member.getGuild().getIdLong());
return FutureUtils.toSingleFutureGeneric(postTargetService.sendEmbedInPostTarget(messageToSend, AntiRaidPostTarget.MASS_PING_LOG, member.getGuild().getIdLong()));
}
}

View File

@@ -0,0 +1,9 @@
abstracto.featureFlags.antiRaid.featureName=antiRaid
abstracto.featureFlags.antiRaid.enabled=false
abstracto.postTargets.massPingLog.name=massPingLog
abstracto.massPing.maxAllowedMentions=5
abstracto.systemConfigs.massPingMinLevel.name=massPingMinLevel
abstracto.systemConfigs.massPingMinLevel.longValue=15

View File

@@ -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="tables/tables.xml" relativeToChangelogFile="true"/>
<include file="seedData/data.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -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="feature.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,10 @@
<?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="anti_raid-feature-insertion">
<insert tableName="feature">
<column name="key" value="antiRaid"/>
</insert>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,5 @@
<?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" >
</databaseChangeLog>

View File

@@ -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="1.3.3/collection.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>anti-raid</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.5.42-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>anti-raid-int</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core-int</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>moderation-int</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,39 @@
package dev.sheldan.abstracto.antiraid.config;
import dev.sheldan.abstracto.antiraid.service.MassPingService;
import dev.sheldan.abstracto.core.config.FeatureConfig;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.config.PostTargetEnum;
import dev.sheldan.abstracto.moderation.config.feature.MutingFeatureConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
@Component
public class AntiRaidFeatureConfig implements FeatureConfig {
@Autowired
private MutingFeatureConfig mutingFeatureConfig;
@Override
public FeatureDefinition getFeature() {
return AntiRaidFeatureDefinition.ANTI_RAID;
}
@Override
public List<PostTargetEnum> getRequiredPostTargets() {
return Arrays.asList(AntiRaidPostTarget.MASS_PING_LOG);
}
@Override
public List<String> getRequiredSystemConfigKeys() {
return Arrays.asList(MassPingService.MAX_AFFECTED_LEVEL_KEY);
}
@Override
public List<FeatureConfig> getRequiredFeatures() {
return Arrays.asList(mutingFeatureConfig);
}
}

View File

@@ -0,0 +1,15 @@
package dev.sheldan.abstracto.antiraid.config;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import lombok.Getter;
@Getter
public enum AntiRaidFeatureDefinition implements FeatureDefinition {
ANTI_RAID("antiRaid");
private String key;
AntiRaidFeatureDefinition(String key) {
this.key = key;
}
}

View File

@@ -0,0 +1,15 @@
package dev.sheldan.abstracto.antiraid.config;
import dev.sheldan.abstracto.core.config.PostTargetEnum;
import lombok.Getter;
@Getter
public enum AntiRaidPostTarget implements PostTargetEnum {
MASS_PING_LOG("massPingLog");
private String key;
AntiRaidPostTarget(String key) {
this.key = key;
}
}

View File

@@ -0,0 +1,16 @@
package dev.sheldan.abstracto.antiraid.model;
import dev.sheldan.abstracto.core.models.template.display.MemberDisplay;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Builder
public class MassPingNotificationModel {
private MemberDisplay memberDisplay;
private String messageContent;
private String messageLink;
private Integer mentionCount;
}

View File

@@ -0,0 +1,10 @@
package dev.sheldan.abstracto.antiraid.service;
import net.dv8tion.jda.api.entities.Message;
import java.util.concurrent.CompletableFuture;
public interface MassPingService {
String MAX_AFFECTED_LEVEL_KEY = "massPingMinLevel";
CompletableFuture<Void> processMessage(Message message);
}

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>abstracto-modules</artifactId>
<groupId>dev.sheldan.abstracto.modules</groupId>
<version>1.5.42-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>anti-raid</artifactId>
<packaging>pom</packaging>
<modules>
<module>anti-raid-int</module>
<module>anti-raid-impl</module>
</modules>
</project>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>assignable-roles</artifactId>
<version>1.5.42-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>assignable-roles-impl</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/liquibase.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>assignable-roles-int</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>metrics-int</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,18 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>liquibase</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>.</outputDirectory>
<directory>${project.basedir}/src/main/resources/migrations</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>

View File

@@ -0,0 +1,69 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.models.database.AServer;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
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;
/**
* Command used to activate an {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace place}
*/
@Component
public class ActivateAssignableRolePlace extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService service;
@Autowired
private ServerManagementService serverManagementService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
AServer server = serverManagementService.loadServer(commandContext.getGuild());
return service.activateAssignableRolePlace(server, name)
.thenApply(unused -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
Parameter placeName = Parameter
.builder()
.name("name")
.type(String.class)
.templated(true)
.build();
List<Parameter> parameters = Arrays.asList(placeName);
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
return CommandConfiguration.builder()
.name("activateAssignableRolePlace")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.messageCommandOnly(true)
.async(true)
.supportsEmbedException(true)
.causesReaction(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,84 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleConditionType;
import dev.sheldan.abstracto.assignableroles.service.AssignableRoleConditionService;
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 net.dv8tion.jda.api.entities.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
@Component
public class AddAssignableRoleCondition extends AbstractConditionableCommand {
@Autowired
private AssignableRoleConditionService assignableRoleConditionService;
@Override
public CommandResult execute(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
Role role = (Role) parameters.get(1);
AssignableRoleConditionType configKey = (AssignableRoleConditionType) parameters.get(2);
String parameterValue = (String) parameters.get(3);
assignableRoleConditionService.createAssignableRoleCondition(name, role, configKey, parameterValue);
return CommandResult.fromSuccess();
}
@Override
public CommandConfiguration getConfiguration() {
Parameter placeName = Parameter
.builder()
.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();
Parameter conditionValue = Parameter
.builder()
.name("conditionParameter")
.type(String.class)
.templated(true)
.build();
List<Parameter> parameters = Arrays.asList(placeName, role, conditionKey, conditionValue);
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
return CommandConfiguration.builder()
.name("addAssignableRoleCondition")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.messageCommandOnly(true)
.supportsEmbedException(true)
.causesReaction(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,112 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.exception.AssignableRoleNotUsableException;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.models.FullEmote;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.service.RoleService;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import net.dv8tion.jda.api.entities.Role;
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;
/**
* Command used to add an {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRole assignableRole}
* to an {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace place}
*/
@Component
public class AddRoleToAssignableRolePost extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService service;
@Autowired
private RoleService roleService;
@Autowired
private ServerManagementService serverManagementService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
Role role = (Role) parameters.get(1);
String description = null;
if (parameters.size() > 2) {
description = (String) parameters.get(2);
}
FullEmote emote = null;
if(parameters.size() > 3) {
emote = (FullEmote) parameters.get(3);
}
AServer server = serverManagementService.loadServer(commandContext.getGuild());
// already used check via role and assignable role place name
if(!roleService.canBotInteractWithRole(role)) {
throw new AssignableRoleNotUsableException(role);
}
return service.addRoleToAssignableRolePlace(server, name, role, emote, description)
.thenApply(aVoid -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
Parameter placeName = Parameter
.builder()
.name("name")
.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);
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
return CommandConfiguration.builder()
.name("addRoleToAssignableRolePlace")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.causesReaction(true)
.messageCommandOnly(true)
.async(true)
.supportsEmbedException(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,20 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.core.command.config.ModuleInfo;
import dev.sheldan.abstracto.core.command.config.ModuleDefinition;
import org.springframework.stereotype.Component;
@Component
public class AssignableRoleModuleDefinition implements ModuleDefinition {
public static final String ASSIGNABLE_ROLES = "assignableRole";
@Override
public ModuleInfo getInfo() {
return ModuleInfo.builder().name(ASSIGNABLE_ROLES).templated(true).build();
}
@Override
public String getParentModule() {
return "default";
}
}

View File

@@ -0,0 +1,88 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRolePlaceParameterKey;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.models.database.AServer;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import lombok.extern.slf4j.Slf4j;
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;
/**
* Command used to change one attribute of an {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace place}
*/
@Component
@Slf4j
public class ChangeAssignableRolePlaceConfig extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService service;
@Autowired
private ServerManagementService serverManagementService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
AssignableRolePlaceParameterKey configKey = (AssignableRolePlaceParameterKey) parameters.get(1);
String parameterValue = (String) parameters.get(2);
AServer server = serverManagementService.loadServer(commandContext.getGuild());
return service.changeConfiguration(server, name, configKey, parameterValue)
.thenApply(aVoid -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
Parameter assignableRolePlaceName = Parameter
.builder()
.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);
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
return CommandConfiguration.builder()
.name("changeAssignableRolePlaceConfig")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.messageCommandOnly(true)
.async(true)
.supportsEmbedException(true)
.causesReaction(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,108 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlaceType;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.config.ParameterValidator;
import dev.sheldan.abstracto.core.command.config.validator.MaxStringLengthValidator;
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.exception.EntityGuildMismatchException;
import dev.sheldan.abstracto.core.models.database.AChannel;
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
@Component
public class CreateAssignableRolePost extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService service;
@Autowired
private ChannelManagementService channelManagementService;
@Override
public CommandResult execute(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
TextChannel channel = (TextChannel) parameters.get(1);
String text = (String) parameters.get(2);
AssignableRolePlaceType type = AssignableRolePlaceType.DEFAULT;
if(parameters.size() > 3) {
type = (AssignableRolePlaceType) parameters.get(3);
}
if(!channel.getGuild().equals(commandContext.getGuild())) {
throw new EntityGuildMismatchException();
}
AChannel chosenChannel = channelManagementService.loadChannel(channel.getIdLong());
service.createAssignableRolePlace(name, chosenChannel, text, type);
return CommandResult.fromSuccess();
}
@Override
public CommandConfiguration getConfiguration() {
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 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));
Parameter text = Parameter
.builder()
.name("text")
.validators(rolePlaceDescriptionValidator)
.type(String.class)
.templated(true)
.build();
List<String> aliases = Arrays.asList("crRPl", "crAssRoPl");
List<Parameter> parameters = Arrays.asList(rolePostName, channel, text, type);
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
return CommandConfiguration.builder()
.name("createAssignableRolePlace")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.supportsEmbedException(true)
.causesReaction(true)
.messageCommandOnly(true)
.parameters(parameters)
.aliases(aliases)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,69 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.models.database.AServer;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
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;
/**
* Command used to deactive an {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace place}
*/
@Component
public class DeactivateAssignableRolePlace extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService service;
@Autowired
private ServerManagementService serverManagementService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
AServer server = serverManagementService.loadServer(commandContext.getGuild());
return service.deactivateAssignableRolePlace(server, name)
.thenApply(unused -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
Parameter rolePostName = Parameter
.builder()
.name("name")
.type(String.class)
.templated(true)
.build();
List<Parameter> parameters = Arrays.asList(rolePostName);
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
return CommandConfiguration.builder()
.name("deactivateAssignableRolePlace")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.async(true)
.messageCommandOnly(true)
.supportsEmbedException(true)
.causesReaction(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,70 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.models.database.AServer;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
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;
/**
* Command used to delete an {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace place}
*/
@Component
public class DeleteAssignableRolePlace extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService service;
@Autowired
private ServerManagementService serverManagementService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
AServer server = serverManagementService.loadServer(commandContext.getGuild());
return service.deleteAssignableRolePlace(server, name)
.thenApply(aVoid -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
Parameter rolePostName = Parameter
.builder()
.name("name")
.type(String.class)
.templated(true)
.build();
List<Parameter> parameters = Arrays.asList(rolePostName);
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
return CommandConfiguration.builder()
.name("deleteAssignableRolePlace")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.causesReaction(true)
.async(true)
.messageCommandOnly(true)
.requiresConfirmation(true)
.supportsEmbedException(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,83 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.config.ParameterValidator;
import dev.sheldan.abstracto.core.command.config.validator.MaxStringLengthValidator;
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.models.database.AServer;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
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;
/**
* Command used to change the text of an {@link AssignableRolePlace place}
*/
@Component
public class EditAssignableRolePlaceText extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService service;
@Autowired
private ServerManagementService serverManagementService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
String newText = (String) parameters.get(1);
AServer server = serverManagementService.loadServer(commandContext.getGuild());
return service.changeTextAsync(server, name, newText)
.thenApply(aVoid -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
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 newText = Parameter
.builder()
.name("newText")
.type(String.class)
.templated(true)
.build();
List<Parameter> parameters = Arrays.asList(rolePostName, newText);
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
return CommandConfiguration.builder()
.name("editAssignableRolePlaceText")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.async(true)
.messageCommandOnly(true)
.supportsEmbedException(true)
.causesReaction(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,82 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.exception.EntityGuildMismatchException;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
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;
/**
* Command used to move an {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace place}
* to another {@link dev.sheldan.abstracto.core.models.database.AChannel channel}
*/
@Component
public class MoveAssignableRolePlace extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService placeManagementService;
@Autowired
private ServerManagementService serverManagementService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
TextChannel newChannel = (TextChannel) parameters.get(1);
if(!newChannel.getGuild().equals(commandContext.getGuild())) {
throw new EntityGuildMismatchException();
}
AServer server = serverManagementService.loadServer(commandContext.getGuild());
return placeManagementService.moveAssignableRolePlace(server, name, newChannel)
.thenApply(unused -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
Parameter rolePostName = Parameter
.builder()
.name("name")
.type(String.class)
.templated(true)
.build();
Parameter channel = Parameter
.builder()
.name("channel")
.type(TextChannel.class)
.templated(true)
.build();
List<Parameter> parameters = Arrays.asList(rolePostName, channel);
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
return CommandConfiguration.builder()
.name("moveAssignableRolePlace")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.causesReaction(true)
.messageCommandOnly(true)
.async(true)
.supportsEmbedException(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,74 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleConditionType;
import dev.sheldan.abstracto.assignableroles.service.AssignableRoleConditionService;
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 net.dv8tion.jda.api.entities.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
@Component
public class RemoveAssignableRoleCondition extends AbstractConditionableCommand {
@Autowired
private AssignableRoleConditionService assignableRoleConditionService;
@Override
public CommandResult execute(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
Role role = (Role) parameters.get(1);
AssignableRoleConditionType configKey = (AssignableRoleConditionType) parameters.get(2);
assignableRoleConditionService.deleteAssignableRoleCondition(name, role, configKey);
return CommandResult.fromSuccess();
}
@Override
public CommandConfiguration getConfiguration() {
Parameter placeName = Parameter
.builder()
.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);
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
return CommandConfiguration.builder()
.name("removeAssignableRoleCondition")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.messageCommandOnly(true)
.supportsEmbedException(true)
.causesReaction(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,81 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.models.database.ARole;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
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;
/**
* Command used to remove a {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRole role}
* from an {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace place}
*/
@Component
public class RemoveRoleFromAssignableRolePlace extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService service;
@Autowired
private ServerManagementService serverManagementService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
ARole role = (ARole) parameters.get(1);
AServer server = serverManagementService.loadServer(commandContext.getGuild());
return service.removeRoleFromAssignableRolePlace(server, name, role)
.thenApply(aVoid -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
Parameter rolePostName = Parameter
.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);
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
return CommandConfiguration.builder()
.name("removeRoleFromAssignableRolePlace")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.causesReaction(true)
.async(true)
.messageCommandOnly(true)
.supportsEmbedException(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,79 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.models.database.AServer;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import lombok.extern.slf4j.Slf4j;
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;
/**
* Command used to render the {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace place}
* and create the {@link net.dv8tion.jda.api.entities.Message messages} used to add {@link net.dv8tion.jda.api.entities.MessageReaction reactions} to
*/
@Component
@Slf4j
public class SetupAssignableRolePlace extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService service;
@Autowired
private ChannelService channelService;
@Autowired
private ServerManagementService serverManagementService;
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
AServer server = serverManagementService.loadServer(commandContext.getGuild());
return service.setupAssignableRolePlace(server, name)
.thenApply(aVoid -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
Parameter rolePostName = Parameter
.builder()
.name("name")
.type(String.class)
.templated(true)
.build();
List<Parameter> parameters = Arrays.asList(rolePostName);
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
return CommandConfiguration.builder()
.name("setupAssignableRolePlace")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.async(true)
.messageCommandOnly(true)
.supportsEmbedException(true)
.causesReaction(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,79 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.model.template.AssignableRolePlaceConfig;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.service.ChannelService;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import dev.sheldan.abstracto.core.utils.FutureUtils;
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;
/**
* Command used to show the configuration of an {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace place}
*/
@Component
public class ShowAssignableRolePlaceConfig extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService service;
@Autowired
private ServerManagementService serverManagementService;
@Autowired
private ChannelService channelService;
public static final String ASSIGNABLE_ROLES_CONFIG_POST_TEMPLATE_KEY = "assignable_roles_config_post";
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
List<Object> parameters = commandContext.getParameters().getParameters();
String name = (String) parameters.get(0);
AssignableRolePlaceConfig config = service.getAssignableRolePlaceConfig(commandContext.getGuild(), name);
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(ASSIGNABLE_ROLES_CONFIG_POST_TEMPLATE_KEY, config, commandContext.getChannel()))
.thenApply(unused -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
Parameter rolePostName = Parameter
.builder()
.name("name")
.type(String.class)
.templated(true)
.build();
List<Parameter> parameters = Arrays.asList(rolePostName);
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
return CommandConfiguration.builder()
.name("showAssignableRolePlaceConfig")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.async(true)
.causesReaction(false)
.messageCommandOnly(true)
.supportsEmbedException(true)
.parameters(parameters)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,67 @@
package dev.sheldan.abstracto.assignableroles.command;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.model.template.AssignablePlaceOverview;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceService;
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.CommandContext;
import dev.sheldan.abstracto.core.command.execution.CommandResult;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
import dev.sheldan.abstracto.core.utils.FutureUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
/**
* Command used to show all {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace places}
* within the current {@link AServer server}
*/
@Component
public class ShowAssignableRolePlaces extends AbstractConditionableCommand {
@Autowired
private AssignableRolePlaceService service;
@Autowired
private ServerManagementService serverManagementService;
@Autowired
private ChannelService channelService;
public static final String ASSIGNABLE_ROLE_PLACES_OVERVIEW_TEMPLATE_KEY = "assignable_role_places_overview";
@Override
public CompletableFuture<CommandResult> executeAsync(CommandContext commandContext) {
AssignablePlaceOverview model = service.getAssignableRolePlaceOverview(commandContext.getGuild());
return FutureUtils.toSingleFutureGeneric(channelService.sendEmbedTemplateInTextChannelList(ASSIGNABLE_ROLE_PLACES_OVERVIEW_TEMPLATE_KEY, model, commandContext.getChannel()))
.thenApply(unused -> CommandResult.fromSuccess());
}
@Override
public CommandConfiguration getConfiguration() {
HelpInfo helpInfo = HelpInfo
.builder()
.templated(true)
.build();
return CommandConfiguration.builder()
.name("showAssignableRolePlaces")
.module(AssignableRoleModuleDefinition.ASSIGNABLE_ROLES)
.templated(true)
.messageCommandOnly(true)
.async(true)
.supportsEmbedException(true)
.help(helpInfo)
.build();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,91 @@
package dev.sheldan.abstracto.assignableroles.condition;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleConditionType;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleMinLevelModel;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRolePlaceConditionModel;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleMinLevelResult;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRoleCondition;
import dev.sheldan.abstracto.assignableroles.model.template.condition.AssignableRoleConditionDisplay;
import dev.sheldan.abstracto.assignableroles.model.template.condition.AssignableRoleMinLevelDisplay;
import dev.sheldan.abstracto.core.models.ConditionContextInstance;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.models.template.display.RoleDisplay;
import dev.sheldan.abstracto.core.service.ConditionService;
import dev.sheldan.abstracto.core.service.SystemCondition;
import net.dv8tion.jda.api.entities.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class AssignableRoleMinimumLevelConditionImpl implements AssignableRoleConditionEvaluator {
private final String conditionName = "HAS_LEVEL";
private final String userIdParameter = "userId";
private final String levelParameter = "level";
private final String serverParameter = "serverId";
@Autowired
private ConditionService conditionService;
@Override
public boolean fulfillsCondition(AssignableRoleCondition conditionDefinition, AUserInAServer aUserInAServer) {
Integer level = parseLevel(conditionDefinition);
Map<String, Object> parameters = new HashMap<>();
parameters.put(userIdParameter, aUserInAServer.getUserInServerId());
parameters.put(levelParameter, level);
parameters.put(serverParameter, aUserInAServer.getServerReference().getId());
ConditionContextInstance contextInstance = ConditionContextInstance
.builder()
.conditionName(conditionName)
.parameters(parameters)
.build();
SystemCondition.Result result = conditionService.checkConditions(contextInstance);
return SystemCondition.Result.consideredSuccessful(result);
}
@Override
public boolean usableValue(String value) {
try {
parseLevelValue(value);
return true;
} catch (Exception exception) {
return false;
}
}
private Integer parseLevel(AssignableRoleCondition conditionDefinition) {
return parseLevelValue(conditionDefinition.getConditionValue());
}
private int parseLevelValue(String value) {
return Integer.parseInt(value);
}
@Override
public AssignableRolePlaceConditionModel createNotificationModel(AssignableRoleCondition conditionDefinition, Role role) {
Integer level = parseLevel(conditionDefinition);
AssignableRoleMinLevelModel model = AssignableRoleMinLevelModel
.builder()
.minLevel(level)
.roleDisplay(RoleDisplay.fromRole(role))
.build();
return AssignableRoleMinLevelResult
.builder()
.model(model)
.build();
}
@Override
public AssignableRoleConditionDisplay getConditionDisplay(AssignableRoleCondition conditionDefinition) {
return new AssignableRoleMinLevelDisplay(Integer.parseInt(conditionDefinition.getConditionValue()));
}
@Override
public boolean handlesCondition(AssignableRoleConditionType type) {
return AssignableRoleConditionType.MIN_LEVEL.equals(type);
}
}

View File

@@ -0,0 +1,10 @@
package dev.sheldan.abstracto.assignableroles.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource("classpath:assignableRoles-config.properties")
public class AssignableRolesConfig {
}

View File

@@ -0,0 +1,234 @@
package dev.sheldan.abstracto.assignableroles.listener;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.exception.AssignableRoleNotFoundException;
import dev.sheldan.abstracto.assignableroles.exception.BoosterAssignableRolePlaceMemberNotBoostingException;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleConditionResult;
import dev.sheldan.abstracto.assignableroles.model.AssignableRolePlacePayload;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRolePlaceConditionModel;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRole;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlaceType;
import dev.sheldan.abstracto.assignableroles.model.database.AssignedRoleUser;
import dev.sheldan.abstracto.assignableroles.model.template.AssignableRoleSuccessNotificationModel;
import dev.sheldan.abstracto.assignableroles.service.AssignableRoleConditionServiceBean;
import dev.sheldan.abstracto.assignableroles.service.AssignableRolePlaceServiceBean;
import dev.sheldan.abstracto.assignableroles.service.AssignableRoleService;
import dev.sheldan.abstracto.assignableroles.service.management.AssignableRolePlaceManagementService;
import dev.sheldan.abstracto.assignableroles.service.management.AssignedRoleUserManagementServiceBean;
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.ButtonClickedListenerResult;
import dev.sheldan.abstracto.core.interaction.button.listener.ButtonClickedListener;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.interaction.button.listener.ButtonClickedListenerModel;
import dev.sheldan.abstracto.core.service.RoleService;
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
import dev.sheldan.abstracto.core.utils.CompletableFutureList;
import dev.sheldan.abstracto.core.utils.FutureUtils;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonInteraction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@Component
@Slf4j
public class AssignableRoleButtonClickedListener implements ButtonClickedListener {
@Autowired
private AssignableRolePlaceManagementService assignableRolePlaceManagementService;
@Autowired
private RoleService roleService;
@Autowired
private AssignableRoleButtonClickedListener self;
@Autowired
private InteractionService interactionService;
@Autowired
private AssignableRoleService assignableRoleService;
@Autowired
private AssignedRoleUserManagementServiceBean assignedRoleUserManagementServiceBean;
@Autowired
private UserInServerManagementService userInServerManagementService;
@Autowired
private AssignableRoleConditionServiceBean assignableRoleConditionServiceBean;
@Override
public ButtonClickedListenerResult execute(ButtonClickedListenerModel model) {
ButtonInteractionEvent event = model.getEvent();
Member member = event.getMember();
if(event.getGuild() != null && member != null) {
AssignableRolePlacePayload payload = (AssignableRolePlacePayload) model.getDeserializedPayload();
AssignableRolePlace place = assignableRolePlaceManagementService.findByPlaceId(payload.getPlaceId());
Guild guild = event.getGuild();
List<Role> removedRoles = new ArrayList<>();
Role roleById = guild.getRoleById(payload.getRoleId());
Optional<AssignableRole> assignableRoleOptional = place
.getAssignableRoles()
.stream()
.filter(assignableRole -> assignableRole.getRole().getId().equals(payload.getRoleId()))
.findFirst();
if(!assignableRoleOptional.isPresent()) {
throw new AssignableRoleNotFoundException(payload.getRoleId());
}
if(roleById != null) {
boolean memberHasRole = member
.getRoles()
.stream()
.anyMatch(memberRole -> memberRole.getIdLong() == payload.getRoleId());
if(!memberHasRole) {
if(place.getType().equals(AssignableRolePlaceType.BOOSTER) && member.getTimeBoosted() == null) {
assignableRoleService.assignableRoleConditionFailure();
throw new BoosterAssignableRolePlaceMemberNotBoostingException();
}
AssignableRole assignableRole = assignableRoleOptional.get();
AUserInAServer aUserInAServer = userInServerManagementService.loadOrCreateUser(member);
if(!assignableRole.getConditions().isEmpty()) {
log.debug("Evaluating {} conditions for assignable role {}.", assignableRole.getConditions().size(), assignableRole.getId());
AssignableRoleConditionResult conditionResult =
assignableRoleConditionServiceBean.evaluateConditions(assignableRole.getConditions(), aUserInAServer, roleById);
if(!conditionResult.getFulfilled()) {
log.info("One condition failed to be fulfilled - notifying user.");
self.notifyUserAboutConditionFail(model, event.getInteraction(), conditionResult.getModel());
assignableRoleService.assignableRoleConditionFailure();
return ButtonClickedListenerResult.ACKNOWLEDGED;
}
}
CompletableFuture<Void> removalFuture;
if(place.getUniqueRoles()) {
Optional<AssignedRoleUser> assignedRoleUserOptional = assignedRoleUserManagementServiceBean.findByUserInServerOptional(aUserInAServer);
if(assignedRoleUserOptional.isPresent()) {
AssignedRoleUser roleUser = assignedRoleUserOptional.get();
List<Role> rolesToRemove = roleUser
.getRoles()
.stream()
.filter(roleOfUser -> roleOfUser.getAssignablePlace().equals(place))
.map(roleOfUser -> guild.getRoleById(roleOfUser.getRole().getId()))
.filter(Objects::nonNull)
.collect(Collectors.toList());
log.info("Removing {} because of unique role configuration in place {}.", rolesToRemove.size(), place.getId());
removedRoles.addAll(rolesToRemove);
List<CompletableFuture<Void>> removalFutures = new ArrayList<>();
rolesToRemove.forEach(roleToRemove -> removalFutures.add(roleService.removeRoleFromUserAsync(member, roleToRemove)));
removalFuture = new CompletableFutureList<>(removalFutures).getMainFuture();
} else {
removalFuture = CompletableFuture.completedFuture(null);
}
} else {
removalFuture = CompletableFuture.completedFuture(null);
}
CompletableFuture<Void> roleAdditionFuture = assignableRoleService.assignAssignableRoleToUser(roleById, member);
CompletableFuture.allOf(removalFuture, roleAdditionFuture).whenComplete((unused, throwable) -> {
if(throwable != null) {
log.error("Failed to either add or remove roles for assignable role place {} in server {}.", payload.getPlaceId(), guild.getIdLong());
}
if(!roleAdditionFuture.isCompletedExceptionally()) {
log.info("Added role {} to member {} in server {} for assignable role interaction {} on component {}.",
roleById.getId(), member.getId(), guild.getIdLong(), event.getInteraction().getId(), event.getComponentId());
self.notifyUser(model, true, roleById, event.getInteraction(), removedRoles).thenAccept(unused1 -> {
log.info("Persisting adding assignable role update for user {} in server {} of role {}.", member.getIdLong(), guild.getIdLong(), roleById.getId());
self.persistAssignableUser(member, payload, false);
});
}
}).exceptionally(throwable -> {
log.error("Failed to perform role change in assignable role place.", throwable);
return null;
});
} else {
assignableRoleService.removeAssignableRoleFromUser(roleById, member)
.thenAccept(unused -> {
self.notifyUser(model, false, roleById, event.getInteraction(), new ArrayList<>());
log.info("Removed role {} from member {} in server {} for assignable role interaction {} on component {}.",
roleById.getId(), member.getId(), guild.getIdLong(), event.getInteraction().getId(), event.getComponentId());
}).thenAccept(unused -> {
log.info("Persisting remove assignable role update for user {} in server {} of role {}.", member.getIdLong(), guild.getIdLong(), roleById.getId());
self.persistAssignableUser(member, payload, true);
});
}
} else {
log.warn("Role {} is not available to be assigned in assignable role place {} in server {}. Component {} failed.",
payload.getRoleId(), payload.getPlaceId(), guild.getIdLong(), event.getComponentId());
throw new AssignableRoleNotFoundException(payload.getRoleId());
}
}
return ButtonClickedListenerResult.ACKNOWLEDGED;
}
@Transactional
public void persistAssignableUser(Member member, AssignableRolePlacePayload payload, boolean removeRole){
AssignableRolePlace place = assignableRolePlaceManagementService.findByPlaceId(payload.getPlaceId());
AUserInAServer aUserInAServer = userInServerManagementService.loadOrCreateUser(member);
if(place.getUniqueRoles() && !removeRole) {
assignableRoleService.clearAllRolesOfUserInPlace(place, aUserInAServer);
}
Optional<AssignableRole> assignableRoleOptional = place
.getAssignableRoles()
.stream()
.filter(assignableRole -> assignableRole.getRole().getId().equals(payload.getRoleId()))
.findFirst();
if(assignableRoleOptional.isPresent()) {
if(removeRole) {
assignableRoleService.removeRoleFromUser(assignableRoleOptional.get(), aUserInAServer);
} else {
assignableRoleService.addRoleToUser(assignableRoleOptional.get(), aUserInAServer);
}
}
}
@Transactional
public CompletableFuture<Void> notifyUser(ButtonClickedListenerModel model, boolean roleAdded, Role role, ButtonInteraction buttonInteraction, List<Role> removedRoles) {
log.info("Notifying user {} in server {} in channel {} about role change with role {}.",
buttonInteraction.getUser().getIdLong(), buttonInteraction.getGuild().getIdLong(), buttonInteraction.getChannel().getIdLong(), role.getId());
AssignableRoleSuccessNotificationModel notificationModel = AssignableRoleSuccessNotificationModel
.builder()
.added(roleAdded)
.removedRoles(removedRoles)
.role(role)
.build();
return FutureUtils.toSingleFutureGeneric(
interactionService.sendMessageToInteraction("assignable_role_success_notification", notificationModel, buttonInteraction.getHook())) ;
}
@Transactional
public CompletableFuture<Void> notifyUserAboutConditionFail(ButtonClickedListenerModel model, ButtonInteraction buttonInteraction,
AssignableRolePlaceConditionModel conditionModel) {
log.info("Notifying user {} in server {} in channel {} about failed condition.", buttonInteraction.getUser().getIdLong(),
buttonInteraction.getGuild().getIdLong(), buttonInteraction.getChannel().getIdLong());
return FutureUtils.toSingleFutureGeneric(
interactionService.sendMessageToInteraction("assignable_role_condition_notification", conditionModel, buttonInteraction.getHook())) ;
}
@Override
public Boolean handlesEvent(ButtonClickedListenerModel model) {
return AssignableRolePlaceServiceBean.ASSIGNABLE_ROLE_COMPONENT_ORIGIN.equals(model.getOrigin()) && model.getEvent().isFromGuild();
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
@Override
public Integer getPriority() {
return ListenerPriority.MEDIUM;
}
}

View File

@@ -0,0 +1,112 @@
package dev.sheldan.abstracto.assignableroles.listener;
import dev.sheldan.abstracto.assignableroles.config.AssignableRoleFeatureDefinition;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRole;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlaceType;
import dev.sheldan.abstracto.assignableroles.model.database.AssignedRoleUser;
import dev.sheldan.abstracto.assignableroles.service.AssignableRoleService;
import dev.sheldan.abstracto.assignableroles.service.management.AssignableRoleManagementService;
import dev.sheldan.abstracto.assignableroles.service.management.AssignedRoleUserManagementService;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import dev.sheldan.abstracto.core.listener.DefaultListenerResult;
import dev.sheldan.abstracto.core.listener.async.jda.AsyncMemberBoostTimeUpdateListener;
import dev.sheldan.abstracto.core.models.ServerUser;
import dev.sheldan.abstracto.core.models.listener.BoostTimeUpdatedModel;
import dev.sheldan.abstracto.core.service.RoleService;
import dev.sheldan.abstracto.core.utils.FutureUtils;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@Component
@Slf4j
public class AssignableRolePlaceBoostTimeUpdateListener implements AsyncMemberBoostTimeUpdateListener {
@Autowired
private AssignedRoleUserManagementService assignedRoleUserManagementService;
@Autowired
private AssignableRoleManagementService assignableRoleManagementService;
@Autowired
private RoleService roleService;
@Autowired
private AssignableRoleService assignableRoleService;
@Autowired
private AssignableRolePlaceBoostTimeUpdateListener self;
@Override
public DefaultListenerResult execute(BoostTimeUpdatedModel model) {
Member member = model.getMember();
if(member.getTimeBoosted() == null) {
removeAssignedBoosterRoles(member);
return DefaultListenerResult.PROCESSED;
}
return DefaultListenerResult.IGNORED;
}
private void removeAssignedBoosterRoles(Member member) {
log.info("Member {} in server {} stopped boosting.", member.getIdLong(), member.getGuild().getIdLong());
ServerUser serverUser = ServerUser.fromMember(member);
Optional<AssignedRoleUser> assignedRoleUserOptional = assignedRoleUserManagementService.findByUserInServerOptional(serverUser);
if(assignedRoleUserOptional.isPresent()) {
AssignedRoleUser assignedRoleUser = assignedRoleUserOptional.get();
List<AssignableRole> boosterRoles = assignableRoleManagementService.getAssignableRolesFromAssignableUserWithPlaceType(assignedRoleUser, AssignableRolePlaceType.BOOSTER);
if(!boosterRoles.isEmpty()) {
log.info("Removing {} assignable role mappings.", boosterRoles.size());
Guild guild = member.getGuild();
List<Role> actualRolesToDelete = boosterRoles
.stream()
.map(assignableRole -> guild.getRoleById(assignableRole.getRole().getId()))
.filter(Objects::nonNull)
.collect(Collectors.toList());
log.debug("Which translated to {} roles in reality.", actualRolesToDelete.size());
List<CompletableFuture<Void>> list = new ArrayList<>();
actualRolesToDelete.forEach(role -> list.add(roleService.removeRoleFromUserAsync(member, role)));
FutureUtils.toSingleFutureGeneric(list)
.thenAccept(unused -> self.clearPersistedBoosterAssignableRoles(member))
.exceptionally(throwable -> {
log.warn("One or more roles might have failed to remove. ", throwable);
self.clearPersistedBoosterAssignableRoles(member);
return null;
});
} else {
log.info("Member {} in server {} did not have boost roles - doing nothing.", member.getIdLong(), member.getGuild().getIdLong());
}
} else {
log.info("Member (ID {}) in server (ID: {}), who was not tracked via assignable roles, stopped boosting - doing nothing.",
member.getIdLong(), member.getGuild().getIdLong());
}
}
@Transactional
public void clearPersistedBoosterAssignableRoles(Member member) {
ServerUser serverUser = ServerUser.fromMember(member);
Optional<AssignedRoleUser> assignedRoleUserOptional = assignedRoleUserManagementService.findByUserInServerOptional(serverUser);
if(assignedRoleUserOptional.isPresent()) {
AssignedRoleUser assignedRoleUser = assignedRoleUserOptional.get();
List<AssignableRole> boosterRoles = assignableRoleManagementService.getAssignableRolesFromAssignableUserWithPlaceType(assignedRoleUser, AssignableRolePlaceType.BOOSTER);
assignableRoleService.removeAssignableRolesFromAssignableRoleUser(boosterRoles, assignedRoleUser);
} else {
log.warn("No assigned role user found for member {} in server {}.", member.getIdLong(), member.getGuild().getIdLong());
}
}
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,14 @@
package dev.sheldan.abstracto.assignableroles.model;
import dev.sheldan.abstracto.core.interaction.button.ButtonPayload;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Builder
public class AssignableRolePlacePayload implements ButtonPayload {
private Long placeId;
private Long roleId;
}

View File

@@ -0,0 +1,14 @@
package dev.sheldan.abstracto.assignableroles.repository;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleConditionType;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRole;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRoleCondition;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface AssignableRoleConditionRepository extends JpaRepository<AssignableRoleCondition, Long> {
Optional<AssignableRoleCondition> findByAssignableRoleAndType(AssignableRole assignableRole, AssignableRoleConditionType type);
}

View File

@@ -0,0 +1,41 @@
package dev.sheldan.abstracto.assignableroles.repository;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace;
import dev.sheldan.abstracto.core.models.database.AServer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
/**
* Repository to manage the access to the table managed by {@link AssignableRolePlace place}
*/
@Repository
public interface AssignableRolePlaceRepository extends JpaRepository<AssignableRolePlace, Long> {
/**
* Whether or not an {@link AssignableRolePlace place} exists in a {@link AServer server} with the given key
* @param server The {@link AServer server} to search in
* @param key The key to search for
* @return Whether or not a {@link AssignableRolePlace place} exists in the {@link AServer server} with the key
*/
boolean existsByServerAndKey(AServer server, String key);
/**
* Finds an {@link AssignableRolePlace place} in a {@link AServer server} with the given key,
* returns an empty {@link Optional optional} otherwise
* @param server The {@link AServer server} to search in
* @param key The key to search for
* @return An {@link Optional optional} containing the {@link AssignableRolePlace place} if it exists, empty otherwise.
*/
Optional<AssignableRolePlace> findByServerAndKey(AServer server, String key);
/**
* Finds all {@link AssignableRolePlace places} in the given {@link AServer server}
* @param server The {@link AServer server} to retrieve {@link AssignableRolePlace places} for
* @return A list of {@link AssignableRolePlace places} which were found in the given {@link AServer server}
*/
List<AssignableRolePlace> findByServer(AServer server);
}

View File

@@ -0,0 +1,17 @@
package dev.sheldan.abstracto.assignableroles.repository;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRole;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlaceType;
import dev.sheldan.abstracto.assignableroles.model.database.AssignedRoleUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Repository to manage the access to the table managed by {@link AssignableRole assignableRole}
*/
@Repository
public interface AssignableRoleRepository extends JpaRepository<AssignableRole, Long> {
List<AssignableRole> findByAssignedUsersContainingAndAssignablePlace_Type(AssignedRoleUser roleUser, AssignableRolePlaceType type);
}

View File

@@ -0,0 +1,12 @@
package dev.sheldan.abstracto.assignableroles.repository;
import dev.sheldan.abstracto.assignableroles.model.database.AssignedRoleUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* Repository to manage the access to the table managed by {@link AssignedRoleUser assignedRoleUser}
*/
@Repository
public interface AssignedRoleUserRepository extends JpaRepository<AssignedRoleUser, Long> {
}

View File

@@ -0,0 +1,132 @@
package dev.sheldan.abstracto.assignableroles.service;
import dev.sheldan.abstracto.assignableroles.condition.AssignableRoleConditionEvaluator;
import dev.sheldan.abstracto.assignableroles.exception.AssignableRoleConditionAlreadyExistsException;
import dev.sheldan.abstracto.assignableroles.exception.AssignableRoleConditionValueNotUsableException;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleConditionResult;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleConditionType;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRole;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRoleCondition;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace;
import dev.sheldan.abstracto.assignableroles.exception.AssignableRoleConditionDoesNotExistException;
import dev.sheldan.abstracto.assignableroles.model.template.condition.AssignableRoleConditionDisplay;
import dev.sheldan.abstracto.assignableroles.service.management.AssignableRoleConditionManagementService;
import dev.sheldan.abstracto.assignableroles.service.management.AssignableRolePlaceManagementService;
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 lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
@Component
@Slf4j
public class AssignableRoleConditionServiceBean implements AssignableRoleConditionService {
@Autowired
private List<AssignableRoleConditionEvaluator> assignableRoleConditionEvaluators;
@Autowired
private UserInServerManagementService userInServerManagementService;
@Autowired
private AssignableRolePlaceManagementService assignableRolePlaceManagementService;
@Autowired
private ServerManagementService serverManagementService;
@Autowired
private AssignableRoleService assignableRoleService;
@Autowired
private AssignableRoleConditionManagementService assignableRoleConditionManagementService;
@Override
public AssignableRoleConditionResult evaluateConditions(List<AssignableRoleCondition> conditions, Member member, Role role) {
AUserInAServer aUserInAServer = userInServerManagementService.loadOrCreateUser(member);
return evaluateConditions(conditions, aUserInAServer, role);
}
@Override
public AssignableRoleConditionResult evaluateConditions(List<AssignableRoleCondition> conditions, AUserInAServer aUserInAServer, Role role) {
log.debug("Evaluating {} conditions for role {}.", conditions.size(), role.getId());
for (AssignableRoleCondition condition : conditions) {
if(assignableRoleConditionEvaluators != null) {
Optional<AssignableRoleConditionEvaluator> evaluatorOptional = findEvaluatorForCondition(condition.getType());
if(evaluatorOptional.isPresent()) {
AssignableRoleConditionEvaluator evaluator = evaluatorOptional.get();
log.debug("Evaluating condition {} with evaluator {}.", condition.getType(), evaluator.getClass());
if(!evaluator.fulfillsCondition(condition, aUserInAServer)) {
log.info("Condition {} failed for role {} in server {}.", condition.getType(), role.getId(), aUserInAServer.getServerReference().getId());
return AssignableRoleConditionResult.fromFail(condition.getType(), evaluator.createNotificationModel(condition, role));
}
}
}
}
return AssignableRoleConditionResult.fromSuccess();
}
private Optional<AssignableRoleConditionEvaluator> findEvaluatorForCondition(AssignableRoleConditionType type) {
return assignableRoleConditionEvaluators
.stream()
.filter(assignableRoleConditionEvaluator -> assignableRoleConditionEvaluator.handlesCondition(type))
.findFirst();
}
@Override
public AssignableRoleCondition createAssignableRoleCondition(String placeName, Role role, AssignableRoleConditionType type, String value) {
AServer server = serverManagementService.loadServer(role.getGuild());
AssignableRolePlace place = assignableRolePlaceManagementService.findByServerAndKey(server, placeName);
AssignableRole assignableRole = assignableRoleService.getAssignableRoleInPlace(place, role);
Optional<AssignableRoleConditionEvaluator> evaluatorOptional = findEvaluatorForCondition(type);
if(!evaluatorOptional.isPresent()) {
throw new AssignableRoleConditionDoesNotExistException();
}
evaluatorOptional.ifPresent(evaluator -> {
boolean valueUsable = evaluator.usableValue(value);
if(!valueUsable) {
throw new AssignableRoleConditionValueNotUsableException();
}
});
if(assignableRoleConditionManagementService.findAssignableRoleCondition(assignableRole, type).isPresent()) {
throw new AssignableRoleConditionAlreadyExistsException();
}
log.info("Creating new condition for role {} in place {} in server {}.", place.getId(), role.getId(), role.getGuild().getIdLong());
return assignableRoleConditionManagementService.createAssignableRoleCondition(assignableRole, type, value);
}
@Override
public void deleteAssignableRoleCondition(String placeName, Role role, AssignableRoleConditionType type) {
AServer server = serverManagementService.loadServer(role.getGuild());
AssignableRolePlace place = assignableRolePlaceManagementService.findByServerAndKey(server, placeName);
AssignableRole assignableRole = assignableRoleService.getAssignableRoleInPlace(place, role);
Optional<AssignableRoleCondition> existingCondition = assignableRoleConditionManagementService.findAssignableRoleCondition(assignableRole, type);
if(!existingCondition.isPresent()) {
throw new AssignableRoleConditionDoesNotExistException();
}
log.info("Deleting assignable role condition on place {} for role {} in server {}.", place.getId(), role.getId(), role.getGuild().getIdLong());
existingCondition.ifPresent(condition -> assignableRoleConditionManagementService.deleteAssignableRoleCondition(condition));
}
@Override
public List<AssignableRoleConditionDisplay> getConditionDisplays(List<AssignableRoleCondition> conditions) {
return conditions.stream().map(condition -> {
Optional<AssignableRoleConditionEvaluator> evaluatorOptional = findEvaluatorForCondition(condition.getType());
if(evaluatorOptional.isPresent()) {
AssignableRoleConditionEvaluator evaluator = evaluatorOptional.get();
return evaluator.getConditionDisplay(condition);
}
return null;
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,528 @@
package dev.sheldan.abstracto.assignableroles.service;
import dev.sheldan.abstracto.assignableroles.config.AssignableRolePlaceParameterKey;
import dev.sheldan.abstracto.assignableroles.exception.*;
import dev.sheldan.abstracto.assignableroles.model.AssignableRolePlacePayload;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRole;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlaceType;
import dev.sheldan.abstracto.assignableroles.model.template.*;
import dev.sheldan.abstracto.assignableroles.service.management.*;
import dev.sheldan.abstracto.core.command.exception.CommandParameterKeyValueWrongTypeException;
import dev.sheldan.abstracto.core.exception.ChannelNotInGuildException;
import dev.sheldan.abstracto.core.exception.EmoteNotUsableException;
import dev.sheldan.abstracto.core.interaction.ComponentPayloadManagementService;
import dev.sheldan.abstracto.core.interaction.ComponentPayloadService;
import dev.sheldan.abstracto.core.interaction.ComponentService;
import dev.sheldan.abstracto.core.models.FullEmote;
import dev.sheldan.abstracto.core.models.database.AChannel;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.models.database.ComponentPayload;
import dev.sheldan.abstracto.core.models.template.display.ChannelDisplay;
import dev.sheldan.abstracto.core.models.template.display.RoleDisplay;
import dev.sheldan.abstracto.core.service.*;
import dev.sheldan.abstracto.core.service.management.*;
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
import dev.sheldan.abstracto.core.templating.service.TemplateService;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@Component
@Slf4j
public class AssignableRolePlaceServiceBean implements AssignableRolePlaceService {
public static final String ASSIGNABLE_ROLES_POST_TEMPLATE_KEY = "assignable_roles_post";
public static final int MAX_ASSIGNABLE_ROLES_PER_POST = ComponentService.MAX_BUTTONS_PER_ROW * 5;
public static final String ASSIGNABLE_ROLE_COMPONENT_ORIGIN = "assignableRoleButton";
@Autowired
private AssignableRolePlaceManagementService rolePlaceManagementService;
@Autowired
private AssignableRoleManagementService assignableRoleManagementServiceBean;
@Autowired
private MessageService messageService;
@Autowired
private ChannelService channelService;
@Autowired
private GuildService guildService;
@Autowired
private EmoteService emoteService;
@Autowired
private AssignableRolePlaceServiceBean self;
@Autowired
private TemplateService templateService;
@Autowired
private ChannelManagementService channelManagementService;
@Autowired
private ComponentService componentService;
@Autowired
private ComponentPayloadManagementService componentPayloadManagementService;
@Autowired
private ComponentPayloadService componentPayloadService;
@Autowired
private AssignableRolePlaceManagementServiceBean assignableRolePlaceManagementServiceBean;
@Autowired
private AssignableRoleConditionService assignableRoleConditionService;
@Autowired
private AssignedRoleUserManagementServiceBean assignedRoleUserManagementServiceBean;
@Autowired
private ServerManagementService serverManagementService;
@Override
public void createAssignableRolePlace(String name, AChannel channel, String text, AssignableRolePlaceType type) {
if (rolePlaceManagementService.doesPlaceExist(channel.getServer(), name)) {
throw new AssignableRolePlaceAlreadyExistsException(name);
}
rolePlaceManagementService.createPlace(name, channel, text, type);
}
@Override
@Transactional
public CompletableFuture<Void> addRoleToAssignableRolePlace(AServer server, String placeName, Role role, FullEmote fakeEmote, String description) {
AssignableRolePlace assignableRolePlace = rolePlaceManagementService.findByServerAndKey(server, placeName);
if (assignableRolePlace.getAssignableRoles().size() > MAX_ASSIGNABLE_ROLES_PER_POST) {
log.info("Assignable role place {} has already {} roles. Not possible to add more.", assignableRolePlace.getId(), assignableRolePlace.getAssignableRoles().size());
throw new AssignableRolePlaceMaximumRolesException();
}
if (assignableRolePlace.getAssignableRoles().stream().anyMatch(assignableRole -> assignableRole.getRole().getId().equals(role.getIdLong()))) {
throw new AssignableRoleAlreadyDefinedException(role, placeName);
}
Long placeId = assignableRolePlace.getId();
Long serverId = server.getId();
if (fakeEmote != null && fakeEmote.getEmote() != null) {
// it only may be unusable if its a custom emote
log.debug("Using custom emote {} to create assignable role {} for assignable role place {} in server {}.",
fakeEmote.getEmote().getId(), role.getId(), placeId, serverId);
if (!emoteService.isEmoteUsableByBot(fakeEmote.getEmote())) {
throw new EmoteNotUsableException(fakeEmote.getEmote());
}
}
Optional<GuildMessageChannel> channelOptional = channelService.getMessageChannelFromServerOptional(server.getId(), assignableRolePlace.getChannel().getId());
if (channelOptional.isPresent()) {
GuildMessageChannel textChannel = channelOptional.get();
String buttonId = componentService.generateComponentId();
String emoteMarkdown = fakeEmote != null ? fakeEmote.getEmoteRepr() : null;
if (assignableRolePlace.getMessageId() != null) {
log.debug("Assignable role place {} has already message post with ID {} - updating.", assignableRolePlace.getId(), assignableRolePlace.getMessageId());
return componentService.addButtonToMessage(assignableRolePlace.getMessageId(), textChannel, buttonId, description, emoteMarkdown, ButtonStyle.SECONDARY)
.thenAccept(message -> self.persistAssignableRoleAddition(placeId, role, description, fakeEmote, buttonId));
} else {
log.info("Assignable role place {} is not yet setup - only adding role to the database.", assignableRolePlace.getId());
self.persistAssignableRoleAddition(placeId, role, description, fakeEmote, buttonId);
return CompletableFuture.completedFuture(null);
}
} else {
throw new ChannelNotInGuildException(assignableRolePlace.getChannel().getId());
}
}
@Transactional
public void persistAssignableRoleAddition(Long placeId, Role role, String description, FullEmote fakeEmote, String componentId) {
AssignableRolePlace place = assignableRolePlaceManagementServiceBean.findByPlaceId(placeId);
log.info("Adding role {} to assignable role place {} with component ID {}.", role.getId(), place.getId(), componentId);
ComponentPayload payload = persistButtonCallback(place, componentId, role.getIdLong());
assignableRoleManagementServiceBean.addRoleToPlace(fakeEmote, role, description, place, payload);
}
@Override
public CompletableFuture<Void> removeRoleFromAssignableRolePlace(AServer server, String placeName, ARole role) {
AssignableRolePlace assignableRolePlace = rolePlaceManagementService.findByServerAndKey(server, placeName);
Long assignableRolePlaceId = assignableRolePlace.getId();
for (AssignableRole assignableRole : assignableRolePlace.getAssignableRoles()) {
if (assignableRole.getRole().getId().equals(role.getId())) {
log.info("Found {} role to be removed - removing button from place.", role.getId());
// TODO we might want to actually remove all the assigned roles as well
return removeButtonFromAssignableRolePlace(assignableRole, assignableRolePlace).thenAccept(aVoid ->
self.deleteAssignableRoleFromPlace(assignableRolePlaceId, assignableRole.getId())
);
}
}
throw new AssignableRoleNotFoundException(role.getId());
}
private CompletableFuture<Void> removeButtonFromAssignableRolePlace(AssignableRole assignableRole, AssignableRolePlace assignableRolePlace) {
String componentId = assignableRole.getComponentPayload().getId();
log.debug("Component ID to remove {} for role {}", componentId, assignableRole.getRole().getId());
return channelService.retrieveMessageInChannel(assignableRolePlace.getServer().getId(), assignableRolePlace.getChannel().getId(), assignableRolePlace.getMessageId())
.thenCompose(message -> {
log.debug("Updating message {} to remove component with ID {}.", message.getIdLong(), componentId);
return componentService.removeComponentWithId(message, componentId, true);
}
);
}
@Transactional
public void deleteAssignableRoleFromPlace(Long placeId, Long assignableRoleId) {
AssignableRolePlace assignableRolePlace = rolePlaceManagementService.findByPlaceId(placeId);
log.info("Deleting the entry for assignable role {} in assignable role place {}.", assignableRoleId, placeId);
Optional<AssignableRole> roleToRemoveOptional = assignableRolePlace
.getAssignableRoles()
.stream()
.filter(role -> role.getId().equals(assignableRoleId))
.findAny();
roleToRemoveOptional.ifPresent(assignableRole -> {
ComponentPayload componentPayload = assignableRole.getComponentPayload();
assignedRoleUserManagementServiceBean.removeAssignedRoleFromUsers(assignableRole);
assignableRoleManagementServiceBean.deleteAssignableRole(assignableRole);
componentPayloadManagementService.deletePayload(componentPayload);
});
if (!roleToRemoveOptional.isPresent()) {
log.warn("Assignable role with ID {} was not present in assignable role place {}.", assignableRoleId, placeId);
}
}
@Override
public CompletableFuture<Void> setupAssignableRolePlace(AServer server, String name) {
AssignableRolePlace assignableRolePlace = rolePlaceManagementService.findByServerAndKey(server, name);
log.info("Setting up assignable role place {} in server {} towards channel {}.", assignableRolePlace.getId(), server.getId(), assignableRolePlace.getChannel().getId());
CompletableFuture<Void> oldPostDeletionFuture = deleteExistingMessagePostsForPlace(assignableRolePlace);
Long serverId = server.getId();
Long assignablePlaceId = assignableRolePlace.getId();
CompletableFuture<Void> postingFuture = new CompletableFuture<>();
oldPostDeletionFuture.whenComplete((unused, throwable) -> {
if (throwable != null) {
log.warn("Not able to delete old messages of assignable role place {} in server {}.", assignablePlaceId, serverId);
}
self.createAssignableRolePlacePost(serverId, assignablePlaceId)
.thenAccept(unused1 -> postingFuture.complete(null))
.exceptionally(innerThrowable -> {
postingFuture.completeExceptionally(innerThrowable);
return null;
});
}).exceptionally(throwable -> {
postingFuture.completeExceptionally(throwable);
return null;
});
return postingFuture;
}
@Override
public CompletableFuture<Void> refreshTextFromPlace(AssignableRolePlace place) {
AssignablePostMessage model = prepareAssignablePostMessageModel(place);
MessageToSend messageToSend = templateService.renderEmbedTemplate(ASSIGNABLE_ROLES_POST_TEMPLATE_KEY, model, place.getServer().getId());
Long channelId = place.getChannel().getId();
Optional<GuildMessageChannel> channelOptional = channelService.getMessageChannelFromServerOptional(place.getServer().getId(), channelId);
if (channelOptional.isPresent()) {
log.info("Refreshing text for assignable role place {} in channel {} in post {}.", place.getId(), channelId, place.getMessageId());
return channelService.editEmbedMessageInAChannel(messageToSend.getEmbeds().get(0), channelOptional.get(), place.getMessageId()).thenCompose(message -> CompletableFuture.completedFuture(null));
} else {
throw new ChannelNotInGuildException(channelId);
}
}
@Override
public CompletableFuture<Void> setAssignablePlaceActiveTo(AServer server, String name, Boolean newValue) {
AssignableRolePlace place = rolePlaceManagementService.findByServerAndKey(server, name);
if (newValue) {
return this.activateAssignableRolePlace(place);
} else {
return this.deactivateAssignableRolePlace(place);
}
}
private CompletableFuture<Void> deleteExistingMessagePostsForPlace(AssignableRolePlace assignableRolePlace) {
if (assignableRolePlace.getMessageId() != null) {
log.info("Deleting old message {} for assignable role place {}.", assignableRolePlace.getMessageId(), assignableRolePlace.getId());
return messageService.deleteMessageInChannelInServer(assignableRolePlace.getServer().getId(), assignableRolePlace.getChannel().getId(), assignableRolePlace.getMessageId());
} else {
log.info("Assignable role place {} was not yet set up - no message ID tracked.", assignableRolePlace.getMessageId());
return CompletableFuture.completedFuture(null);
}
}
@Override
public CompletableFuture<Void> deactivateAssignableRolePlace(AServer server, String name) {
return setAssignablePlaceActiveTo(server, name, false);
}
@Override
public CompletableFuture<Void> deactivateAssignableRolePlace(AssignableRolePlace place) {
log.info("Deactivating assignable role place {} in server {}", place.getId(), place.getServer().getId());
return channelService.retrieveMessageInChannel(place.getServer().getId(), place.getChannel().getId(), place.getMessageId())
.thenCompose(message ->
componentService.disableAllButtons(message)
);
}
@Override
public CompletableFuture<Void> activateAssignableRolePlace(AServer server, String name) {
return setAssignablePlaceActiveTo(server, name, true);
}
@Override
public CompletableFuture<Void> activateAssignableRolePlace(AssignableRolePlace place) {
log.info("Activating assignable role place {} in server {}", place.getId(), place.getServer().getId());
return channelService.retrieveMessageInChannel(place.getServer().getId(), place.getChannel().getId(), place.getMessageId())
.thenCompose(message ->
componentService.enableAllButtons(message)
);
}
@Override
public void setAssignablePlaceUniqueTo(AServer server, String name, Boolean newValue) {
AssignableRolePlace place = rolePlaceManagementService.findByServerAndKey(server, name);
if (newValue) {
this.uniqueAssignableRolePlace(place);
} else {
this.multipleAssignableRolePlace(place);
}
}
@Override
public void uniqueAssignableRolePlace(AServer server, String name) {
setAssignablePlaceUniqueTo(server, name, true);
}
@Override
public void uniqueAssignableRolePlace(AssignableRolePlace place) {
log.info("Setting assignable role place uniqueness {} in server {} to {}", place.getId(), place.getServer().getId(), true);
place.setUniqueRoles(true);
}
@Override
public void multipleAssignableRolePlace(AServer server, String name) {
setAssignablePlaceUniqueTo(server, name, false);
}
@Override
public void multipleAssignableRolePlace(AssignableRolePlace place) {
log.info("Setting assignable role place uniqueness {} in server {} to {}", place.getId(), place.getServer().getId(), false);
place.setUniqueRoles(false);
}
@Override
public AssignableRolePlaceConfig getAssignableRolePlaceConfig(Guild guild, String name) {
AServer server = serverManagementService.loadServer(guild);
AssignableRolePlace place = rolePlaceManagementService.findByServerAndKey(server, name);
log.info("Generating assignable role place config for place {} on server {}.", place.getId(), guild.getIdLong());
return convertPlaceToAssignableRolePlaceConfig(guild, place);
}
private AssignableRolePlaceConfig convertPlaceToAssignableRolePlaceConfig(Guild guild, AssignableRolePlace place) {
List<AssignableRolePlaceConfigRole> roles = new ArrayList<>();
List<AssignableRole> assignableRoles = place.getAssignableRoles();
for (AssignableRole role : assignableRoles) {
Role jdaRole = guild.getRoleById(role.getRole().getId());
RoleDisplay display = jdaRole != null ? RoleDisplay.fromRole(jdaRole) : RoleDisplay.fromARole(role.getRole());
AssignableRolePlaceConfigRole postRole = AssignableRolePlaceConfigRole
.builder()
.description(role.getDescription())
.emoteMarkDown(role.getEmoteMarkdown())
.conditions(assignableRoleConditionService.getConditionDisplays(role.getConditions()))
.roleDisplay(display)
.build();
roles.add(postRole);
}
TextChannel placeChannel = guild.getTextChannelById(place.getChannel().getId());
return AssignableRolePlaceConfig
.builder()
.roles(roles)
.type(place.getType())
.placeName(place.getKey())
.placeText(place.getText())
.uniqueRoles(place.getUniqueRoles())
.channelDisplay(ChannelDisplay.fromChannel(placeChannel))
.build();
}
@Override
public CompletableFuture<Void> moveAssignableRolePlace(AServer server, String name, TextChannel newChannel) {
AssignableRolePlace place = rolePlaceManagementService.findByServerAndKey(server, name);
log.info("Moving assignable role place {} from channel {} to channel {} in guild {}.",
place.getId(), place.getChannel().getId(), newChannel.getId(), newChannel.getGuild().getIdLong());
CompletableFuture<Void> oldPostDeletionFuture = deleteExistingMessagePostsForPlace(place);
Long serverId = server.getId();
Long assignablePlaceId = place.getId();
CompletableFuture<Void> returnFuture = new CompletableFuture<>();
oldPostDeletionFuture.whenComplete((unused, throwable) -> {
if (throwable != null) {
log.warn("Not able to delete old messages of assignable role place {} in server {}.", assignablePlaceId, serverId);
}
self.setupAssignableRolePlaceInChannel(serverId, assignablePlaceId, newChannel)
.thenAccept(unused1 -> self.updateAssignableRolePlaceChannel(name, newChannel))
.thenAccept(unused1 -> returnFuture.complete(null))
.exceptionally(innerThrowable -> {
returnFuture.completeExceptionally(innerThrowable);
return null;
});
}).exceptionally(throwable -> {
returnFuture.completeExceptionally(throwable);
return null;
});
return returnFuture;
}
@Transactional
public void updateAssignableRolePlaceChannel(String name, TextChannel textChannel) {
AChannel channel = channelManagementService.loadChannel(textChannel.getIdLong());
log.info("Setting assignable role place to channel {}.", textChannel.getIdLong());
rolePlaceManagementService.moveAssignableRolePlace(name, channel);
}
@Override
public CompletableFuture<Void> deleteAssignableRolePlace(AServer server, String name) {
AssignableRolePlace place = rolePlaceManagementService.findByServerAndKey(server, name);
log.info("Deleting assignable role place {}.", place.getId());
Long placeId = place.getId();
CompletableFuture<Void> deleteFuture = deleteExistingMessagePostsForPlace(place);
return deleteFuture.thenAccept(unused -> self.deleteAssignableRolePlaceInDatabase(placeId));
}
@Transactional
public void deleteAssignableRolePlaceInDatabase(Long placeId) {
AssignableRolePlace place = rolePlaceManagementService.findByPlaceId(placeId);
place.getAssignableRoles()
.forEach(assignableRole -> componentPayloadManagementService.deletePayload(assignableRole.getComponentPayload()));
rolePlaceManagementService.deleteAssignablePlace(place);
}
@Override
public CompletableFuture<Void> changeTextAsync(AServer server, String name, String newText) {
AssignableRolePlace place = rolePlaceManagementService.findByServerAndKey(server, name);
log.info("Changing text of assignable role place {} in server {}.", place.getId(), server.getId());
place.setText(newText);
return refreshTextFromPlace(place);
}
@Override
public CompletableFuture<Void> changeConfiguration(AServer server, String name, AssignableRolePlaceParameterKey keyToChange, String newValue) {
Boolean booleanValue = BooleanUtils.toBooleanObject(newValue);
if (booleanValue == null) {
throw new CommandParameterKeyValueWrongTypeException(Arrays.asList("yes", "no", "true", "false", "on", "off"));
}
if (keyToChange == AssignableRolePlaceParameterKey.UNIQUE) {
setAssignablePlaceUniqueTo(server, name, booleanValue);
return CompletableFuture.completedFuture(null);
}
throw new AssignableRolePlaceIllegalConfigurationException();
}
@Override
public AssignablePlaceOverview getAssignableRolePlaceOverview(Guild guild) {
AServer server = serverManagementService.loadServer(guild);
List<AssignableRolePlace> assignableRolePlaces = rolePlaceManagementService.findAllByServer(server);
List<AssignableRolePlaceConfig> placeConfigs = assignableRolePlaces
.stream()
.map(place -> convertPlaceToAssignableRolePlaceConfig(guild, place))
.collect(Collectors.toList());
log.info("Showing overview over all assignable role places for server {}.", server.getId());
return AssignablePlaceOverview
.builder()
.places(placeConfigs)
.build();
}
private CompletableFuture<Void> sendAssignablePostMessage(AssignableRolePlace place, GuildMessageChannel channel) {
AssignablePostMessage model = prepareAssignablePostMessageModel(place);
MessageToSend messageToSend = templateService.renderEmbedTemplate(ASSIGNABLE_ROLES_POST_TEMPLATE_KEY, model, place.getServer().getId());
log.info("Sending message for assignable role place {}.", place.getId());
CompletableFuture<Message> postFuture = channelService.sendMessageToSendToChannel(messageToSend, channel).get(0);
Long placeId = model.getPlaceId();
return postFuture.thenCompose(unused -> {
CompletableFuture<Void> future = new CompletableFuture<>();
try {
self.persistAssignablePlaceMessageId(placeId, postFuture);
future.complete(null);
} catch (Exception exception) {
future.completeExceptionally(exception);
return future;
}
return future;
});
}
@Transactional
public void persistAssignablePlaceMessageId(Long placeId, CompletableFuture<Message> messageFuture) {
AssignableRolePlace place = assignableRolePlaceManagementServiceBean.findByPlaceId(placeId);
Message message = messageFuture.join();
log.info("Setting message ID of assignable role place {} to {}.", placeId, message.getIdLong());
place.setMessageId(message.getIdLong());
}
private ComponentPayload persistButtonCallback(AssignableRolePlace place, String buttonId, Long roleId) {
AssignableRolePlacePayload payload = AssignableRolePlacePayload
.builder()
.roleId(roleId)
.placeId(place.getId())
.build();
return componentPayloadService.createButtonPayload(buttonId, payload, ASSIGNABLE_ROLE_COMPONENT_ORIGIN, place.getServer());
}
private AssignablePostMessage prepareAssignablePostMessageModel(AssignableRolePlace place) {
List<AssignablePostRole> roles = new ArrayList<>();
List<AssignableRole> rolesToAdd = place.getAssignableRoles();
int maxPosition = 0;
Map<String, Long> componentIdMap = new HashMap<>();
if (!rolesToAdd.isEmpty()) {
rolesToAdd.forEach(assignableRole -> {
String componentId = assignableRole.getComponentPayload().getId();
componentIdMap.put(componentId, assignableRole.getRole().getId());
roles.add(AssignablePostRole
.builder()
.componentId(componentId)
.description(assignableRole.getDescription())
.emoteMarkDown(assignableRole.getEmoteMarkdown())
.build());
});
}
return AssignablePostMessage
.builder()
.roles(roles)
.placeId(place.getId())
.componentIdToRole(componentIdMap)
.placeDescription(place.getText())
.maxPosition(maxPosition)
.build();
}
@Transactional
public CompletableFuture<Void> createAssignableRolePlacePost(Long serverId, Long assignablePlaceId) {
AssignableRolePlace assignableRolePlace = rolePlaceManagementService.findByPlaceId(assignablePlaceId);
Optional<GuildMessageChannel> channelOptional = channelService.getMessageChannelFromServerOptional(serverId, assignableRolePlace.getChannel().getId());
if (channelOptional.isPresent()) {
GuildMessageChannel channel = channelOptional.get();
log.info("Sending assignable role place posts for place {} in channel {} in server {}.", assignableRolePlace.getId(), channel.getId(), serverId);
return sendAssignablePostMessage(assignableRolePlace, channel);
} else {
throw new AssignableRolePlaceChannelDoesNotExistException(assignableRolePlace.getChannel().getId(), assignableRolePlace.getKey());
}
}
@Transactional
public CompletableFuture<Void> setupAssignableRolePlaceInChannel(Long serverId, Long assignablePlaceId, TextChannel textChannel) {
AssignableRolePlace assignableRolePlace = rolePlaceManagementService.findByPlaceId(assignablePlaceId);
log.info("Sending assignable role place posts for place {} in channel {} in server {}.", assignableRolePlace.getId(), textChannel.getId(), serverId);
return sendAssignablePostMessage(assignableRolePlace, textChannel);
}
}

View File

@@ -0,0 +1,195 @@
package dev.sheldan.abstracto.assignableroles.service;
import dev.sheldan.abstracto.assignableroles.exception.AssignableRoleNotFoundException;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRole;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace;
import dev.sheldan.abstracto.assignableroles.model.database.AssignedRoleUser;
import dev.sheldan.abstracto.assignableroles.service.management.AssignableRoleManagementServiceBean;
import dev.sheldan.abstracto.assignableroles.service.management.AssignedRoleUserManagementService;
import dev.sheldan.abstracto.assignableroles.service.management.AssignedRoleUserManagementServiceBean;
import dev.sheldan.abstracto.core.metric.service.CounterMetric;
import dev.sheldan.abstracto.core.metric.service.MetricService;
import dev.sheldan.abstracto.core.metric.service.MetricTag;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.service.MemberService;
import dev.sheldan.abstracto.core.service.RoleService;
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
@Component
@Slf4j
public class AssignableRoleServiceBean implements AssignableRoleService {
@Autowired
private RoleService roleService;
@Autowired
private AssignedRoleUserManagementService assignedRoleUserManagementService;
@Autowired
private AssignableRoleManagementServiceBean assignableRoleManagementServiceBean;
@Autowired
private UserInServerManagementService userInServerManagementService;
@Autowired
private AssignedRoleUserManagementServiceBean assignedRoleUserManagementServiceBean;
@Autowired
private AssignableRoleServiceBean self;
@Autowired
private MemberService memberService;
@Autowired
private MetricService metricService;
public static final String ASSIGNABLE_ROLES_METRIC = "assignable.roles";
public static final String ACTION = "action";
private static final CounterMetric ASSIGNABLE_ROLES_ASSIGNED =
CounterMetric
.builder()
.name(ASSIGNABLE_ROLES_METRIC)
.tagList(Arrays.asList(MetricTag.getTag(ACTION, "assigned")))
.build();
private static final CounterMetric ASSIGNABLE_ROLES_REMOVED =
CounterMetric
.builder()
.name(ASSIGNABLE_ROLES_METRIC)
.tagList(Arrays.asList(MetricTag.getTag(ACTION, "removed")))
.build();
private static final CounterMetric ASSIGNABLE_ROLES_CONDITION_FAILED =
CounterMetric
.builder()
.name(ASSIGNABLE_ROLES_METRIC)
.tagList(Arrays.asList(MetricTag.getTag(ACTION, "condition")))
.build();
@Override
public CompletableFuture<Void> assignAssignableRoleToUser(Long assignableRoleId, Member member) {
AssignableRole role = assignableRoleManagementServiceBean.getByAssignableRoleId(assignableRoleId);
log.info("Assigning role {} to member {} in server {}.", assignableRoleId, member.getId(), member.getGuild().getId());
metricService.incrementCounter(ASSIGNABLE_ROLES_ASSIGNED);
return roleService.addRoleToMemberAsync(member, role.getRole());
}
@Override
public CompletableFuture<Void> assignAssignableRoleToUser(Role role, Member member) {
return assignRoleToUser(role.getIdLong(), member);
}
@Override
public void assignableRoleConditionFailure() {
metricService.incrementCounter(ASSIGNABLE_ROLES_CONDITION_FAILED);
}
private CompletableFuture<Void> assignRoleToUser(Long roleId, Member member) {
metricService.incrementCounter(ASSIGNABLE_ROLES_ASSIGNED);
return roleService.addRoleToMemberAsync(member, roleId);
}
@Override
public void clearAllRolesOfUserInPlace(AssignableRolePlace place, AUserInAServer userInAServer) {
Optional<AssignedRoleUser> userOptional = assignedRoleUserManagementServiceBean.findByUserInServerOptional(userInAServer);
userOptional.ifPresent(assignedRoleUser -> {
log.info("Clearing all {} assignable roles in place {} for user {} in server {}.",
assignedRoleUser.getRoles().size(), place.getId(), userInAServer.getUserReference().getId(), userInAServer.getServerReference().getId());
assignedRoleUser.getRoles().forEach(assignableRole -> {
if(assignableRole.getAssignablePlace().equals(place)) {
assignableRole.getAssignedUsers().remove(assignedRoleUser);
}
});
assignedRoleUser.getRoles().removeIf(assignableRole -> assignableRole.getAssignablePlace().equals(place));
});
if(!userOptional.isPresent()) {
log.info("User {} was not yet stored as an assignable role user in server {} - nothing to clear.",
userInAServer.getUserReference().getId(), place.getServer().getId());
}
}
@Override
public CompletableFuture<Void> removeAssignableRoleFromUser(AssignableRole assignableRole, Member member) {
log.info("Removing assignable role {} from user {} in server {}.", assignableRole.getId(), member.getId(), member.getGuild().getId());
return removeRoleFromUser(assignableRole.getRole().getId(), member);
}
@Override
public CompletableFuture<Void> removeAssignableRoleFromUser(Role role, Member member) {
return removeRoleFromUser(role.getIdLong(), member);
}
private CompletableFuture<Void> removeRoleFromUser(Long roleId, Member member) {
metricService.incrementCounter(ASSIGNABLE_ROLES_REMOVED);
return roleService.removeRoleFromMemberAsync(member, roleId);
}
@Override
@Transactional
public CompletableFuture<Void> removeAssignableRoleFromUser(Long assignableRoleId, Member member) {
AssignableRole role = assignableRoleManagementServiceBean.getByAssignableRoleId(assignableRoleId);
return self.removeAssignableRoleFromUser(role, member);
}
@Override
public void addRoleToUser(AssignableRole assignableRole, AUserInAServer aUserInAServer) {
log.info("Persisting storing adding assignable role {} to user {} in server {}.",
assignableRole.getId(), aUserInAServer.getUserReference().getId(), aUserInAServer.getServerReference().getId());
assignedRoleUserManagementServiceBean.addAssignedRoleToUser(assignableRole, aUserInAServer);
}
@Override
public void removeRoleFromUser(AssignableRole assignableRole, AUserInAServer aUserInAServer) {
log.info("Persisting storing removing assignable role {} to user {} in server {}.",
assignableRole.getId(), aUserInAServer.getUserReference().getId(), aUserInAServer.getServerReference().getId());
assignedRoleUserManagementServiceBean.removeAssignedRoleFromUser(assignableRole, aUserInAServer);
}
@Override
public AssignableRole getAssignableRoleInPlace(AssignableRolePlace place, Role role) {
return getAssignableRoleInPlace(place, role.getIdLong());
}
@Override
public AssignableRole getAssignableRoleInPlace(AssignableRolePlace place, ARole role) {
return getAssignableRoleInPlace(place, role.getId());
}
@Override
public AssignableRole getAssignableRoleInPlace(AssignableRolePlace place, Long roleId) {
for (AssignableRole assignableRole : place.getAssignableRoles()) {
if (assignableRole.getRole().getId().equals(roleId)) {
return assignableRole;
}
}
throw new AssignableRoleNotFoundException(roleId);
}
@Override
public void removeAssignableRolesFromAssignableRoleUser(List<AssignableRole> roles, AssignedRoleUser roleUser) {
log.info("Removing {} assignable roles from user {} in server {}.", roles.size(), roleUser.getUser().getUserReference().getId(),
roleUser.getUser().getServerReference().getId());
roles.forEach(assignableRole -> assignedRoleUserManagementServiceBean.removeAssignedRoleFromUser(assignableRole, roleUser));
}
@PostConstruct
public void postConstruct() {
metricService.registerCounter(ASSIGNABLE_ROLES_ASSIGNED, "Assignable roles assigned.");
metricService.registerCounter(ASSIGNABLE_ROLES_REMOVED, "Assignable roles removed.");
metricService.registerCounter(ASSIGNABLE_ROLES_CONDITION_FAILED, "Assignable roles failed to assign because of condition.");
}
}

View File

@@ -0,0 +1,43 @@
package dev.sheldan.abstracto.assignableroles.service.management;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleConditionType;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRole;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRoleCondition;
import dev.sheldan.abstracto.assignableroles.repository.AssignableRoleConditionRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Optional;
@Component
@Slf4j
public class AssignableRoleConditionManagementServiceBean implements AssignableRoleConditionManagementService {
@Autowired
private AssignableRoleConditionRepository repository;
@Override
public AssignableRoleCondition createAssignableRoleCondition(AssignableRole assignableRole, AssignableRoleConditionType type, String value) {
AssignableRoleCondition condition = AssignableRoleCondition
.builder()
.assignableRole(assignableRole)
.type(type)
.conditionValue(value)
.build();
log.info("Creating condition of type {} for assignable role {}", assignableRole.getId(), type);
assignableRole.getConditions().add(condition);
return repository.save(condition);
}
@Override
public void deleteAssignableRoleCondition(AssignableRoleCondition condition) {
log.info("Deleting condition {}.", condition.getId());
repository.delete(condition);
}
@Override
public Optional<AssignableRoleCondition> findAssignableRoleCondition(AssignableRole role, AssignableRoleConditionType type) {
return repository.findByAssignableRoleAndType(role, type);
}
}

View File

@@ -0,0 +1,75 @@
package dev.sheldan.abstracto.assignableroles.service.management;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRole;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlaceType;
import dev.sheldan.abstracto.assignableroles.model.database.AssignedRoleUser;
import dev.sheldan.abstracto.assignableroles.repository.AssignableRoleRepository;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.core.models.FullEmote;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.models.database.ComponentPayload;
import dev.sheldan.abstracto.core.service.EmoteService;
import dev.sheldan.abstracto.core.service.management.EmoteManagementService;
import dev.sheldan.abstracto.core.service.management.RoleManagementService;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Slf4j
public class AssignableRoleManagementServiceBean implements AssignableRoleManagementService {
@Autowired
private AssignableRolePlaceManagementService rolePlaceManagementService;
@Autowired
private EmoteManagementService emoteManagementService;
@Autowired
private RoleManagementService roleManagementService;
@Autowired
private AssignableRoleRepository repository;
@Autowired
private EmoteService emoteService;
@Override
public AssignableRole addRoleToPlace(FullEmote emote, Role role, String description, AssignableRolePlace place, ComponentPayload componentPayload) {
ARole arole = roleManagementService.findRole(role.getIdLong());
AssignableRole roleToAdd = AssignableRole
.builder()
.assignablePlace(place)
.emoteMarkdown(emote != null ? emote.getEmoteRepr() : null)
.role(arole)
.componentPayload(componentPayload)
.server(place.getServer())
.description(description)
.build();
place.getAssignableRoles().add(roleToAdd);
log.info("Adding role {} to assignable role place {}. There are now {} roles.", role.getId(), place.getId(), place.getAssignableRoles().size());
return roleToAdd;
}
@Override
public AssignableRole getByAssignableRoleId(Long assignableRoleId) {
return repository.findById(assignableRoleId).orElseThrow(() -> new AbstractoRunTimeException("Assignable role not found"));
}
@Override
public void deleteAssignableRole(AssignableRole assignableRole) {
assignableRole.getAssignablePlace().getAssignableRoles().remove(assignableRole);
assignableRole.setAssignablePlace(null);
repository.delete(assignableRole);
}
@Override
public List<AssignableRole> getAssignableRolesFromAssignableUserWithPlaceType(AssignedRoleUser user, AssignableRolePlaceType type) {
return repository.findByAssignedUsersContainingAndAssignablePlace_Type(user, type);
}
}

View File

@@ -0,0 +1,89 @@
package dev.sheldan.abstracto.assignableroles.service.management;
import dev.sheldan.abstracto.assignableroles.exception.AssignableRolePlaceNotFoundException;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlaceType;
import dev.sheldan.abstracto.assignableroles.repository.AssignableRolePlaceRepository;
import dev.sheldan.abstracto.core.models.database.AChannel;
import dev.sheldan.abstracto.core.models.database.AServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional;
@Component
@Slf4j
public class AssignableRolePlaceManagementServiceBean implements AssignableRolePlaceManagementService {
@Autowired
private AssignableRolePlaceRepository repository;
@Override
public AssignableRolePlace createPlace(String name, AChannel channel, String text, AssignableRolePlaceType type) {
boolean unique = false;
if(type.equals(AssignableRolePlaceType.BOOSTER)) {
unique = true;
}
AssignableRolePlace place = AssignableRolePlace
.builder()
.channel(channel)
.server(channel.getServer())
.text(text)
.uniqueRoles(unique)
.type(type)
.key(name)
.build();
log.info("Creating assignable role place in channel {} on server {}.", channel.getId(), channel.getServer().getId());
return repository.save(place);
}
@Override
public boolean doesPlaceExist(AServer server, String name) {
return repository.existsByServerAndKey(server, name);
}
@Override
public AssignableRolePlace findByServerAndKey(AServer server, String name) {
return repository.findByServerAndKey(server, name).orElseThrow(AssignableRolePlaceNotFoundException::new);
}
@Override
public Optional<AssignableRolePlace> findByPlaceIdOptional(Long id) {
return repository.findById(id);
}
@Override
public AssignableRolePlace findByPlaceId(Long id) {
return findByPlaceIdOptional(id).orElseThrow(AssignableRolePlaceNotFoundException::new);
}
@Override
public void moveAssignableRolePlace(String name, AChannel newChannel) {
AssignableRolePlace assignablePlaceToChange = findByServerAndKey(newChannel.getServer(), name);
log.info("Moving assignable role place {} in server {} from channel {} to channel {}.",
assignablePlaceToChange.getId(), newChannel.getServer().getId(), assignablePlaceToChange.getChannel().getId(), newChannel.getId());
assignablePlaceToChange.setChannel(newChannel);
}
@Override
public void changeAssignableRolePlaceDescription(AServer server, String name, String newDescription) {
AssignableRolePlace assignablePlaceToChange = findByServerAndKey(server, name);
log.info("Changing description of assignable role place {} in server {}.", assignablePlaceToChange.getId(), server.getId());
assignablePlaceToChange.setText(newDescription);
}
@Override
public void deleteAssignablePlace(AssignableRolePlace toDelete) {
log.info("Deleting assignable role place {} in server {} which was in server {}.", toDelete.getId(), toDelete.getChannel().getId(), toDelete.getServer().getId());
repository.delete(toDelete);
}
@Override
public List<AssignableRolePlace> findAllByServer(AServer server) {
return repository.findByServer(server);
}
}

View File

@@ -0,0 +1,87 @@
package dev.sheldan.abstracto.assignableroles.service.management;
import dev.sheldan.abstracto.assignableroles.exception.AssignedUserNotFoundException;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRole;
import dev.sheldan.abstracto.assignableroles.model.database.AssignedRoleUser;
import dev.sheldan.abstracto.assignableroles.repository.AssignedRoleUserRepository;
import dev.sheldan.abstracto.core.models.ServerUser;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional;
@Component
@Slf4j
public class AssignedRoleUserManagementServiceBean implements AssignedRoleUserManagementService {
@Autowired
private AssignedRoleUserRepository repository;
@Autowired
private UserInServerManagementService userInServerManagementService;
@Override
public void addAssignedRoleToUser(AssignableRole assignableRole, AUserInAServer aUserInAServer) {
Optional<AssignedRoleUser> optional = findByUserInServerOptional(aUserInAServer);
log.info("Adding assignable role {} to user {} in server {} because of assignable role place {}.",
assignableRole.getId(), aUserInAServer.getUserReference().getId(), aUserInAServer.getServerReference().getId(),
assignableRole.getAssignablePlace().getId());
AssignedRoleUser user = optional.orElseGet(() -> createAssignedRoleUser(aUserInAServer));
assignableRole.getAssignedUsers().add(user);
user.getRoles().add(assignableRole);
}
@Override
public void removeAssignedRoleFromUser(AssignableRole assignableRole, AUserInAServer aUserInAServer) {
log.info("Removing assignable role {} from user {} in server {} in assignable role place {}.",
assignableRole.getId(), aUserInAServer.getUserReference().getId(), aUserInAServer.getServerReference().getId(),
assignableRole.getAssignablePlace().getId());
AssignedRoleUser user = findByUserInServer(aUserInAServer);
removeAssignedRoleFromUser(assignableRole, user);
}
@Override
public void removeAssignedRoleFromUsers(AssignableRole assignableRole, List<AssignedRoleUser> users) {
log.info("Clearing all assignable role {} for {} users.", assignableRole.getId(), users.size());
assignableRole.getAssignedUsers().removeAll(users);
users.forEach(roleUser -> roleUser.getRoles().remove(assignableRole));
}
@Override
public void removeAssignedRoleFromUsers(AssignableRole assignableRole) {
removeAssignedRoleFromUsers(assignableRole, assignableRole.getAssignedUsers());
}
@Override
public void removeAssignedRoleFromUser(AssignableRole assignableRole, AssignedRoleUser user) {
assignableRole.getAssignedUsers().remove(user);
user.getRoles().remove(assignableRole);
}
@Override
public AssignedRoleUser createAssignedRoleUser(AUserInAServer aUserInAServer) {
log.info("Creating assigned role user for user {} in server {}.", aUserInAServer.getUserReference().getId(), aUserInAServer.getServerReference().getId());
AssignedRoleUser newUser = AssignedRoleUser.builder().user(aUserInAServer).id(aUserInAServer.getUserInServerId()).build();
return repository.save(newUser);
}
@Override
public Optional<AssignedRoleUser> findByUserInServerOptional(AUserInAServer aUserInAServer) {
return repository.findById(aUserInAServer.getUserInServerId());
}
@Override
public Optional<AssignedRoleUser> findByUserInServerOptional(ServerUser serverUser) {
AUserInAServer aUserInAServer = userInServerManagementService.loadOrCreateUser(serverUser);
return findByUserInServerOptional(aUserInAServer);
}
@Override
public AssignedRoleUser findByUserInServer(AUserInAServer aUserInAServer) {
return findByUserInServerOptional(aUserInAServer).orElseThrow(() -> new AssignedUserNotFoundException(aUserInAServer));
}
}

View File

@@ -0,0 +1,2 @@
abstracto.featureFlags.assignableRole.featureName=assignableRole
abstracto.featureFlags.assignableRole.enabled=false

View File

@@ -0,0 +1,80 @@
<?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="assignableRoleModule" value="(SELECT id FROM module WHERE name = 'assignableRoles')"/>
<property name="assignableRoleFeature" value="(SELECT id FROM feature WHERE key = 'assignableRole')"/>
<changeSet author="Sheldan" id="assignable_roles-commands">
<insert tableName="command">
<column name="name" value="addRoleToAssignableRolePlace"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="setupAssignableRolePlace"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="activateAssignableRolePlace"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="deactivateAssignableRolePlace"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="removeRoleFromAssignableRolePlace"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="changeAssignableRolePlaceConfig"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="deleteAssignableRolePlace"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="createAssignableRolePlace"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="showAssignableRolePlaceConfig"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="editAssignableRolePlaceText"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="moveAssignableRolePlace"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="showAssignableRolePlaces"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="addAssignableRoleCondition"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
<insert tableName="command">
<column name="name" value="removeAssignableRoleCondition"/>
<column name="module_id" valueComputed="${assignableRoleModule}"/>
<column name="feature_id" valueComputed="${assignableRoleFeature}"/>
</insert>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,8 @@
<?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="feature.xml" relativeToChangelogFile="true"/>
<include file="module.xml" relativeToChangelogFile="true"/>
<include file="command.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,10 @@
<?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="assignable_role-feature-insertion">
<insert tableName="feature">
<column name="key" value="assignableRole"/>
</insert>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,10 @@
<?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="assignable_role-module-insertion">
<insert tableName="module">
<column name="name" value="assignableRoles"/>
</insert>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,48 @@
<?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="assignable_role-table">
<createTable tableName="assignable_role">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true" primaryKeyName="assignable_role_pkey"/>
</column>
<column name="emote_markdown" type="VARCHAR(100)">
<constraints nullable="true"/>
</column>
<column name="role_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="assignable_place_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="server_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="description" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="component_id" type="VARCHAR(100)" />
<column name="created" type="TIMESTAMP WITHOUT TIME ZONE">
<constraints nullable="false"/>
</column>
<column name="updated" type="TIMESTAMP WITHOUT TIME ZONE"/>
</createTable>
<createIndex indexName="idx_assignable_role_role_id" tableName="assignable_role">
<column name="role_id"/>
</createIndex>
<addForeignKeyConstraint baseColumnNames="role_id" baseTableName="assignable_role" constraintName="fk_assignable_role_role" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="role" validate="true"/>
<addForeignKeyConstraint baseColumnNames="assignable_place_id" baseTableName="assignable_role" constraintName="fk_assignable_role_place" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="assignable_role_place" validate="true"/>
<addForeignKeyConstraint baseColumnNames="server_id" baseTableName="assignable_role" constraintName="fk_assignable_role_server" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="server" validate="true"/>
<addForeignKeyConstraint baseColumnNames="component_id" baseTableName="assignable_role" constraintName="fk_assignable_role_payload" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="component_payload" validate="true"/>
<sql>
DROP TRIGGER IF EXISTS assignable_role_update_trigger ON assignable_role;
CREATE TRIGGER assignable_role_update_trigger BEFORE UPDATE ON assignable_role FOR EACH ROW EXECUTE PROCEDURE update_trigger_procedure();
</sql>
<sql>
DROP TRIGGER IF EXISTS assignable_role_insert_trigger ON assignable_role;
CREATE TRIGGER assignable_role_insert_trigger BEFORE INSERT ON assignable_role FOR EACH ROW EXECUTE PROCEDURE insert_trigger_procedure();
</sql>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,29 @@
<?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="assignable_role_condition-table">
<createTable tableName="assignable_role_condition">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true" primaryKeyName="assignable_role_condition_pkey"/>
</column>
<column name="type" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column name="assignable_role_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="condition_value" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="created" type="TIMESTAMP WITHOUT TIME ZONE"/>
</createTable>
<addForeignKeyConstraint baseColumnNames="assignable_role_id" baseTableName="assignable_role_condition" constraintName="fk_assignable_role_condition_assignable_role"
deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="assignable_role" validate="true"/>
<sql>
DROP TRIGGER IF EXISTS assignable_role_condition_insert_trigger ON assignable_role_condition;
CREATE TRIGGER assignable_role_condition_insert_trigger BEFORE INSERT ON assignable_role_condition FOR EACH ROW EXECUTE PROCEDURE insert_trigger_procedure();
</sql>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,47 @@
<?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="assignable_role_place-table">
<createTable tableName="assignable_role_place">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true" primaryKeyName="assignable_role_place_pkey"/>
</column>
<column name="channel_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="server_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="key" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="text" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
<column name="unique_roles" type="BOOLEAN">
<constraints nullable="false"/>
</column>
<column name="message_id" type="BIGINT" />
<column name="created" type="TIMESTAMP WITHOUT TIME ZONE">
<constraints nullable="false"/>
</column>
<column name="updated" type="TIMESTAMP WITHOUT TIME ZONE"/>
</createTable>
<createIndex indexName="idx_assignable_role_place" tableName="assignable_role_place">
<column name="server_id"/>
<column name="key"/>
</createIndex>
<addForeignKeyConstraint baseColumnNames="channel_id" baseTableName="assignable_role_place" constraintName="fk_assignable_role_place_channel" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="channel" validate="true"/>
<addForeignKeyConstraint baseColumnNames="server_id" baseTableName="assignable_role_place" constraintName="fk_assignable_role_place_server" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="server" validate="true"/>
<sql>
DROP TRIGGER IF EXISTS assignable_role_place_update_trigger ON assignable_role_place;
CREATE TRIGGER assignable_role_place_update_trigger BEFORE UPDATE ON assignable_role_place FOR EACH ROW EXECUTE PROCEDURE update_trigger_procedure();
</sql>
<sql>
DROP TRIGGER IF EXISTS assignable_role_place_insert_trigger ON assignable_role_place;
CREATE TRIGGER assignable_role_place_insert_trigger BEFORE INSERT ON assignable_role_place FOR EACH ROW EXECUTE PROCEDURE insert_trigger_procedure();
</sql>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,38 @@
<?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="assigned_role_user-table">
<createTable tableName="assigned_role_user">
<column name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true" primaryKeyName="assigned_role_user_pkey"/>
</column>
<column name="created" type="TIMESTAMP WITHOUT TIME ZONE">
<constraints nullable="false"/>
</column>
<column name="updated" type="TIMESTAMP WITHOUT TIME ZONE"/>
</createTable>
<addForeignKeyConstraint baseColumnNames="id" baseTableName="assigned_role_user" constraintName="fk_assigned_role_user_user" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="user_in_server_id" referencedTableName="user_in_server" validate="true"/>
<sql>
DROP TRIGGER IF EXISTS assigned_role_user_update_trigger ON assigned_role_user;
CREATE TRIGGER assigned_role_user_update_trigger BEFORE UPDATE ON assigned_role_user FOR EACH ROW EXECUTE PROCEDURE update_trigger_procedure();
</sql>
<sql>
DROP TRIGGER IF EXISTS assigned_role_user_insert_trigger ON assigned_role_user;
CREATE TRIGGER assigned_role_user_insert_trigger BEFORE INSERT ON assigned_role_user FOR EACH ROW EXECUTE PROCEDURE insert_trigger_procedure();
</sql>
</changeSet>
<changeSet author="Sheldan" id="assigned_role_in_user-table">
<createTable tableName="assigned_role_in_user">
<column name="assigned_role_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="user_in_server_id" type="BIGINT">
<constraints nullable="false"/>
</column>
</createTable>
<addForeignKeyConstraint baseColumnNames="assigned_role_id" baseTableName="assigned_role_in_user" constraintName="fk_assigned_role_in_user_assignable_role" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="assignable_role" validate="true"/>
<addForeignKeyConstraint baseColumnNames="user_in_server_id" baseTableName="assigned_role_in_user" constraintName="fk_assigned_role_in_user_assigned_user" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="assigned_role_user" validate="true"/>
</changeSet>
</databaseChangeLog>

View File

@@ -0,0 +1,9 @@
<?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="assignable_role_place.xml" relativeToChangelogFile="true"/>
<include file="assignable_role.xml" relativeToChangelogFile="true"/>
<include file="assignable_role_condition.xml" relativeToChangelogFile="true"/>
<include file="assigned_role_user.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -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="assignableRoles-tables/tables.xml" relativeToChangelogFile="true"/>
<include file="assignableRoles-seedData/data.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -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="tables/tables.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,11 @@
<?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="assignable_role_place-add_type">
<addColumn tableName="assignable_role_place">
<column name="type" type="VARCHAR2(128)" defaultValue="DEFAULT"/>
</addColumn>
</changeSet>
</databaseChangeLog>

View File

@@ -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="assignable_role_place.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -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="1.0-assignableRoles/collection.xml" relativeToChangelogFile="true"/>
<include file="1.3.4/collection.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>assignable-roles</artifactId>
<version>1.5.42-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>assignable-roles-int</artifactId>
</project>

View File

@@ -0,0 +1,16 @@
package dev.sheldan.abstracto.assignableroles.condition;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleConditionType;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRolePlaceConditionModel;
import dev.sheldan.abstracto.assignableroles.model.database.AssignableRoleCondition;
import dev.sheldan.abstracto.assignableroles.model.template.condition.AssignableRoleConditionDisplay;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import net.dv8tion.jda.api.entities.Role;
public interface AssignableRoleConditionEvaluator {
boolean handlesCondition(AssignableRoleConditionType type);
boolean fulfillsCondition(AssignableRoleCondition conditionDefinition, AUserInAServer aUserInAServer);
boolean usableValue(String value);
AssignableRolePlaceConditionModel createNotificationModel(AssignableRoleCondition conditionDefinition, Role role);
AssignableRoleConditionDisplay getConditionDisplay(AssignableRoleCondition conditionDefinition);
}

View File

@@ -0,0 +1,13 @@
package dev.sheldan.abstracto.assignableroles.config;
import dev.sheldan.abstracto.core.config.FeatureConfig;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import org.springframework.stereotype.Component;
@Component
public class AssignableFeatureConfig implements FeatureConfig {
@Override
public FeatureDefinition getFeature() {
return AssignableRoleFeatureDefinition.ASSIGNABLE_ROLES;
}
}

View File

@@ -0,0 +1,15 @@
package dev.sheldan.abstracto.assignableroles.config;
import dev.sheldan.abstracto.core.config.FeatureDefinition;
import lombok.Getter;
@Getter
public enum AssignableRoleFeatureDefinition implements FeatureDefinition {
ASSIGNABLE_ROLES("assignableRole");
private String key;
AssignableRoleFeatureDefinition(String key) {
this.key = key;
}
}

View File

@@ -0,0 +1,9 @@
package dev.sheldan.abstracto.assignableroles.config;
import dev.sheldan.abstracto.core.command.execution.CommandParameterKey;
import lombok.Getter;
@Getter
public enum AssignableRolePlaceParameterKey implements CommandParameterKey {
UNIQUE
}

View File

@@ -0,0 +1,35 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.assignableroles.model.exception.AssignableRoleAlreadyDefinedExceptionModel;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.core.models.template.display.RoleDisplay;
import dev.sheldan.abstracto.core.templating.Templatable;
import net.dv8tion.jda.api.entities.Role;
/**
* Exception thrown in case the {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRole} has already been
* defined for an {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace}. This is identified
* via the emote which is used to react.
*/
public class AssignableRoleAlreadyDefinedException extends AbstractoRunTimeException implements Templatable {
private final AssignableRoleAlreadyDefinedExceptionModel model;
public AssignableRoleAlreadyDefinedException(Role role, String placeName) {
super("Assignable role already assigned");
this.model = AssignableRoleAlreadyDefinedExceptionModel
.builder()
.roleDisplay(RoleDisplay.fromRole(role))
.placeName(placeName)
.build();
}
@Override
public String getTemplateName() {
return "assignable_role_already_defined_exception";
}
@Override
public Object getTemplateModel() {
return model;
}
}

View File

@@ -0,0 +1,15 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
public class AssignableRoleConditionAlreadyExistsException extends AbstractoTemplatableException {
@Override
public String getTemplateName() {
return "assignable_role_condition_already_present_exception";
}
@Override
public Object getTemplateModel() {
return new Object();
}
}

View File

@@ -0,0 +1,15 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
public class AssignableRoleConditionDoesNotExistException extends AbstractoTemplatableException {
@Override
public String getTemplateName() {
return "assignable_role_condition_does_not_exist_exception";
}
@Override
public Object getTemplateModel() {
return new Object();
}
}

View File

@@ -0,0 +1,15 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
public class AssignableRoleConditionValueNotUsableException extends AbstractoTemplatableException {
@Override
public String getTemplateName() {
return "assignable_role_condition_value_not_usable_exception";
}
@Override
public Object getTemplateModel() {
return new Object();
}
}

View File

@@ -0,0 +1,27 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.assignableroles.model.exception.AssignableRoleNotFoundExceptionModel;
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
public class AssignableRoleNotFoundException extends AbstractoTemplatableException {
private final AssignableRoleNotFoundExceptionModel model;
public AssignableRoleNotFoundException(Long roleId) {
super("Role to assign is not available anymore.");
this.model = AssignableRoleNotFoundExceptionModel
.builder()
.roleId(roleId)
.build();
}
@Override
public String getTemplateName() {
return "assignable_role_not_found_exception";
}
@Override
public Object getTemplateModel() {
return this.model;
}
}

View File

@@ -0,0 +1,34 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.assignableroles.model.exception.AssignableRoleNotUsableExceptionModel;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.core.models.template.display.RoleDisplay;
import dev.sheldan.abstracto.core.templating.Templatable;
import net.dv8tion.jda.api.entities.Role;
/**
* Exception thrown in case the defined {@link net.dv8tion.jda.api.entities.Role role} cannot be interacted with by the bot,
* because of permissions, this can happen if the role is the same or higher than the bot, therefore cannot be given to
* {@link net.dv8tion.jda.api.entities.Member members}
*/
public class AssignableRoleNotUsableException extends AbstractoRunTimeException implements Templatable {
private final AssignableRoleNotUsableExceptionModel model;
public AssignableRoleNotUsableException(Role role) {
super("Role is not usable as assignable role");
this.model = AssignableRoleNotUsableExceptionModel
.builder()
.roleDisplay(RoleDisplay.fromRole(role))
.build();
}
@Override
public String getTemplateName() {
return "assignable_role_not_usable_exception";
}
@Override
public Object getTemplateModel() {
return model;
}
}

View File

@@ -0,0 +1,32 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.assignableroles.model.exception.AssignableRolePlaceAlreadyExistsExceptionModel;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.core.templating.Templatable;
/**
* Exception thrown in case the {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace place}
* identified by {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace} key
*/
public class AssignableRolePlaceAlreadyExistsException extends AbstractoRunTimeException implements Templatable {
private final AssignableRolePlaceAlreadyExistsExceptionModel model;
public AssignableRolePlaceAlreadyExistsException(String name) {
super("Assignable role place already exists");
this.model = AssignableRolePlaceAlreadyExistsExceptionModel
.builder()
.name(name)
.build();
}
@Override
public String getTemplateName() {
return "assignable_role_place_exists_exception";
}
@Override
public Object getTemplateModel() {
return model;
}
}

View File

@@ -0,0 +1,33 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.assignableroles.model.exception.AssignableRolePlaceChannelDoesNotExistExceptionModel;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.core.templating.Templatable;
/**
* Exception thrown in case the {@link dev.sheldan.abstracto.core.models.database.AChannel channel} in which a
* {@link dev.sheldan.abstracto.assignableroles.model.database.AssignableRolePlace place} is defined, does not exist
*/
public class AssignableRolePlaceChannelDoesNotExistException extends AbstractoRunTimeException implements Templatable {
private final AssignableRolePlaceChannelDoesNotExistExceptionModel model;
public AssignableRolePlaceChannelDoesNotExistException(Long channelId, String placeName) {
super("Assignable role place channel does not exist");
this.model = AssignableRolePlaceChannelDoesNotExistExceptionModel
.builder()
.channelId(channelId)
.placeName(placeName)
.build();
}
@Override
public String getTemplateName() {
return "assignable_role_place_channel_does_not_exist_exception";
}
@Override
public Object getTemplateModel() {
return this.model;
}
}

View File

@@ -0,0 +1,20 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
public class AssignableRolePlaceIllegalConfigurationException extends AbstractoTemplatableException {
public AssignableRolePlaceIllegalConfigurationException() {
super("An illegal configuration key has been passed to configure the assignable role place config. Doing nothing.");
}
@Override
public String getTemplateName() {
return "assignable_role_place_illegal_configuration_key_exception";
}
@Override
public Object getTemplateModel() {
return new Object();
}
}

View File

@@ -0,0 +1,20 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
public class AssignableRolePlaceMaximumRolesException extends AbstractoTemplatableException {
public AssignableRolePlaceMaximumRolesException() {
super("The maximum amount of assignable roles have been reached.");
}
@Override
public String getTemplateName() {
return "assignable_role_place_maximum_roles_reached_exception";
}
@Override
public Object getTemplateModel() {
return new Object();
}
}

View File

@@ -0,0 +1,21 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.core.templating.Templatable;
public class AssignableRolePlaceNotFoundException extends AbstractoRunTimeException implements Templatable {
public AssignableRolePlaceNotFoundException() {
super("Assignable role place not found");
}
@Override
public String getTemplateName() {
return "assignable_role_place_not_found_exception";
}
@Override
public Object getTemplateModel() {
return new Object();
}
}

View File

@@ -0,0 +1,33 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.assignableroles.model.exception.AssignedUserNotFoundExceptionModel;
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
import dev.sheldan.abstracto.core.templating.Templatable;
/**
* Exception which is thrown in case an {@link dev.sheldan.abstracto.assignableroles.model.database.AssignedRoleUser user}
* was not found.
*/
public class AssignedUserNotFoundException extends AbstractoRunTimeException implements Templatable {
private final AssignedUserNotFoundExceptionModel model;
public AssignedUserNotFoundException(AUserInAServer userInAServer) {
super("Assigned user was not found");
this.model = AssignedUserNotFoundExceptionModel
.builder()
.userId(userInAServer.getUserReference().getId())
.build();
}
@Override
public String getTemplateName() {
return "assignable_role_place_assigned_user_not_found_exception";
}
@Override
public Object getTemplateModel() {
return model;
}
}

View File

@@ -0,0 +1,20 @@
package dev.sheldan.abstracto.assignableroles.exception;
import dev.sheldan.abstracto.core.exception.AbstractoTemplatableException;
public class BoosterAssignableRolePlaceMemberNotBoostingException extends AbstractoTemplatableException {
public BoosterAssignableRolePlaceMemberNotBoostingException() {
super("Clicking member does not boost");
}
@Override
public String getTemplateName() {
return "assignable_role_booster_place_member_not_boosting_exception";
}
@Override
public Object getTemplateModel() {
return new Object();
}
}

View File

@@ -0,0 +1,38 @@
package dev.sheldan.abstracto.assignableroles.model.condition;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Builder
public class AssignableRoleConditionResult {
private Boolean fulfilled;
private AssignableRoleConditionType causingCondition;
private AssignableRolePlaceConditionModel model;
public static AssignableRoleConditionResult fromFail(AssignableRoleConditionType cause, AssignableRolePlaceConditionModel model) {
return AssignableRoleConditionResult
.builder()
.causingCondition(cause)
.model(model)
.fulfilled(false)
.build();
}
public static AssignableRoleConditionResult fromFail(AssignableRoleConditionType cause) {
return AssignableRoleConditionResult
.builder()
.causingCondition(cause)
.fulfilled(false)
.build();
}
public static AssignableRoleConditionResult fromSuccess() {
return AssignableRoleConditionResult
.builder()
.fulfilled(true)
.build();
}
}

View File

@@ -0,0 +1,7 @@
package dev.sheldan.abstracto.assignableroles.model.condition;
import dev.sheldan.abstracto.core.command.execution.CommandParameterKey;
public enum AssignableRoleConditionType implements CommandParameterKey {
MIN_LEVEL
}

View File

@@ -0,0 +1,14 @@
package dev.sheldan.abstracto.assignableroles.model.condition;
import dev.sheldan.abstracto.core.models.template.display.RoleDisplay;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Builder
public class AssignableRoleMinLevelModel {
private Integer minLevel;
private RoleDisplay roleDisplay;
}

View File

@@ -0,0 +1,22 @@
package dev.sheldan.abstracto.assignableroles.model.condition;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Builder
public class AssignableRoleMinLevelResult implements AssignableRolePlaceConditionModel {
private AssignableRoleMinLevelModel model;
@Override
public String getTemplateName() {
return "assignable_role_condition_min_level";
}
@Override
public Object getTemplateModel() {
return model;
}
}

View File

@@ -0,0 +1,6 @@
package dev.sheldan.abstracto.assignableroles.model.condition;
import dev.sheldan.abstracto.core.templating.Templatable;
public interface AssignableRolePlaceConditionModel extends Templatable {
}

View File

@@ -0,0 +1,100 @@
package dev.sheldan.abstracto.assignableroles.model.database;
import dev.sheldan.abstracto.core.models.database.AEmote;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.models.database.ComponentPayload;
import lombok.*;
import jakarta.persistence.*;
import java.io.Serializable;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
/**
* A {@link ARole role} which can be mapped to an {@link AssignableRolePlace ṕlace}. This is uniquely defined by an emote on the
* respective assignable role place, but the same role can be given via different {@link AEmote emote}
*/
@Entity
@Table(name = "assignable_role")
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@EqualsAndHashCode
public class AssignableRole implements Serializable {
/**
* The unique ID of this {@link AssignableRole assignableRole}
*/
@Id
@Column(name = "id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "emote_markdown")
private String emoteMarkdown;
/**
* The {@link ARole} which given via this {@link AssignableRole assignableRole}
*/
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "role_id", nullable = false)
private ARole role;
/**
* The {@link AServer server} in which this {@link AssignableRole assignableRole} is used
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "server_id", nullable = false)
private AServer server;
/**
* The {@link AssignableRolePlace} this assignable role is in
*/
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "assignable_place_id", nullable = false)
private AssignableRolePlace assignablePlace;
/**
* The {@link AssignedRoleUser users} which currently have this role assigned via this mechanism.
* This is necessary to enforce the unique property of {@link AssignableRolePlace}, in which you only may chose one
* role.
*/
@ManyToMany(mappedBy = "roles")
@Builder.Default
private List<AssignedRoleUser> assignedUsers = new ArrayList<>();
/**
* The display text which is used for the button
*/
@Column(name = "description", nullable = false)
private String description;
@OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "component_id", nullable = false)
private ComponentPayload componentPayload;
/**
* The {@link Instant} this entity was created
*/
@Column(name = "created", nullable = false, insertable = false, updatable = false)
private Instant created;
/**
* The {@link Instant} this entity was updated
*/
@Column(name = "updated", insertable = false, updatable = false)
private Instant updated;
@OneToMany(
fetch = FetchType.LAZY,
cascade = {CascadeType.PERSIST, CascadeType.MERGE},
orphanRemoval = true,
mappedBy = "assignableRole"
)
@Builder.Default
private List<AssignableRoleCondition> conditions = new ArrayList<>();
}

View File

@@ -0,0 +1,34 @@
package dev.sheldan.abstracto.assignableroles.model.database;
import dev.sheldan.abstracto.assignableroles.model.condition.AssignableRoleConditionType;
import lombok.*;
import jakarta.persistence.*;
@Entity
@Table(name = "assignable_role_condition")
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@EqualsAndHashCode
public class AssignableRoleCondition {
@Id
@Column(name = "id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Getter
@Enumerated(EnumType.STRING)
@Column(name = "type")
private AssignableRoleConditionType type;
@ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "assignable_role_id", nullable = false)
private AssignableRole assignableRole;
@Column(name = "condition_value")
private String conditionValue;
}

View File

@@ -0,0 +1,92 @@
package dev.sheldan.abstracto.assignableroles.model.database;
import dev.sheldan.abstracto.core.models.database.AChannel;
import dev.sheldan.abstracto.core.models.database.AServer;
import lombok.*;
import jakarta.persistence.*;
import java.io.Serializable;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "assignable_role_place")
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@EqualsAndHashCode
public class AssignableRolePlace implements Serializable {
public static final Long ASSIGNABLE_PLACE_NAME_LIMIT = 255L;
public static final Long ASSIGNABLE_PLACE_DESCRIPTION_LIMIT = 255L;
/**
* A unique ID created
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name="channel_id", nullable = false)
private AChannel channel;
/**
* The {@link AServer server} for which this place is configured for. Unique in combination with the key
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "server_id", nullable = false)
private AServer server;
/**
* The key this place is associated with via commands. Unique per server.
*/
@Column(name = "key", nullable = false)
private String key;
/**
* A List containing the {@link AssignableRole} which are associated with this place
*/
@OneToMany(
fetch = FetchType.LAZY,
cascade = {CascadeType.PERSIST, CascadeType.MERGE},
orphanRemoval = true,
mappedBy = "assignablePlace"
)
@Builder.Default
private List<AssignableRole> assignableRoles = new ArrayList<>();
@Column(name = "message_id")
private Long messageId;
@Column(name = "text", nullable = false)
private String text;
/**
* Whether or not it should be restricted, that a {@link AssignedRoleUser} should only have one role of this place
*/
@Builder.Default
@Column(name = "unique_roles", nullable = false)
private Boolean uniqueRoles = false;
/**
* The {@link Instant} this entity was created
*/
@Column(name = "created", nullable = false, insertable = false, updatable = false)
private Instant created;
/**
* The {@link Instant} this entity was updated
*/
@Column(name = "updated", insertable = false, updatable = false)
private Instant updated;
@Enumerated(EnumType.STRING)
@Column(name = "type")
private AssignableRolePlaceType type;
}

Some files were not shown because too many files have changed in this diff Show More