mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Compare commits
252 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f68f219a25 | ||
|
8f16b11d02 | ||
|
df5eced904 | ||
|
1dcd158f43 | ||
|
757c9b564d | ||
|
07cef3eb5e | ||
|
85c525e19b | ||
|
477581f616 | ||
|
ff30105816 | ||
|
49f04a594b | ||
|
716090a132 | ||
|
c835514c7b | ||
|
b136e7ff0e | ||
|
9dd2997b0f | ||
|
fde5309ea4 | ||
|
a8e4173e9b | ||
|
74b4c4b64d | ||
|
6cc5a160a2 | ||
|
ca8e022db6 | ||
|
cd8c14c607 | ||
|
1340533c21 | ||
|
14d86b9042 | ||
|
3a504a954f | ||
|
822ce0b8de | ||
|
40490a4656 | ||
|
0cf7909fef | ||
|
de8d4b7d9e | ||
|
0123892038 | ||
|
d00e59567a | ||
|
0aba2fdcaf | ||
|
bb910a8188 | ||
|
bdad9cc17a | ||
|
5d76a15dc0 | ||
|
a7be56a562 | ||
|
3c108e531e | ||
|
c473669cbc | ||
|
b97c486b80 | ||
|
716e092fd0 | ||
|
a362ee90fc | ||
|
1de6cdb8dc | ||
|
f473014fe9 | ||
|
2c3e5fe507 | ||
|
ecc192c6a9 | ||
|
f7bd181034 | ||
|
664a4b3604 | ||
|
0326e88910 | ||
|
e4202b33f5 | ||
|
021e7978da | ||
|
28ad6db2de | ||
|
fb62df7aa2 | ||
|
33663d7efc | ||
|
6d1edc07cb | ||
|
c36ab34c4f | ||
|
e85e7c49cb | ||
|
e56190e9da | ||
|
2d16ecf6de | ||
|
2b12269917 | ||
|
79c2dfec2d | ||
|
73356b6beb | ||
|
bc22987330 | ||
|
c033c0e3c8 | ||
|
c9ed2cf4b5 | ||
|
52b87c7776 | ||
|
8b2ed0dbdc | ||
|
9424d4d5f9 | ||
|
67b186a1a5 | ||
|
436f9ed074 | ||
|
c1e51329be | ||
|
ae1193c1c5 | ||
|
9601a4d1a9 | ||
|
bdfde1205a | ||
|
5992628f80 | ||
|
d24e6fd8e7 | ||
|
c31c2e8d8e | ||
|
9aaf062d78 | ||
|
0b9e812d59 | ||
|
dc63e46852 | ||
|
e314686a03 | ||
|
f764a650da | ||
|
67616deb79 | ||
|
d0aa80a004 | ||
|
f66c105cc0 | ||
|
2a528cb3d6 | ||
|
8b40f97a3d | ||
|
fa9263ed32 | ||
|
88c42b74c7 | ||
|
f7406ec90b | ||
|
e446c8ee8b | ||
|
5839e944e1 | ||
|
15e41c10db | ||
|
99a8ea18bb | ||
|
5453f8acfa | ||
|
c95d1421c6 | ||
|
f631f16690 | ||
|
d397c2dce8 | ||
|
273816b8a4 | ||
|
3094c3248b | ||
|
ae6018f0e1 | ||
|
54adbedf9f | ||
|
eb29e34f17 | ||
|
4a402ee673 | ||
|
764babdf06 | ||
|
dd49d202b7 | ||
|
a396c2d9dd | ||
|
15fe8b5daf | ||
|
f8da25a6f3 | ||
|
383acba443 | ||
|
690c03b396 | ||
|
f4ed907134 | ||
|
1b0badd8d8 | ||
|
2c3ada4710 | ||
|
0df3c1a4a1 | ||
|
ac589e0461 | ||
|
8f181eed85 | ||
|
6fefce4c4d | ||
|
d9e080f4b9 | ||
|
762a2eca1f | ||
|
2fba771681 | ||
|
b5e2b6f483 | ||
|
17e5ff8b89 | ||
|
3d287b2afa | ||
|
3f33274cec | ||
|
ee9d8a51bf | ||
|
80a7678a82 | ||
|
de8a0e2207 | ||
|
122b3ae0d9 | ||
|
b4307f9123 | ||
|
5ae18ba1bf | ||
|
44c8c9f459 | ||
|
4e177ff198 | ||
|
ad679a996d | ||
|
7d86a5e3eb | ||
|
214c9a383c | ||
|
f77e1c6b8c | ||
|
7e784b9507 | ||
|
7a14991ed6 | ||
|
4c5c2d7f6e | ||
|
87b90b47ce | ||
|
9f060243f0 | ||
|
d3ab32a7ac | ||
|
7bd081b7cf | ||
|
3a5b482884 | ||
|
db66264bc6 | ||
|
ae1ddd82d0 | ||
|
8523abd6f1 | ||
|
e1892c4ff4 | ||
|
a50a7b3b0e | ||
|
9d2268a925 | ||
|
d77a86c08b | ||
|
d605f685cf | ||
|
bbc1fd28c2 | ||
|
cff8a258d0 | ||
|
1d760a548e | ||
|
25fa8a3852 | ||
|
ca13684c0d | ||
|
0ad6b741e7 | ||
|
4ce756d760 | ||
|
5f2813d3af | ||
|
1b7458529c | ||
|
9c9c8d7490 | ||
|
2700bfdce8 | ||
|
5498c5ce3f | ||
|
6f444a8da0 | ||
|
454c14eee1 | ||
|
30aa8e8186 | ||
|
2ca141810c | ||
|
9da8e4f1c1 | ||
|
ef471c32bb | ||
|
49d557caec | ||
|
4366f908f3 | ||
|
237e66495b | ||
|
15d4117d7f | ||
|
d7daa5f2af | ||
|
b08ff62406 | ||
|
9aa89d3be8 | ||
|
518f2e425e | ||
|
8fae6e621d | ||
|
30f3ae1ade | ||
|
ef4b1c8868 | ||
|
7f64d2661f | ||
|
ab93380d7c | ||
|
a6adf73ecf | ||
|
d9e52038ac | ||
|
be7ddc732b | ||
|
79b25c8a41 | ||
|
12fa209555 | ||
|
28a9f5682e | ||
|
06321380ee | ||
|
b51ce34190 | ||
|
317c94979a | ||
|
df2fd1b3f1 | ||
|
35f0228986 | ||
|
f391027c8c | ||
|
4e570475df | ||
|
e2066f433f | ||
|
78b328dc18 | ||
|
f0cbacd01a | ||
|
d45c39a5fe | ||
|
a6010716e8 | ||
|
d2c7563c5c | ||
|
0c167a9382 | ||
|
b9d2e4baf1 | ||
|
82e230010b | ||
|
03fb1a5ca2 | ||
|
8ac07ce6d7 | ||
|
12da9f3178 | ||
|
ae45329d2b | ||
|
f499380fe8 | ||
|
0083e9ef68 | ||
|
22b7cf5e6c | ||
|
f973766c73 | ||
|
0efdd3300d | ||
|
5016377dd1 | ||
|
2d40a35112 | ||
|
9ea6cd0b32 | ||
|
a52a246982 | ||
|
803fe5db2f | ||
|
39980a1374 | ||
|
d2c4af273b | ||
|
d51dfa88f1 | ||
|
869b9d3b9d | ||
|
f4b26c5b40 | ||
|
15f629ec53 | ||
|
9406a9cc34 | ||
|
52438f45e1 | ||
|
7b2ce072ee | ||
|
89d93dcffb | ||
|
0fb34b1c61 | ||
|
980a6b0af8 | ||
|
5c7a467caa | ||
|
35fd5c415d | ||
|
2762108986 | ||
|
876d63fd8b | ||
|
263ef4b47f | ||
|
1c540476d3 | ||
|
1d0f3d3fd6 | ||
|
c7cec25a29 | ||
|
23c8dc00e8 | ||
|
0da8190637 | ||
|
d766295286 | ||
|
21e3c64e01 | ||
|
9ddcd6d89e | ||
|
a154d5881c | ||
|
fb594e50fd | ||
|
75c5a003bf | ||
|
6f4cbddcad | ||
|
40528150f7 | ||
|
2b80823a1b | ||
|
37ee769119 | ||
|
cfd39ebbd5 | ||
|
0532b30f7f | ||
|
b92a38f49d |
@@ -30,12 +30,17 @@ variables:
|
|||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- "dotnet publish -c Release -r linux-x64 --self-contained -p:PublishSingleFile=true -o $LINUX_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
- |
|
||||||
- "dotnet publish -c Release -r linux-arm64 --self-contained -p:PublishSingleFile=true -o $LINUX_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
VERSION_STRING=""
|
||||||
- "dotnet publish -c Release -r win-x64 --self-contained -p:PublishSingleFile=true -o $WIN_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
if [ -n "$CI_COMMIT_TAG" ]; then
|
||||||
- "dotnet publish -c Release -r win-arm64 --self-contained -p:PublishSingleFile=true -o $WIN_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
VERSION_STRING="-p:Version=$CI_COMMIT_TAG"
|
||||||
- "dotnet publish -c Release -r osx-x64 --self-contained -p:PublishSingleFile=true -o $MACOS_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
fi
|
||||||
- "dotnet publish -c Release -r osx-arm64 --self-contained -p:PublishSingleFile=true -o $MACOS_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
- "dotnet publish -c Release -r linux-x64 --self-contained $VERSION_STRING -o $LINUX_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||||
|
- "dotnet publish -c Release -r linux-arm64 --self-contained $VERSION_STRING -o $LINUX_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||||
|
- "dotnet publish -c Release -r win-x64 --self-contained $VERSION_STRING -o $WIN_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||||
|
- "dotnet publish -c Release -r win-arm64 --self-contained $VERSION_STRING -o $WIN_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||||
|
- "dotnet publish -c Release -r osx-x64 --self-contained $VERSION_STRING -o $MACOS_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||||
|
- "dotnet publish -c Release -r osx-arm64 --self-contained $VERSION_STRING -o $MACOS_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- "$LINUX_X64_OUTPUT_DIR/"
|
- "$LINUX_X64_OUTPUT_DIR/"
|
||||||
@@ -81,7 +86,7 @@ release:
|
|||||||
- if: $CI_COMMIT_TAG
|
- if: $CI_COMMIT_TAG
|
||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
release-cli create --name "NadekoBot v$CI_COMMIT_TAG" --description "## [Changelog](https://gitlab.com/nadeko/nadekobot/-/blob/v5/CHANGELOG.md#$(echo "$CI_COMMIT_TAG" | sed "s/\.//g")-$(date +%d%m%Y))" --tag-name $CI_COMMIT_TAG \
|
release-cli create --name "NadekoBot v$CI_COMMIT_TAG" --description "## [Changelog](https://gitlab.com/kwoth/nadekobot/-/blob/v5/CHANGELOG.md#$(echo "$CI_COMMIT_TAG" | sed "s/\.//g")-$(date +%d%m%Y))" --tag-name $CI_COMMIT_TAG \
|
||||||
--assets-link "{\"name\":\"${LINUX_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_X64_RELEASE}\"}" \
|
--assets-link "{\"name\":\"${LINUX_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_X64_RELEASE}\"}" \
|
||||||
--assets-link "{\"name\":\"${LINUX_ARM64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_ARM64_RELEASE}\"}" \
|
--assets-link "{\"name\":\"${LINUX_ARM64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_ARM64_RELEASE}\"}" \
|
||||||
--assets-link "{\"name\":\"${WIN_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_X64_RELEASE}\"}" \
|
--assets-link "{\"name\":\"${WIN_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_X64_RELEASE}\"}" \
|
||||||
@@ -113,7 +118,7 @@ build-installer:
|
|||||||
script:
|
script:
|
||||||
- dotnet clean
|
- dotnet clean
|
||||||
- dotnet restore -f --no-cache -v n
|
- dotnet restore -f --no-cache -v n
|
||||||
- dotnet publish -c Release --runtime win-x64 /p:Version=$CI_COMMIT_TAG src/NadekoBot
|
- dotnet publish -c Release --self-contained --runtime win-x64 /p:Version=$CI_COMMIT_TAG src/NadekoBot
|
||||||
- $env:NADEKOBOT_INSTALL_VERSION = $CI_COMMIT_TAG
|
- $env:NADEKOBOT_INSTALL_VERSION = $CI_COMMIT_TAG
|
||||||
- iscc.exe "/O+" ".\exe_builder.iss"
|
- iscc.exe "/O+" ".\exe_builder.iss"
|
||||||
tags:
|
tags:
|
||||||
@@ -123,6 +128,8 @@ publish-medusa-package:
|
|||||||
stage: publish-medusa-package
|
stage: publish-medusa-package
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
rules:
|
rules:
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||||
|
when: never
|
||||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG
|
||||||
script:
|
script:
|
||||||
- LAST_TAG=$(git describe --tags --abbrev=0)
|
- LAST_TAG=$(git describe --tags --abbrev=0)
|
||||||
|
352
CHANGELOG.md
352
CHANGELOG.md
@@ -2,7 +2,353 @@
|
|||||||
|
|
||||||
Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
||||||
|
|
||||||
## [5.0.0]
|
## [5.1.16] - 28.10.2024
|
||||||
|
|
||||||
|
## Added
|
||||||
|
|
||||||
|
- Added .ncanvas and related commands.
|
||||||
|
- You can set pixel colors (and text) on a 500x350 canvas, pepega version of r/place
|
||||||
|
- You use currency to set pixels.
|
||||||
|
- Commands:
|
||||||
|
- see the entire canvas: `.nc`
|
||||||
|
- zoom: `.ncz <pos>` or `.ncz x y`
|
||||||
|
- set pixel: `.ncsp <pos> <color> <text?>`
|
||||||
|
- get pixel: `.ncp <pos>`
|
||||||
|
- Owners can use .ncsetimg to set a starting image, use `.h .setimg` for instructions
|
||||||
|
- Owners can reset the whole canvas via `.ncreset`
|
||||||
|
|
||||||
|
## [5.1.15] - 21.10.2024
|
||||||
|
|
||||||
|
## Added
|
||||||
|
|
||||||
|
- Added -c option for `.xpglb`
|
||||||
|
-
|
||||||
|
|
||||||
|
## Change
|
||||||
|
|
||||||
|
- Leaderboards will now show 10 users per page
|
||||||
|
- A lot of internal changes and improvements
|
||||||
|
|
||||||
|
## Fixed
|
||||||
|
|
||||||
|
- Fixed a big issue which caused several features to not get loaded on bot restart
|
||||||
|
- Alias collision fix `.qse` is now quotesearch, `.qs` will stay `.queuesearch`
|
||||||
|
- Fixed some migrations which would prevent users from updating from ancient versions
|
||||||
|
- Waifulb will no longer show #0000 discrims
|
||||||
|
- More `.greet` command fixes
|
||||||
|
- Author name will now be counted as content in embeds. Embeds can now only have author fields and still be valid
|
||||||
|
- Grpc api fixes, and additions
|
||||||
|
|
||||||
|
## [5.1.14] - 03.10.2024
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
|
||||||
|
- Improved `.xplb -c`, it will now correctly only show users who are still in the server with no count limit
|
||||||
|
|
||||||
|
## Fixed
|
||||||
|
|
||||||
|
- Fixed medusa load error on startup
|
||||||
|
|
||||||
|
## [5.1.13] - 03.10.2024
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Grpc api server will no longer start unless enabled in creds
|
||||||
|
- Seq comment in creds fixed
|
||||||
|
|
||||||
|
## [5.1.12] - 03.10.2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added support for `seq` for logging. If you fill in seq url and apiKey in creds.yml, bot will sends logs to it
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed another bug in `.greet` / `.bye` system, which caused it to show wrong message on a wrong server occasionally
|
||||||
|
|
||||||
|
## [5.1.11] - 03.10.2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `%user.displayname%` placeholder. It will show users nickname, if there is one, otherwise it will show the username.
|
||||||
|
- Nickname won't be shown in bye messages.
|
||||||
|
- Added initial version of grpc api. Beta
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed a bug which caused `.bye` and `.greet` messages to be randomly disabled
|
||||||
|
- Fixed `.lb -c` breaking sometimes, and fixed pagination
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Youtube now always uses `yt-dlp`. Dropped support for `youtube-dl`
|
||||||
|
- If you've previously renamed your yt-dlp file to youtube-dl, please rename it back.
|
||||||
|
- ytProvider in data/searches.yml now also controls where you're getting your song streams from.
|
||||||
|
- (Invidious support added for .q)
|
||||||
|
|
||||||
|
## [5.1.10] - 24.09.2024
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed claimed waifu decay in `games.yml`
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Added some logs for greet service in case there are unforeseen issues, for easier debugging
|
||||||
|
|
||||||
|
## [5.1.9] - 21.09.2024
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `.greettest`, and other `.*test` commands if you didn't have them enabled.
|
||||||
|
- Fixed `.greetdmtest` sending messages twice.
|
||||||
|
- Fixed a serious bug which caused greet messages to be jumbled up, and wrong ones to be sent for the wrong events.
|
||||||
|
- There is no database issue, all greet messages are safe, the cache was caching any setting every 3 seconds with no regard for the type of the event
|
||||||
|
- This also caused `.greetdm` messages to not be sent if `.greet` is enabled
|
||||||
|
- This bug was introduced in 5.1.8. PLEASE UPDATE if you are on 5.1.8
|
||||||
|
- Selfhosters only: Fixed medusa dependency loading
|
||||||
|
- Note: Make sure to not publish any other DLLs besides the ones you are sure you will need, as there can be version conflicts which didn't happen before.
|
||||||
|
|
||||||
|
## [5.1.8] - 19.09.2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `.leaveunkeptservers` which will make the bot leave all servers on all shards whose owners didn't run `.keep` command.
|
||||||
|
- This is a dangerous and irreversible command, don't use it. Meant for use on the public bot.
|
||||||
|
- `.adpl` now supports custom statuses (you no longer need to specify Playing, Watching, etc...)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `.quote` commands cleaned up and improved
|
||||||
|
- All quote commands now start with `.q<whatever>` and follow the same naming pattern as Expression commands
|
||||||
|
- `.liqu` renamed to `.qli`
|
||||||
|
- `.quotesearch` / `.qse` is now paginated for easier searching
|
||||||
|
- `.whosplaying` is now paginated
|
||||||
|
- `.img` is now paginated
|
||||||
|
- `.setgame` renamed to`.setactivity` and now supports custom text activity. You don't have to specify playing, listening etc before the activity
|
||||||
|
- Clarified and added some embed / placeholder links to command help where needed
|
||||||
|
- dev: A lot of code cleanup and internal improvements
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `.xpcurrew` breaking xp gain if user gains 0 xp from being in a voice channel
|
||||||
|
- Fixed a bug in `.gatari` command
|
||||||
|
- Fixed some waifu related strings
|
||||||
|
- Fixed `.quoteshow` and `.quoteid` commands
|
||||||
|
- Fixed some placeholders not working in `.greetdm`
|
||||||
|
- Fixed postgres support
|
||||||
|
- Fixed and clarified some command strings/parameter descriptions
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Removed mysql support as it didn't work for a while, and requires some special handling/maintenance
|
||||||
|
- Sqlite and Postgres support stays
|
||||||
|
|
||||||
|
## [5.1.7] - 08.08.2024
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed some command groups incorrectly showing up as modules
|
||||||
|
|
||||||
|
## [5.1.6] - 07.08.2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `.serverlist` is now paginated
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `.listservers` renamed to `.serverlist`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `.afk` messages can no longer ping, and the response is moved to DMs to avoid abuse
|
||||||
|
- Possible fix for `.remind` timestamp
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Removed old bloat / semi broken / dumb commands
|
||||||
|
- `.memelist` / `.memegen` (too inconvenient to use)
|
||||||
|
- `.activity` (useless owner-only command)
|
||||||
|
- `.rafflecur` (Just use raffle and then award manually instead)
|
||||||
|
- `.rollduel` (we had this command?)
|
||||||
|
- You can no longer bet on `.connect4`
|
||||||
|
- `.economy` Removed.
|
||||||
|
- Was buggy and didn't really show the real state of the economy.
|
||||||
|
- It might come back improved in the future
|
||||||
|
- `.mal` Removed. Useless information / semi broken
|
||||||
|
|
||||||
|
## [5.1.5] - 01.08.2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added: Added a `.afk <msg>?` command which sets an afk message which will trigger whenever someone pings you
|
||||||
|
- Message will when you type a message in any channel that the bot sees, or after 8 hours, whichever comes first
|
||||||
|
- The specified message will be prefixed with "The user is afk: "
|
||||||
|
- The afk message will disappear 30 seconds after being triggered
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Bot now shows a message when .prune fails due to already running error
|
||||||
|
- Updated some bet descriptions to include 'all' 'half' usage instructions
|
||||||
|
- Updated some command strings
|
||||||
|
- dev: Vastly simplified medusa creation using dotnet templates, docs updated
|
||||||
|
- Slight refactor of .wiki, time, .catfact, .wikia, .define, .bible and .quran commands, no significant change in functionality
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- .coins will no longer show double minus sign for negative changes
|
||||||
|
- You can once again disable cleverbot responses using fake 'cleverbot:response' module name in permission commands
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Removed .rip command
|
||||||
|
|
||||||
|
## [5.1.4] - 13.07.2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `.coins` command which lists top 10 cryptos ordered by marketcap
|
||||||
|
- Added Clubs rank in the leaderboard to `.clubinfo`
|
||||||
|
- Bot owners can now check other people's bank balance (Not server owners, only bot owner, the person who is hosting the bot)
|
||||||
|
- You can now send multiple waifu gifts at once to waifus. For example `.waifugift 3xRose @user` will give that user 3 roses
|
||||||
|
- The format is `<NUMBER>x<ITEM>`, no spaces
|
||||||
|
- Added `.boosttest` command
|
||||||
|
- Added support for any openai compatible api for the chatterbot feature change:
|
||||||
|
- Changed games.yml to allow input of the apiUrl (needs to be openai compatible) and modelName as a string.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Updated command strings to clarify `.say` and `.send` usages
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `.waifugift` help string
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Removed selfhost button from `.donate` command, no idea why it was there in the first place
|
||||||
|
|
||||||
|
## [5.1.3] - 06.07.2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `.quran` command, which will show the provided ayah in english and arabic, including recitation by Alafasy
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Replying to the bot's message in the channel where chatterbot is enabled will also trigger the ai response, as if you pinged the bot. This only works for chatterbot, but not for nadeko ai command prompts
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `.stickeradd` it now properly supports 300x300 image uploads.
|
||||||
|
- Bot should now trim the invalid characters from chatterbot usernames to avoid openai errors
|
||||||
|
- Fixed prompt triggering chatterbot responses twice
|
||||||
|
|
||||||
|
## [5.1.2] - 29.06.2024
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `.honeypot` not unbanning and not pruning messages
|
||||||
|
|
||||||
|
## [5.1.1] - 27.06.2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `.honeypot` command, which automatically softbans (ban and immediate unban) any user who posts in that channel.
|
||||||
|
- Useful to auto softban bots who spam every channel upon joining
|
||||||
|
- Users who run commands or expressions won't be softbanned.
|
||||||
|
- Users who have ban member permissions are also excluded.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `.betdraw` not respecting maxbet
|
||||||
|
- Fixed `.xpshop` pagination for real this time?
|
||||||
|
|
||||||
|
## [5.1.0] - 25.06.2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `.prompt` command, Nadeko Ai Assistant
|
||||||
|
- You can send natural language questions, queries or execute commands. For example "@Nadeko how's the weather in paris" and it will return `.we Paris` and run it for you.
|
||||||
|
- In case the bot can't execute a command using your query, It will fall back to your chatter bot, in case you have it enabled in data/games.yml. (Cleverbot or chatgpt)
|
||||||
|
- (It's far from perfect so please don't ask the bot to do dangerous things like banning or pruning)
|
||||||
|
- Requires Patreon subscription, after which you'll be able to run it on global @Nadeko bot.
|
||||||
|
- Selfhosters: If you're selfhosting, you also will need to acquire the api key from <https://dashy.nadeko.bot/me> after pledging on patreon and put it in nadekoAiToken in creds.yml
|
||||||
|
- Added support for `gpt-4o` in `data/games.yml`
|
||||||
|
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Remind will now show a timestamp tag for durations
|
||||||
|
- Only `Gpt35Turbo` and `Gpt4o` are valid inputs in games.yml now
|
||||||
|
- `data/patron.yml` changed. It now has limits. The entire feature limit system has been reworked. Your previous settings will be reset
|
||||||
|
- A lot of updates to bot strings (thanks Ene)
|
||||||
|
- Improved cleanup command to delete a lot more data once cleanup is ran, not only guild configs (please don't use this command unless you have your database bakced up and you know 100% what you're doing)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed xp bg buy button not working, and possibly some other buttons too
|
||||||
|
- Fixed shopbuy %user% placeholders and updated help text
|
||||||
|
- All .feed overloads should now work"
|
||||||
|
- `.xpexclude` should will now work with forums too. If you exclude a forum you won't be able to gain xp in any of the threads.
|
||||||
|
- Fixed remind not showing correct time (thx cata)
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Removed PoE related commands
|
||||||
|
- dev: Removed patron quota data from the database, it will now be stored in redis
|
||||||
|
|
||||||
|
## [5.0.8] - 21.05.2024
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `.setserverbanner` and `.setservericon` commands (thx cata)
|
||||||
|
- Added overloads section to `.h command` which will show you all versions of command usage with param names
|
||||||
|
- You can now check commands for submodules, for example `.cmds SelfAssignedRoles` will show brief help for each of the commands in that submodule
|
||||||
|
- Added dropdown menus for .mdls and .cmds (both module and group versions) which will give you the option to see more detailed help for each specific module, group or command respectively
|
||||||
|
- Self-Hosters only:
|
||||||
|
- Added a dangerous cleanup command that you don't have to know about
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Quotes will now use alphanumerical ids (like expressions)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `.verbose` will now be respected for expression errors
|
||||||
|
- Using `.pick` will now correctly show the name of the user who picked the currency
|
||||||
|
- Fixed `.h` not working on some commands
|
||||||
|
- `.langset` and `.langsetd` should no longer allow unsupported languages and nonsense to be typed in
|
||||||
|
|
||||||
|
## [5.0.7] - 15.05.2024
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `.streammessage` will once again be able to mention anyone (as long as the user setting the message has the permission to mention everyone)
|
||||||
|
- `.streammsgall` fixed
|
||||||
|
- `.xplb` and `.xpglb` pagination fixed
|
||||||
|
- Fixed page number when the total number of elements is unknown
|
||||||
|
|
||||||
|
## [5.0.6] - 14.05.2024
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `.greet` and `.bye` will now be automatically disabled if the bot losses permissions to post in the specified channel
|
||||||
|
- Removed response replies from `.blackjack` and `.pick` as the original message will always be deleted
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `.blackjack` response string as it contained no user name
|
||||||
|
- Fixed `.ttt` and `.gift` strings not mentioning the user
|
||||||
|
|
||||||
|
## [5.0.5] - 11.05.2024
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `%server.members%` placeholder fixed
|
||||||
|
- `.say #channel <message>` should now be working properly again
|
||||||
|
- `.repeat`, `.greet`, `.bye` and `.boost` command can now once again mention anyone
|
||||||
|
|
||||||
|
## [5.0.4] - 10.05.2024
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
@@ -71,7 +417,7 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
|
|||||||
- Removed log voice presence TTS
|
- Removed log voice presence TTS
|
||||||
- Cleanup: Removed a lot of obsolete aliases from aliases.yml
|
- Cleanup: Removed a lot of obsolete aliases from aliases.yml
|
||||||
|
|
||||||
## [4.3.22] - 23.04.2023
|
## [4.3.22] - 23.04.2024
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Added `.setbanner` command (thx cata)
|
- Added `.setbanner` command (thx cata)
|
||||||
@@ -80,7 +426,7 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except da
|
|||||||
- Fixed pagination error due to a missing emoji
|
- Fixed pagination error due to a missing emoji
|
||||||
|
|
||||||
|
|
||||||
## [4.3.21] - 19.04.2023
|
## [4.3.21] - 19.04.2024
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Possible fix for a duplicate in `.h bank`
|
- Possible fix for a duplicate in `.h bank`
|
||||||
|
23
Dockerfile
23
Dockerfile
@@ -1,16 +1,24 @@
|
|||||||
|
# Use the .NET 8.0 SDK as the base image for the build stage
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
WORKDIR /source
|
WORKDIR /source
|
||||||
|
|
||||||
|
# Copy the .csproj files for each project
|
||||||
COPY src/Nadeko.Medusa/*.csproj src/Nadeko.Medusa/
|
COPY src/Nadeko.Medusa/*.csproj src/Nadeko.Medusa/
|
||||||
COPY src/NadekoBot/*.csproj src/NadekoBot/
|
COPY src/NadekoBot/*.csproj src/NadekoBot/
|
||||||
COPY src/NadekoBot.Coordinator/*.csproj src/NadekoBot.Coordinator/
|
COPY src/NadekoBot.Coordinator/*.csproj src/NadekoBot.Coordinator/
|
||||||
COPY src/NadekoBot.Generators/*.csproj src/NadekoBot.Generators/
|
COPY src/NadekoBot.Generators/*.csproj src/NadekoBot.Generators/
|
||||||
COPY src/NadekoBot.Voice/*.csproj src/NadekoBot.Voice/
|
COPY src/NadekoBot.Voice/*.csproj src/NadekoBot.Voice/
|
||||||
COPY NuGet.Config ./
|
|
||||||
|
# Restore the dependencies for the NadekoBot project
|
||||||
RUN dotnet restore src/NadekoBot/
|
RUN dotnet restore src/NadekoBot/
|
||||||
|
|
||||||
|
# Copy the rest of the source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Set the working directory to the NadekoBot project
|
||||||
WORKDIR /source/src/NadekoBot
|
WORKDIR /source/src/NadekoBot
|
||||||
|
|
||||||
|
# Build and publish the NadekoBot project, then clean up unnecessary files
|
||||||
RUN set -xe; \
|
RUN set -xe; \
|
||||||
dotnet --version; \
|
dotnet --version; \
|
||||||
dotnet publish -c Release -o /app --no-restore; \
|
dotnet publish -c Release -o /app --no-restore; \
|
||||||
@@ -19,28 +27,33 @@ RUN set -xe; \
|
|||||||
find /app -type f -exec chmod -x {} \; ;\
|
find /app -type f -exec chmod -x {} \; ;\
|
||||||
chmod +x /app/NadekoBot
|
chmod +x /app/NadekoBot
|
||||||
|
|
||||||
# final stage/image
|
# Use the .NET 8.0 runtime as the base image for the final stage
|
||||||
FROM mcr.microsoft.com/dotnet/runtime:8.0
|
FROM mcr.microsoft.com/dotnet/runtime:8.0
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Create a new user, install dependencies, and set up sudoers file
|
||||||
RUN set -xe; \
|
RUN set -xe; \
|
||||||
useradd -m nadeko; \
|
useradd -m nadeko; \
|
||||||
apt-get update; \
|
apt-get update; \
|
||||||
apt-get install -y --no-install-recommends libopus0 libsodium23 libsqlite3-0 curl ffmpeg python3 sudo; \
|
apt-get install -y --no-install-recommends libsqlite3-0 curl ffmpeg sudo python3; \
|
||||||
update-alternatives --install /usr/local/bin/python python /usr/bin/python3.9 1; \
|
|
||||||
echo 'Defaults>nadeko env_keep+="ASPNETCORE_* DOTNET_* NadekoBot_* shard_id total_shards TZ"' > /etc/sudoers.d/nadeko; \
|
echo 'Defaults>nadeko env_keep+="ASPNETCORE_* DOTNET_* NadekoBot_* shard_id total_shards TZ"' > /etc/sudoers.d/nadeko; \
|
||||||
curl -Lo /usr/local/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp; \
|
curl -Lo /usr/local/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp; \
|
||||||
chmod a+rx /usr/local/bin/yt-dlp; \
|
chmod a+rx /usr/local/bin/yt-dlp; \
|
||||||
apt-get autoremove -y; \
|
apt-get autoremove -y; \
|
||||||
apt-get autoclean -y
|
apt-get autoclean -y
|
||||||
|
|
||||||
|
# Copy the built application and the entrypoint script from the build stage
|
||||||
COPY --from=build /app ./
|
COPY --from=build /app ./
|
||||||
COPY docker-entrypoint.sh /usr/local/sbin
|
COPY docker-entrypoint.sh /usr/local/sbin
|
||||||
|
|
||||||
|
# Set environment variables
|
||||||
ENV shard_id=0
|
ENV shard_id=0
|
||||||
ENV total_shards=1
|
ENV total_shards=1
|
||||||
ENV NadekoBot__creds=/app/data/creds.yml
|
ENV NadekoBot__creds=/app/data/creds.yml
|
||||||
|
|
||||||
|
# Define the data directory as a volume
|
||||||
VOLUME [ "/app/data" ]
|
VOLUME [ "/app/data" ]
|
||||||
|
|
||||||
|
# Set the entrypoint and default command
|
||||||
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
||||||
CMD dotnet NadekoBot.dll "$shard_id" "$total_shards"
|
CMD dotnet NadekoBot.dll "$shard_id" "$total_shards"
|
@@ -12,7 +12,6 @@ ProjectSection(SolutionItems) = preProject
|
|||||||
README.md = README.md
|
README.md = README.md
|
||||||
.gitlab-ci.yml = .gitlab-ci.yml
|
.gitlab-ci.yml = .gitlab-ci.yml
|
||||||
Dockerfile = Dockerfile
|
Dockerfile = Dockerfile
|
||||||
NuGet.Config = NuGet.Config
|
|
||||||
migrate.ps1 = migrate.ps1
|
migrate.ps1 = migrate.ps1
|
||||||
remove-migration.ps1 = remove-migration.ps1
|
remove-migration.ps1 = remove-migration.ps1
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
@@ -31,6 +30,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Medusa", "src\Nadeko
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Generators", "src\NadekoBot.Generators\NadekoBot.Generators.csproj", "{92770AF3-83EE-49F1-A0BB-79124D19A13D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Generators", "src\NadekoBot.Generators\NadekoBot.Generators.csproj", "{92770AF3-83EE-49F1-A0BB-79124D19A13D}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.GrpcApiBase", "src\NadekoBot.GrpcApiBase\NadekoBot.GrpcApiBase.csproj", "{FB74B9EA-10B9-4542-ACB1-35523A95A587}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -80,6 +81,12 @@ Global
|
|||||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -92,6 +99,7 @@ Global
|
|||||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{E685977E-31A4-46F4-A5D7-4E3E39E82E43} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{92770AF3-83EE-49F1-A0BB-79124D19A13D} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
{2F4CF6D6-0C2F-4944-B204-9508CDA53195} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{2F4CF6D6-0C2F-4944-B204-9508CDA53195} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {5F3F555C-855F-4BE8-B526-D062D3E8ACA4}
|
SolutionGuid = {5F3F555C-855F-4BE8-B526-D062D3E8ACA4}
|
||||||
|
@@ -1,6 +0,0 @@
|
|||||||
<configuration>
|
|
||||||
<packageSources>
|
|
||||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
|
||||||
<add key="nadeko.bot" value="https://www.myget.org/F/nadeko/api/v3/index.json" protocolVersion="3" />
|
|
||||||
</packageSources>
|
|
||||||
</configuration>
|
|
@@ -1,23 +0,0 @@
|
|||||||
version: "3.7"
|
|
||||||
|
|
||||||
services:
|
|
||||||
nadeko:
|
|
||||||
image: insert-image-name-here:latest
|
|
||||||
depends_on:
|
|
||||||
- redis
|
|
||||||
environment:
|
|
||||||
TZ: Europe/Paris
|
|
||||||
NadekoBot_RedisOptions: redis,name=nadeko
|
|
||||||
#NadekoBot_ShardRunCommand: dotnet
|
|
||||||
#NadekoBot_ShardRunArguments: /app/NadekoBot.dll {0} {1}
|
|
||||||
volumes:
|
|
||||||
- /srv/nadeko/conf:/app/conf:ro
|
|
||||||
- /srv/nadeko/data:/app/data
|
|
||||||
|
|
||||||
redis:
|
|
||||||
image: redis:4-alpine
|
|
||||||
sysctls:
|
|
||||||
- net.core.somaxconn=511
|
|
||||||
command: redis-server --maxmemory 32M --maxmemory-policy volatile-lru
|
|
||||||
volumes:
|
|
||||||
- /srv/nadeko/redis-data:/data
|
|
@@ -1,6 +1,6 @@
|
|||||||
# How to contribute
|
# How to contribute
|
||||||
|
|
||||||
1. Make Merge Requests to the [**v5 branch**](https://gitlab.com/nadeko/nadekobot/tree/v5)
|
1. Make Merge Requests to the [**v5 branch**](https://gitlab.com/kwoth/nadekobot/tree/v5)
|
||||||
2. Keep a single Merge Request to a single feature
|
2. Keep a single Merge Request to a single feature
|
||||||
3. Fill out the MR template
|
3. Fill out the MR template
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ You can also donate to us through [PayPal][paypal] for one-time donations using
|
|||||||
|
|
||||||
[![img][paypal-button]][paypal]
|
[![img][paypal-button]][paypal]
|
||||||
|
|
||||||
[gitlab]: https://gitlab.com/nadeko/nadekobot
|
[gitlab]: https://gitlab.com/kwoth/nadekobot
|
||||||
[discord-server]: https://discord.nadeko.bot/
|
[discord-server]: https://discord.nadeko.bot/
|
||||||
[patreon]: https://www.patreon.com/nadekobot
|
[patreon]: https://www.patreon.com/nadekobot
|
||||||
[patreon-button]: ./assets/patreon.png
|
[patreon-button]: ./assets/patreon.png
|
||||||
|
@@ -1,46 +1,76 @@
|
|||||||
# Setting up NadekoBot with Docker
|
# Deploying NadekoBot with Docker: A Comprehensive Guide
|
||||||
|
|
||||||
# WORK IN PROGRESS
|
## Getting Started
|
||||||
|
|
||||||
### Installation
|
Ensure Docker and Docker Compose are installed on your system. If not, follow the official Docker guides for your specific operating system:
|
||||||
|
|
||||||
|
- [Docker Installation Guide](https://docs.docker.com/engine/install/)
|
||||||
|
- [Docker Compose Installation Guide](https://docs.docker.com/compose/install/)
|
||||||
|
|
||||||
|
## Step-by-Step Installation
|
||||||
|
|
||||||
|
1. **Choose Your Workspace:** Select a directory where you'll set up your NadekoBot stack. Use your terminal to navigate to this directory. For the purpose of this guide, we'll use `/opt/stacks/nadekobot/` as an example, but you can choose any directory that suits your needs.
|
||||||
|
|
||||||
|
2. **Create a Docker Compose File:** In this directory, create a Docker Compose file named `docker-compose.yml`. You can use any text editor for this task. For instance, to use the `nano` editor, type `nano docker-compose.yml`.
|
||||||
|
|
||||||
|
3. **Configure Your Docker Compose File:** Populate your Docker Compose file with the following configuration:
|
||||||
|
|
||||||
1. Create a `/srv/nadeko` folder
|
|
||||||
- `mkdir -p /srv/nadeko`
|
|
||||||
2. Create a `docker-compose.yml`
|
|
||||||
- nano `docker-compose.yml`
|
|
||||||
- copy the following contents into it:
|
|
||||||
##### docker-compose.yml
|
|
||||||
```yml
|
```yml
|
||||||
version: "3.7"
|
|
||||||
services:
|
services:
|
||||||
nadeko:
|
nadeko:
|
||||||
image: registry.gitlab.com/nadeko/nadekobot:latest
|
image: registry.gitlab.com/kwoth/nadekobot:latest
|
||||||
depends_on:
|
container_name: nadeko
|
||||||
- redis
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
TZ: Europe/Paris
|
TZ: Europe/Rome
|
||||||
NadekoBot_RedisOptions: redis,name=nadeko
|
|
||||||
#NadekoBot_ShardRunCommand: dotnet
|
|
||||||
#NadekoBot_ShardRunArguments: /app/NadekoBot.dll {0} {1}
|
|
||||||
volumes:
|
volumes:
|
||||||
- /srv/nadeko/conf/creds.yml:/app/creds.yml:ro
|
- /opt/stacks/nadekobot/conf/creds.yml:/app/data/creds.yml
|
||||||
- /srv/nadeko/data:/app/data
|
- /opt/stacks/nadekobot/data:/app/data
|
||||||
|
networks: {}
|
||||||
redis:
|
|
||||||
image: redis:4-alpine
|
|
||||||
sysctls:
|
|
||||||
- net.core.somaxconn=511
|
|
||||||
command: redis-server --maxmemory 32M --maxmemory-policy volatile-lru
|
|
||||||
volumes:
|
|
||||||
- /srv/nadeko/redis-data:/data
|
|
||||||
```
|
```
|
||||||
3. Save your file and run docker compose
|
|
||||||
- `docker-compose up`
|
|
||||||
4. Edit creds in `/srv/nadeko/conf/creds.yml`
|
|
||||||
5. Run it again with
|
|
||||||
- `docker-compose up`
|
|
||||||
|
|
||||||
### Updating
|
4. **Prepare Your Credentials File:** Before running Docker Compose, ensure the `creds.yml` file exists in the `/opt/stacks/nadekobot/conf/` directory. If it's missing, create it using `touch /opt/stacks/nadekobot/conf/creds.yml`. You may need to use `sudo`. Remember to replace `/opt/stacks/nadekobot/` with your chosen directory.
|
||||||
- `cd /srv/nadeko`
|
|
||||||
- `docker-compose pull`
|
5. **Edit Your Credentials File:** Populate the `creds.yml` file in `/opt/stacks/nadekobot/conf/creds.yml` with your bot's credentials. You can use any text editor for this task. For instance, to use the `nano` editor, type `nano /opt/stacks/nadekobot/conf/creds.yml`. You may need to use `sudo`. Again, replace `/opt/stacks/nadekobot/` with your chosen directory.
|
||||||
- `docker-compose up -d`
|
|
||||||
|
6. **Launch Your Bot:** Now, you're ready to run Docker Compose. Use the following command: `docker-compose up -d`.
|
||||||
|
|
||||||
|
## Keeping Your Bot Up-to-Date
|
||||||
|
|
||||||
|
There are two methods to update your NadekoBot:
|
||||||
|
|
||||||
|
### Manual Update
|
||||||
|
|
||||||
|
1. **Navigate to Your Directory:** Use `cd /path/to/your/directory` to go to the directory containing your Docker Compose file.
|
||||||
|
|
||||||
|
2. **Pull the Latest Images:** Use `docker-compose pull` to fetch the latest images.
|
||||||
|
|
||||||
|
3. **Restart Your Containers:** Use `docker-compose up -d` to restart the containers.
|
||||||
|
|
||||||
|
### Automatic Update with Watchtower
|
||||||
|
|
||||||
|
If you prefer an automated update process, consider using Watchtower. Watchtower automatically updates your Docker containers to the latest versions.
|
||||||
|
|
||||||
|
To use Watchtower with NadekoBot, you need to add a specific label to the service in your Docker Compose file. Here's how your Docker Compose file should look:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
services:
|
||||||
|
nadeko:
|
||||||
|
image: registry.gitlab.com/kwoth/nadekobot:latest
|
||||||
|
container_name: nadeko
|
||||||
|
restart: unless-stopped
|
||||||
|
labels:
|
||||||
|
- com.centurylinklabs.watchtower.enable=true
|
||||||
|
environment:
|
||||||
|
TZ: Europe/Rome
|
||||||
|
volumes:
|
||||||
|
- /opt/stacks/nadekobot/conf/creds.yml:/app/data/creds.yml
|
||||||
|
- /opt/stacks/nadekobot/data:/app/data
|
||||||
|
networks: {}
|
||||||
|
```
|
||||||
|
|
||||||
|
Remember to replace `/opt/stacks/nadekobot/` with your chosen directory in the Docker Compose file.
|
||||||
|
|
||||||
|
To install and run Watchtower, follow the guide provided by Containrrr:
|
||||||
|
|
||||||
|
- [Watchtower Installation and Usage Guide](https://containrrr.dev/watchtower/)
|
@@ -15,12 +15,13 @@
|
|||||||
|
|
||||||
##### Compatible operating systems:
|
##### Compatible operating systems:
|
||||||
|
|
||||||
- Ubuntu: 18.04, 20.04, 22.04, 22.10
|
- Ubuntu: 20.04, 22.04, 24.04
|
||||||
- Mint: 19, 20, 21
|
- Mint: 19, 20, 21
|
||||||
- Debian: 10, 11
|
- Debian: 10, 11, 12
|
||||||
- CentOS: 7
|
- RockyLinux: 8, 9
|
||||||
- openSUSE 15
|
- AlmaLinux: 8, 9
|
||||||
- ~~Fedora: 33, 34, 35~~ (Fedora is Pending Support)
|
- openSUSE Leap: 15.5, 15.6 & Tumbleweed
|
||||||
|
- Fedora: 38, 39, 40, 41, 42
|
||||||
|
|
||||||
## Linux From Source
|
## Linux From Source
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
|
|
||||||
Follow the following few steps only if you're migrating from v3. If not, skip to installation instructions.
|
Follow the following few steps only if you're migrating from v3. If not, skip to installation instructions.
|
||||||
|
|
||||||
Use the new installer script: `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
Use the new installer script: `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
> - Install prerequisites (type `1` and press `enter`)
|
> - Install prerequisites (type `1` and press `enter`)
|
||||||
> - Download (type `2` and press `enter`)
|
> - Download (type `2` and press `enter`)
|
||||||
> - Run (type `3` and press `enter`)
|
> - Run (type `3` and press `enter`)
|
||||||
@@ -38,7 +39,7 @@ Use the new installer script: `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-
|
|||||||
|
|
||||||
Open Terminal (if you're on an installation with a window manager) and navigate to the location where you want to install the bot (for example `cd ~`)
|
Open Terminal (if you're on an installation with a window manager) and navigate to the location where you want to install the bot (for example `cd ~`)
|
||||||
|
|
||||||
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
2. Install prerequisites (type `1` and press enter)
|
2. Install prerequisites (type `1` and press enter)
|
||||||
3. Download the bot (type `2` and press enter)
|
3. Download the bot (type `2` and press enter)
|
||||||
4. Exit the installer (type `6` and press enter)
|
4. Exit the installer (type `6` and press enter)
|
||||||
@@ -50,13 +51,13 @@ Open Terminal (if you're on an installation with a window manager) and navigate
|
|||||||
- `CTRL` + `X`
|
- `CTRL` + `X`
|
||||||
- `Y`
|
- `Y`
|
||||||
- `Enter`
|
- `Enter`
|
||||||
8. Run the installer script again `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
8. Run the installer script again `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
9. Run the bot (type `3` and press enter)
|
9. Run the bot (type `3` and press enter)
|
||||||
|
|
||||||
##### Source Update Instructions
|
##### Source Update Instructions
|
||||||
|
|
||||||
1. ⚠ Stop the bot ⚠
|
1. ⚠ Stop the bot ⚠
|
||||||
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
3. Update the bot (type `2` and press enter)
|
3. Update the bot (type `2` and press enter)
|
||||||
4. Run the bot (type `3` and press enter)
|
4. Run the bot (type `3` and press enter)
|
||||||
5. 🎉
|
5. 🎉
|
||||||
@@ -69,16 +70,16 @@ Open Terminal (if you're on an installation with a window manager) and navigate
|
|||||||
|
|
||||||
1. (Optional) Installing Redis
|
1. (Optional) Installing Redis
|
||||||
- ubuntu installation command: `sudo apt-get install redis-server`
|
- ubuntu installation command: `sudo apt-get install redis-server`
|
||||||
2. Playing music requires `ffmpeg`, `libopus`, `libsodium` and `youtube-dl` (which in turn requires python3)
|
2. Playing music requires `ffmpeg`, `libopus`, `libsodium` and `yt-dlp` (which in turn requires python3)
|
||||||
- ubuntu installation command: `sudo apt-get install ffmpeg libopus0 opus-tools libopus-dev libsodium-dev -y`
|
- Ubuntu installation command: `sudo apt-get install ffmpeg libopus0 opus-tools libopus-dev libsodium-dev -y`
|
||||||
|
- yt-dlp installation command: `sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp && sudo chmod a+rx /usr/local/bin/yt-dlp`
|
||||||
3. Make sure your python is version 3+ with `python --version`
|
3. Make sure your python is version 3+ with `python --version`
|
||||||
- if it's not, you can install python 3 and make it the default with: `sudo apt-get install python3.8 python-is-python3`
|
- if it's not, you can install python 3 and make it the default with: `sudo apt-get install python3.8 python-is-python3`
|
||||||
|
*You can use nadeko bash script [prerequisites installer](https://gitlab.com/kwoth/nadeko-bash-installer/-/blob/v5/n-prereq.sh) as a reference*
|
||||||
*You can use nadeko bash script [prerequisites installer](https://gitlab.com/Kwoth/nadeko-bash-installer/-/blob/v5/n-prereq.sh) as a reference*
|
|
||||||
|
|
||||||
##### Installation Instructions
|
##### Installation Instructions
|
||||||
|
|
||||||
1. Download the latest release from <https://gitlab.com/nadeko/nadekobot/-/releases>
|
1. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
||||||
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
||||||
2. Untar it
|
2. Untar it
|
||||||
- ⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
- ⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
||||||
@@ -102,7 +103,7 @@ Open Terminal (if you're on an installation with a window manager) and navigate
|
|||||||
##### Release Update Instructions
|
##### Release Update Instructions
|
||||||
|
|
||||||
1. Stop the bot
|
1. Stop the bot
|
||||||
2. Download the latest release from <https://gitlab.com/nadeko/nadekobot/-/releases>
|
2. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
||||||
- Look for the file called "x.x.x-linux-x64-build.tar" (where `X.X.X` is a version, for example 3.0.4) and download it
|
- Look for the file called "x.x.x-linux-x64-build.tar" (where `X.X.X` is a version, for example 3.0.4) and download it
|
||||||
3. Untar it
|
3. Untar it
|
||||||
- ⚠ Make sure that you change `X.X.X` to the same series of numbers as in step 2!
|
- ⚠ Make sure that you change `X.X.X` to the same series of numbers as in step 2!
|
||||||
@@ -267,7 +268,7 @@ This method is similar to the one above, but requires one extra step, with the a
|
|||||||
echo '#!/bin/bash'
|
echo '#!/bin/bash'
|
||||||
echo ""
|
echo ""
|
||||||
echo "echo \"Running NadekoBot in the background with auto restart\"
|
echo "echo \"Running NadekoBot in the background with auto restart\"
|
||||||
youtube-dl -U
|
yt-dlp -U
|
||||||
|
|
||||||
# If you want Nadeko to be compiled prior to every startup, uncomment the lines
|
# If you want Nadeko to be compiled prior to every startup, uncomment the lines
|
||||||
# below. Note that it's not necessary unless you are personally modifying the
|
# below. Note that it's not necessary unless you are personally modifying the
|
||||||
@@ -299,7 +300,7 @@ This method is similar to the one above, but requires one extra step, with the a
|
|||||||
|
|
||||||
echo \"Waiting for 5 seconds...\"
|
echo \"Waiting for 5 seconds...\"
|
||||||
sleep 5
|
sleep 5
|
||||||
youtube-dl -U
|
yt-dlp -U
|
||||||
echo \"Restarting NadekoBot...\"
|
echo \"Restarting NadekoBot...\"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@@ -31,7 +31,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
|||||||
|
|
||||||
##### Installation Instructions
|
##### Installation Instructions
|
||||||
|
|
||||||
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
2. Install prerequisites (type `1` and press enter)
|
2. Install prerequisites (type `1` and press enter)
|
||||||
3. Download the bot (type `2` and press enter)
|
3. Download the bot (type `2` and press enter)
|
||||||
4. Exit the installer in order to set up your `creds.yml`
|
4. Exit the installer in order to set up your `creds.yml`
|
||||||
@@ -49,7 +49,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
|||||||
##### Update Instructions
|
##### Update Instructions
|
||||||
|
|
||||||
1. ⚠ Stop the bot
|
1. ⚠ Stop the bot
|
||||||
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
3. Update the bot (type `2` and press enter)
|
3. Update the bot (type `2` and press enter)
|
||||||
4. Run the bot (type `3` and press enter)
|
4. Run the bot (type `3` and press enter)
|
||||||
5. 🎉
|
5. 🎉
|
||||||
@@ -60,7 +60,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
|||||||
|
|
||||||
##### Installation Instructions
|
##### Installation Instructions
|
||||||
|
|
||||||
1. Download the latest release from <https://gitlab.com/nadeko/nadekobot/-/releases>
|
1. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
||||||
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
||||||
2. Untar it
|
2. Untar it
|
||||||
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
||||||
@@ -84,7 +84,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
|||||||
##### Update Instructions
|
##### Update Instructions
|
||||||
|
|
||||||
1. Stop the bot
|
1. Stop the bot
|
||||||
2. Download the latest release from <https://gitlab.com/nadeko/nadekobot/-/releases>
|
2. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
||||||
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
||||||
3. Untar it
|
3. Untar it
|
||||||
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 2!
|
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 2!
|
||||||
|
@@ -67,7 +67,7 @@ You can still install them manually:
|
|||||||
##### Prerequisites
|
##### Prerequisites
|
||||||
|
|
||||||
**Install these before proceeding or your bot will not work!**
|
**Install these before proceeding or your bot will not work!**
|
||||||
- [.net 7](https://dotnet.microsoft.com/en-us/download) - needed to compile and run the bot
|
- [.net 8](https://dotnet.microsoft.com/en-us/download) - needed to compile and run the bot
|
||||||
- [git](https://git-scm.com/downloads) - needed to clone the repository (you can also download the zip manually and extract it, but this guide assumes you're using git)
|
- [git](https://git-scm.com/downloads) - needed to clone the repository (you can also download the zip manually and extract it, but this guide assumes you're using git)
|
||||||
- [Redis] (OPTIONAL)- to cache things needed by some features and persist through restarts
|
- [Redis] (OPTIONAL)- to cache things needed by some features and persist through restarts
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ You can still install them manually:
|
|||||||
|
|
||||||
Open PowerShell (press windows button on your keyboard and type powershell, it should show up; alternatively, right click the start menu and select Windows PowerShell), and navigate to the location where you want to install the bot (for example `cd ~/Desktop/`)
|
Open PowerShell (press windows button on your keyboard and type powershell, it should show up; alternatively, right click the start menu and select Windows PowerShell), and navigate to the location where you want to install the bot (for example `cd ~/Desktop/`)
|
||||||
|
|
||||||
1. `git clone https://gitlab.com/nadeko/nadekobot -b v5 --depth 1`
|
1. `git clone https://gitlab.com/kwoth/nadekobot -b v5 --depth 1`
|
||||||
2. `cd nadekobot`
|
2. `cd nadekobot`
|
||||||
3. `dotnet publish -c Release -o output/ src/NadekoBot/`
|
3. `dotnet publish -c Release -o output/ src/NadekoBot/`
|
||||||
4. `cd output`
|
4. `cd output`
|
||||||
@@ -93,8 +93,12 @@ Open PowerShell as described above and run the following commands:
|
|||||||
- ⚠️ Make sure you don't have your database, credentials or any other nadekobot folder open in some application, this might prevent some of the steps from executing succesfully
|
- ⚠️ Make sure you don't have your database, credentials or any other nadekobot folder open in some application, this might prevent some of the steps from executing succesfully
|
||||||
2. Navigate to your bot's folder, example:
|
2. Navigate to your bot's folder, example:
|
||||||
- `cd ~/Desktop/nadekobot`
|
- `cd ~/Desktop/nadekobot`
|
||||||
3. Pull the new version
|
3. Pull the new version, and make sure you're on the v5 branch
|
||||||
- `git pull`
|
- *⚠️ the first 3 lines can be omitted if you're already on v5. If you're updating from v4, you must run them*
|
||||||
|
- `git remote set-branches origin '*'`
|
||||||
|
- `git fetch -v --depth=1`
|
||||||
|
- `git checkout v5`
|
||||||
|
- `git pull`
|
||||||
- ⚠️ If this fails, you may want to stash or remove your code changes if you don't know how to resolve merge conflicts
|
- ⚠️ If this fails, you may want to stash or remove your code changes if you don't know how to resolve merge conflicts
|
||||||
4. **Backup** old output in case your data is overwritten
|
4. **Backup** old output in case your data is overwritten
|
||||||
- `cp -r -fo output/ output-old`
|
- `cp -r -fo output/ output-old`
|
||||||
|
@@ -36,6 +36,6 @@ If you're unsure whether something is an issue, ask in our support server first.
|
|||||||
[macos-guide]: ./guides/osx-guide.md
|
[macos-guide]: ./guides/osx-guide.md
|
||||||
[from-source-guide]: ./guides/from-source.md
|
[from-source-guide]: ./guides/from-source.md
|
||||||
[discord-server]: https://discord.nadeko.bot/
|
[discord-server]: https://discord.nadeko.bot/
|
||||||
[gitlab]: https://gitlab.com/nadeko/nadekobot
|
[gitlab]: https://gitlab.com/kwoth/nadekobot
|
||||||
[issues]: https://gitlab.com/nadeko/nadekobot/issues
|
[issues]: https://gitlab.com/kwoth/nadekobot/issues
|
||||||
[donate]: ./donate.md
|
[donate]: ./donate.md
|
||||||
|
@@ -1,14 +1,61 @@
|
|||||||
# Creating A Medusa
|
# Creating A Medusa
|
||||||
|
|
||||||
## Theory
|
## Getting started
|
||||||
|
|
||||||
### Introduction
|
This section will guide you through how to create a simple custom medusa. You can find the entirety of this code hosted [here](https://gitlab.com/nadeko/example_medusa)
|
||||||
|
|
||||||
|
#### Prerequisite
|
||||||
|
- [.net8 sdk](https://dotnet.microsoft.com/en-us/download) installed
|
||||||
|
- Optional: use [vscode](https://code.visualstudio.com/download) to write code
|
||||||
|
|
||||||
|
#### Guide
|
||||||
|
|
||||||
|
- Open your favorite terminal and navigate to a folder where you will keep your project .
|
||||||
|
|
||||||
|
- Create a new folder and move into it
|
||||||
|
- `mkdir example_medusa `
|
||||||
|
- `cd example_medusa`
|
||||||
|
|
||||||
|
- Install nadeko-medusa template
|
||||||
|
- `dotnet new install nadeko-medusa`
|
||||||
|
|
||||||
|
- Make a new Nadeko Medusa project
|
||||||
|
- `dotnet new nadeko-medusa`
|
||||||
|
|
||||||
|
### Build it
|
||||||
|
|
||||||
|
- Build your Medusa into a dll that Nadeko can load. In your terminal, type:
|
||||||
|
- `dotnet publish -o bin/medusae/example_medusa /p:DebugType=embedded`
|
||||||
|
|
||||||
|
- Done. You can now try it out in action.
|
||||||
|
|
||||||
|
### Try it out
|
||||||
|
|
||||||
|
- Copy the `bin/medusae/example_medusa` folder into your NadekoBot's `data/medusae/` folder. (Nadeko version 4.1.0+)
|
||||||
|
|
||||||
|
- Load it with `.meload example_medusa`
|
||||||
|
|
||||||
|
- In the channel your bot can see, run the following commands to try it out
|
||||||
|
- `.hello` and
|
||||||
|
- `.hello @<someone>`
|
||||||
|
|
||||||
|
- Check its information with
|
||||||
|
- `.meinfo example_medusa`
|
||||||
|
|
||||||
|
- Unload it
|
||||||
|
- `.meunload example_medusa`
|
||||||
|
|
||||||
|
- :tada: Congrats! You've just made your first medusa! :tada:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Theory
|
||||||
|
|
||||||
Medusa system allows you to write independent medusae (known as "modules", "cogs" or "plugins" in other software) which you can then load, unload and update at will without restarting the bot.
|
Medusa system allows you to write independent medusae (known as "modules", "cogs" or "plugins" in other software) which you can then load, unload and update at will without restarting the bot.
|
||||||
|
|
||||||
The system itself borrows some design from the current way Nadeko's Modules are written but mostly from never-released `Ayu.Commands` system which was designed to be used for a full Nadeko v3 rewrite.
|
The system itself borrows some design from the current way Nadeko's Modules are written but mostly from never-released `Ayu.Commands` system which was designed to be used for a full Nadeko v3 rewrite.
|
||||||
|
|
||||||
The medusa base classes used for development are open source [here](https://gitlab.com/nadeko/nadekobot/-/tree/v5/src/Nadeko.Medusa) in case you need reference, as there is no generated documentation at the moment.
|
The medusa base classes used for development are open source [here](https://gitlab.com/kwoth/nadekobot/-/tree/v5/src/Nadeko.Medusa) in case you need reference, as there is no generated documentation at the moment.
|
||||||
|
|
||||||
### Term list
|
### Term list
|
||||||
|
|
||||||
@@ -99,9 +146,9 @@ If you don't want any auxiliary files, and you don't want to bother making new .
|
|||||||
|
|
||||||
If you update your response strings .yml file(s) while the medusa is loaded and running, running `.stringsreload` will reload the responses without the need to reload the medusa or restart the bot.
|
If you update your response strings .yml file(s) while the medusa is loaded and running, running `.stringsreload` will reload the responses without the need to reload the medusa or restart the bot.
|
||||||
|
|
||||||
#### Config
|
#### Bot medusa config file
|
||||||
|
|
||||||
- Medusa config is kept in `medusae/medusa.yml` file
|
- Medusa config is kept in `data/medusae/medusa.yml` file in NadekoBot installation folder
|
||||||
- At the moment this config only keeps track of which medusae are currently loaded (they will also be always loaded at startup)
|
- At the moment this config only keeps track of which medusae are currently loaded (they will also be always loaded at startup)
|
||||||
- If a medusa is causing issues and you're unable to unload it, you can remove it from the `loaded:` list in this config file and restart the bot. It won't be loaded next time the bot is started up
|
- If a medusa is causing issues and you're unable to unload it, you can remove it from the `loaded:` list in this config file and restart the bot. It won't be loaded next time the bot is started up
|
||||||
|
|
||||||
@@ -115,138 +162,4 @@ To make sure your medusa can be properly unloaded/reloaded you must:
|
|||||||
|
|
||||||
- If you are still having issues, you can always run `.meunload` followed by a bot restart, or if you want to find what is causing the medusa unloadability issues, you can check the [microsoft's assembly unloadability debugging guide](https://docs.microsoft.com/en-us/dotnet/standard/assembly/unloadability)
|
- If you are still having issues, you can always run `.meunload` followed by a bot restart, or if you want to find what is causing the medusa unloadability issues, you can check the [microsoft's assembly unloadability debugging guide](https://docs.microsoft.com/en-us/dotnet/standard/assembly/unloadability)
|
||||||
|
|
||||||
## Practice
|
|
||||||
|
|
||||||
This section will guide you through how to create a simple custom medusa. You can find the entirety of this code hosted [here](https://gitlab.com/nadeko/example_medusa)
|
|
||||||
|
|
||||||
#### Prerequisite
|
|
||||||
- [.net6 sdk](https://dotnet.microsoft.com/en-us/download) installed
|
|
||||||
- Optional: use [vscode](https://code.visualstudio.com/download) to write code
|
|
||||||
|
|
||||||
#### Guide
|
|
||||||
|
|
||||||
|
|
||||||
- Open your favorite terminal and navigate to a folder where you will keep your project .
|
|
||||||
|
|
||||||
- Create a new folder
|
|
||||||
- `mkdir example_medusa`
|
|
||||||
- Create a new .net class library
|
|
||||||
- `dotnet new classlib`
|
|
||||||
- Open the current folder with your favorite editor/IDE. In this case we'll use VsCode
|
|
||||||
- `code .`
|
|
||||||
- Remove the `Class1.cs` file
|
|
||||||
- Replace the contents of the `.csproj` file with the following contents
|
|
||||||
```xml
|
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
|
|
||||||
<!-- Reduces some boilerplate in your .cs files -->
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
|
|
||||||
<!-- Use latest .net features -->
|
|
||||||
<LangVersion>preview</LangVersion>
|
|
||||||
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
|
||||||
<GenerateRequiresPreviewFeaturesAttribute>true</GenerateRequiresPreviewFeaturesAttribute>
|
|
||||||
|
|
||||||
<!-- tell .net that this library will be used as a plugin -->
|
|
||||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<!-- Base medusa package. You MUST reference this in order to have a working medusa -->
|
|
||||||
<!-- Also, this package comes from MyGet, which requires you to have a NuGet.Config file next to your .csproj -->
|
|
||||||
<PackageReference Include="Nadeko.Medusa" Version="4.3.9">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
</PackageReference>
|
|
||||||
|
|
||||||
<!-- Note: If you want to use NadekoBot services etc... You will have to manually clone
|
|
||||||
the https://gitlab.com/nadeko/nadekobot repo locally and reference the NadekoBot.csproj because there is no NadekoBot package atm.
|
|
||||||
It is strongly recommended that you checkout a specific tag which matches your version of nadeko,
|
|
||||||
as there could be breaking changes even between minor versions of NadekoBot.
|
|
||||||
For example if you're running NadekoBot 4.1.0 locally for which you want to create a medusa for,
|
|
||||||
you should do "git checkout 4.1.0" in your NadekoBot solution and then reference the NadekoBot.csproj
|
|
||||||
-->
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- Copy shortcut and full strings to output (if they exist) -->
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="res.yml;cmds.yml;strings/**">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
```
|
|
||||||
- Create a `MySnek.cs` file and add the following contents
|
|
||||||
```cs
|
|
||||||
using Nadeko.Snake;
|
|
||||||
using NadekoBot;
|
|
||||||
using Discord;
|
|
||||||
|
|
||||||
public sealed class MySnek : Snek
|
|
||||||
{
|
|
||||||
[cmd]
|
|
||||||
public async Task Hello(AnyContext ctx)
|
|
||||||
{
|
|
||||||
await ctx.Channel.SendMessageAsync($"Hello everyone!");
|
|
||||||
}
|
|
||||||
|
|
||||||
[cmd]
|
|
||||||
public async Task Hello(AnyContext ctx, IUser target)
|
|
||||||
{
|
|
||||||
await ctx.ConfirmLocalizedAsync("hello", target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
- Create `res.yml` and `cmds.yml` files with the following contents
|
|
||||||
`res.yml`
|
|
||||||
```yml
|
|
||||||
medusa.description: "This is my medusa's description"
|
|
||||||
hello: "Hello {0}, from res.yml!"
|
|
||||||
```
|
|
||||||
|
|
||||||
`cmds.yml`
|
|
||||||
```yml
|
|
||||||
hello:
|
|
||||||
desc: "This is a basic hello command"
|
|
||||||
args:
|
|
||||||
- ""
|
|
||||||
- "@Someone"
|
|
||||||
```
|
|
||||||
|
|
||||||
- Add `NuGet.Config` file which will let you use the base Nadeko.Medusa package. This file should always look like this and you shouldn't change it
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<configuration>
|
|
||||||
<packageSources>
|
|
||||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
|
||||||
<add key="nadeko.bot" value="https://www.myget.org/F/nadeko/api/v3/index.json" protocolVersion="3" />
|
|
||||||
</packageSources>
|
|
||||||
</configuration>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Build it
|
|
||||||
|
|
||||||
- Build your Medusa into a dll that Nadeko can load. In your terminal, type:
|
|
||||||
- `dotnet publish -o bin/medusae/example_medusa /p:DebugType=embedded`
|
|
||||||
|
|
||||||
- Done. You can now try it out in action.
|
|
||||||
|
|
||||||
### Try it out
|
|
||||||
|
|
||||||
- Copy the `bin/medusae/example_medusa` folder into your NadekoBot's `data/medusae/` folder. (Nadeko version 4.1.0+)
|
|
||||||
|
|
||||||
- Load it with `.meload example_medusa`
|
|
||||||
|
|
||||||
- In the channel your bot can see, run the following commands to try it out
|
|
||||||
- `.hello` and
|
|
||||||
- `.hello @<someone>`
|
|
||||||
|
|
||||||
- Check its information with
|
|
||||||
- `.meinfo example_medusa`
|
|
||||||
|
|
||||||
- Unload it
|
|
||||||
- `.meunload example_medusa`
|
|
||||||
|
|
||||||
- Congrats! You've just made your first medusa!
|
|
||||||
|
@@ -5,6 +5,5 @@ else {
|
|||||||
$migrationName = $args[0]
|
$migrationName = $args[0]
|
||||||
dotnet ef migrations add $migrationName -c SqliteContext -p src/NadekoBot/NadekoBot.csproj
|
dotnet ef migrations add $migrationName -c SqliteContext -p src/NadekoBot/NadekoBot.csproj
|
||||||
dotnet ef migrations add $migrationName -c PostgreSqlContext -p src/NadekoBot/NadekoBot.csproj
|
dotnet ef migrations add $migrationName -c PostgreSqlContext -p src/NadekoBot/NadekoBot.csproj
|
||||||
dotnet ef migrations add $migrationName -c MysqlContext -p src/NadekoBot/NadekoBot.csproj
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
dotnet ef migrations remove -c SqliteContext -f
|
dotnet ef migrations remove -c SqliteContext -f -p src/NadekoBot/NadekoBot.csproj
|
||||||
dotnet ef migrations remove -c PostgreSqlContext -f
|
dotnet ef migrations remove -c PostgreSqlContext -f -p src/NadekoBot/NadekoBot.csproj
|
||||||
dotnet ef migrations remove -c MysqlContext -f
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
using NadekoBot;
|
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
namespace NadekoBot.Medusa;
|
||||||
|
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Discord.Net.Core" Version="3.204.0" />
|
<PackageReference Include="Discord.Net.Core" Version="3.15.3" />
|
||||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||||
<PackageReference Include="YamlDotNet" Version="15.1.2" />
|
<PackageReference Include="YamlDotNet" Version="15.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Version)' == '' ">
|
<PropertyGroup Condition=" '$(Version)' == '' ">
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
<PackageReference Include="YamlDotNet" Version="15.1.2" />
|
<PackageReference Include="YamlDotNet" Version="15.1.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -417,8 +417,7 @@ namespace NadekoBot.Coordinator
|
|||||||
{
|
{
|
||||||
lock (locker)
|
lock (locker)
|
||||||
{
|
{
|
||||||
if (shardId >= _shardStatuses.Length)
|
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(shardId, _shardStatuses.Length);
|
||||||
throw new ArgumentOutOfRangeException(nameof(shardId));
|
|
||||||
|
|
||||||
return _shardStatuses[shardId];
|
return _shardStatuses[shardId];
|
||||||
}
|
}
|
||||||
|
184
src/NadekoBot.Generators/GrpcApiPermGenerator.cs
Normal file
184
src/NadekoBot.Generators/GrpcApiPermGenerator.cs
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
#nullable enable
|
||||||
|
using System.CodeDom.Compiler;
|
||||||
|
using System.Collections.Immutable;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
using Microsoft.CodeAnalysis.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace NadekoBot.Generators
|
||||||
|
{
|
||||||
|
public readonly record struct MethodPermData
|
||||||
|
{
|
||||||
|
public readonly ImmutableArray<(string Name, string Value)> MethodPerms;
|
||||||
|
public readonly ImmutableArray<string> NoAuthRequired;
|
||||||
|
|
||||||
|
public MethodPermData(ImmutableArray<(string Name, string Value)> methodPerms,
|
||||||
|
ImmutableArray<string> noAuthRequired)
|
||||||
|
{
|
||||||
|
MethodPerms = methodPerms;
|
||||||
|
NoAuthRequired = noAuthRequired;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Generator]
|
||||||
|
public class GrpcApiPermGenerator : IIncrementalGenerator
|
||||||
|
{
|
||||||
|
public const string GRPC_API_PERM_ATTRIBUTE =
|
||||||
|
"""
|
||||||
|
namespace NadekoBot.GrpcApi;
|
||||||
|
|
||||||
|
[System.AttributeUsage(System.AttributeTargets.Method)]
|
||||||
|
public class GrpcApiPermAttribute : System.Attribute
|
||||||
|
{
|
||||||
|
public GuildPerm Value { get; }
|
||||||
|
public GrpcApiPermAttribute(GuildPerm value) => Value = value;
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
|
||||||
|
public const string GRPC_NO_AUTH_REQUIRED_ATTRIBUTE =
|
||||||
|
"""
|
||||||
|
namespace NadekoBot.GrpcApi;
|
||||||
|
|
||||||
|
[System.AttributeUsage(System.AttributeTargets.Method)]
|
||||||
|
public class GrpcNoAuthRequiredAttribute : System.Attribute
|
||||||
|
{
|
||||||
|
}
|
||||||
|
""";
|
||||||
|
|
||||||
|
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||||
|
{
|
||||||
|
context.RegisterPostInitializationOutput(ctx => ctx.AddSource("GrpcApiPermAttribute.cs",
|
||||||
|
SourceText.From(GRPC_API_PERM_ATTRIBUTE, Encoding.UTF8)));
|
||||||
|
|
||||||
|
context.RegisterPostInitializationOutput(ctx => ctx.AddSource("GrpcNoAuthRequiredAttribute.cs",
|
||||||
|
SourceText.From(GRPC_NO_AUTH_REQUIRED_ATTRIBUTE, Encoding.UTF8)));
|
||||||
|
|
||||||
|
var perms = context.SyntaxProvider
|
||||||
|
.ForAttributeWithMetadataName(
|
||||||
|
"NadekoBot.GrpcApi.GrpcApiPermAttribute",
|
||||||
|
predicate: static (s, _) => s is MethodDeclarationSyntax,
|
||||||
|
transform: static (ctx, _) => GetMethodSemanticTargets(ctx.SemanticModel, ctx.TargetNode))
|
||||||
|
.Where(static m => m is not null)
|
||||||
|
.Select(static (x, _) => x!.Value)
|
||||||
|
.Collect();
|
||||||
|
|
||||||
|
|
||||||
|
var all = context.SyntaxProvider
|
||||||
|
.ForAttributeWithMetadataName(
|
||||||
|
"NadekoBot.GrpcApi.GrpcNoAuthRequiredAttribute",
|
||||||
|
predicate: static (s, _) => s is MethodDeclarationSyntax,
|
||||||
|
transform: static (ctx, _) => GetNoAuthMethodName(ctx.SemanticModel, ctx.TargetNode))
|
||||||
|
.Collect()
|
||||||
|
.Combine(perms)
|
||||||
|
.Select((x, _) => new MethodPermData(x.Right, x.Left));
|
||||||
|
|
||||||
|
context.RegisterSourceOutput(all,
|
||||||
|
static (spc, source) => Execute(source, spc));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetNoAuthMethodName(SemanticModel model, SyntaxNode node)
|
||||||
|
=> ((MethodDeclarationSyntax)node).Identifier.Text;
|
||||||
|
|
||||||
|
private static (string Name, string Value)? GetMethodSemanticTargets(SemanticModel model, SyntaxNode node)
|
||||||
|
{
|
||||||
|
var method = (MethodDeclarationSyntax)node;
|
||||||
|
|
||||||
|
var name = method.Identifier.Text;
|
||||||
|
var attr = method.AttributeLists
|
||||||
|
.SelectMany(x => x.Attributes)
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
if (attr is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return (name, attr.ArgumentList?.Arguments[0].ToString() ?? "__missing_perm__");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Execute(MethodPermData data, SourceProductionContext ctx)
|
||||||
|
{
|
||||||
|
using (var stringWriter = new StringWriter())
|
||||||
|
using (var sw = new IndentedTextWriter(stringWriter))
|
||||||
|
{
|
||||||
|
sw.WriteLine("using System.Collections.Frozen;");
|
||||||
|
sw.WriteLine();
|
||||||
|
sw.WriteLine("namespace NadekoBot.GrpcApi;");
|
||||||
|
sw.WriteLine();
|
||||||
|
|
||||||
|
sw.WriteLine("public partial class GrpcApiPermsInterceptor");
|
||||||
|
sw.WriteLine("{");
|
||||||
|
|
||||||
|
sw.Indent++;
|
||||||
|
|
||||||
|
sw.WriteLine(
|
||||||
|
"private static FrozenDictionary<string, GuildPerm> _perms = new Dictionary<string, GuildPerm>()");
|
||||||
|
sw.WriteLine("{");
|
||||||
|
|
||||||
|
sw.Indent++;
|
||||||
|
foreach (var field in data.MethodPerms)
|
||||||
|
{
|
||||||
|
sw.WriteLine("{{ \"{0}\", {1} }},", field.Name, field.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
sw.Indent--;
|
||||||
|
sw.WriteLine("}.ToFrozenDictionary();");
|
||||||
|
|
||||||
|
sw.WriteLine();
|
||||||
|
sw.WriteLine("private static FrozenSet<string> _noAuthRequired = new HashSet<string>()");
|
||||||
|
sw.WriteLine("{");
|
||||||
|
|
||||||
|
sw.Indent++;
|
||||||
|
foreach (var noauth in data.NoAuthRequired)
|
||||||
|
{
|
||||||
|
sw.WriteLine("{{ \"{0}\" }},", noauth);
|
||||||
|
}
|
||||||
|
|
||||||
|
sw.WriteLine("");
|
||||||
|
|
||||||
|
sw.Indent--;
|
||||||
|
sw.WriteLine("}.ToFrozenSet();");
|
||||||
|
|
||||||
|
sw.Indent--;
|
||||||
|
sw.WriteLine("}");
|
||||||
|
|
||||||
|
sw.Flush();
|
||||||
|
ctx.AddSource("GrpcApiInterceptor.g.cs", stringWriter.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<TranslationPair> GetFields(string? dataText)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(dataText))
|
||||||
|
return new();
|
||||||
|
|
||||||
|
Dictionary<string, string> data;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var output = JsonConvert.DeserializeObject<Dictionary<string, string>>(dataText!);
|
||||||
|
if (output is null)
|
||||||
|
return new();
|
||||||
|
|
||||||
|
data = output;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Debug.WriteLine("Failed parsing responses file.");
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = new List<TranslationPair>();
|
||||||
|
foreach (var entry in data)
|
||||||
|
{
|
||||||
|
list.Add(new(
|
||||||
|
entry.Key,
|
||||||
|
entry.Value
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -9,7 +9,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" PrivateAssets="all" GeneratePathProperty="true" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" PrivateAssets="all" GeneratePathProperty="true" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
21
src/NadekoBot.GrpcApiBase/NadekoBot.GrpcApiBase.csproj
Normal file
21
src/NadekoBot.GrpcApiBase/NadekoBot.GrpcApiBase.csproj
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Google.Protobuf" Version="3.28.2" />
|
||||||
|
<PackageReference Include="Grpc" Version="2.46.6" />
|
||||||
|
<PackageReference Include="Grpc.Tools" Version="2.66.0" PrivateAssets="All" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Protobuf Include="protos/*.proto">
|
||||||
|
<GrpcServices>Server</GrpcServices>
|
||||||
|
</Protobuf>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
47
src/NadekoBot.GrpcApiBase/protos/canvas.proto
Normal file
47
src/NadekoBot.GrpcApiBase/protos/canvas.proto
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option csharp_namespace = "NadekoBot.GrpcApi";
|
||||||
|
|
||||||
|
import "google/protobuf/empty.proto";
|
||||||
|
|
||||||
|
package ncanvas;
|
||||||
|
|
||||||
|
service GrpcNCanvas {
|
||||||
|
rpc GetCanvas(google.protobuf.Empty) returns (CanvasReply);
|
||||||
|
rpc GetPixel(GetPixelRequest) returns (GetPixelReply);
|
||||||
|
rpc SetPixel(SetPixelRequest) returns (SetPixelReply);
|
||||||
|
}
|
||||||
|
|
||||||
|
message CanvasReply {
|
||||||
|
repeated uint32 pixels = 1;
|
||||||
|
int32 width = 2;
|
||||||
|
int32 height = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetPixelRequest {
|
||||||
|
int32 x = 1;
|
||||||
|
int32 y = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetPixelReply {
|
||||||
|
string color = 1;
|
||||||
|
uint32 packedColor = 2;
|
||||||
|
int32 positionX = 3;
|
||||||
|
int32 positionY = 4;
|
||||||
|
int64 price = 5;
|
||||||
|
string text = 6;
|
||||||
|
string position = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SetPixelRequest {
|
||||||
|
string position = 1;
|
||||||
|
string color = 2;
|
||||||
|
string text = 3;
|
||||||
|
int64 price = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SetPixelReply {
|
||||||
|
string error = 1;
|
||||||
|
bool success = 2;
|
||||||
|
optional GetPixelReply pixel = 3;
|
||||||
|
}
|
89
src/NadekoBot.GrpcApiBase/protos/exprs.proto
Normal file
89
src/NadekoBot.GrpcApiBase/protos/exprs.proto
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option csharp_namespace = "NadekoBot.GrpcApi";
|
||||||
|
|
||||||
|
import "google/protobuf/empty.proto";
|
||||||
|
|
||||||
|
package exprs;
|
||||||
|
|
||||||
|
service GrpcExprs {
|
||||||
|
rpc GetExprs(GetExprsRequest) returns (GetExprsReply);
|
||||||
|
rpc AddExpr(AddExprRequest) returns (AddExprReply);
|
||||||
|
rpc DeleteExpr(DeleteExprRequest) returns (google.protobuf.Empty);
|
||||||
|
|
||||||
|
rpc GetQuotes(GetQuotesRequest) returns (GetQuotesReply);
|
||||||
|
rpc AddQuote(AddQuoteRequest) returns (AddQuoteReply);
|
||||||
|
rpc DeleteQuote(DeleteQuoteRequest) returns (google.protobuf.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteExprRequest {
|
||||||
|
string id = 1;
|
||||||
|
uint64 guildId = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetExprsRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
string query = 2;
|
||||||
|
int32 page = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetExprsReply {
|
||||||
|
repeated ExprDto expressions = 1;
|
||||||
|
int32 totalCount = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ExprDto {
|
||||||
|
string id = 1;
|
||||||
|
string trigger = 2;
|
||||||
|
string response = 3;
|
||||||
|
|
||||||
|
bool ca = 4;
|
||||||
|
bool ad = 5;
|
||||||
|
bool dm = 6;
|
||||||
|
bool at = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddExprRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
ExprDto expr = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddExprReply {
|
||||||
|
string id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetQuotesRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
string query = 2;
|
||||||
|
int32 page = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetQuotesReply {
|
||||||
|
repeated QuoteDto quotes = 1;
|
||||||
|
int32 totalCount = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message QuoteDto {
|
||||||
|
string id = 1;
|
||||||
|
string trigger = 2;
|
||||||
|
string response = 3;
|
||||||
|
|
||||||
|
uint64 authorId = 4;
|
||||||
|
string authorName = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddQuoteRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
QuoteDto quote = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddQuoteReply {
|
||||||
|
string id = 1;
|
||||||
|
bool success = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteQuoteRequest {
|
||||||
|
string id = 1;
|
||||||
|
uint64 guildId = 2;
|
||||||
|
}
|
60
src/NadekoBot.GrpcApiBase/protos/fin.proto
Normal file
60
src/NadekoBot.GrpcApiBase/protos/fin.proto
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option csharp_namespace = "NadekoBot.GrpcApi";
|
||||||
|
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
|
||||||
|
package fin;
|
||||||
|
|
||||||
|
service GrpcFin {
|
||||||
|
rpc GetTransactions(GetTransactionsRequest) returns (GetTransactionsReply);
|
||||||
|
rpc GetHoldings(GetHoldingsRequest) returns (GetHoldingsReply);
|
||||||
|
rpc Withdraw(WithdrawRequest) returns (WithdrawReply);
|
||||||
|
rpc Deposit(DepositRequest) returns (DepositReply);
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTransactionsRequest {
|
||||||
|
int32 page = 1;
|
||||||
|
uint64 userId = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTransactionsReply {
|
||||||
|
repeated TransactionReply transactions = 1;
|
||||||
|
int32 total = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TransactionReply {
|
||||||
|
int64 amount = 1;
|
||||||
|
string note = 2;
|
||||||
|
string type = 3;
|
||||||
|
string extra = 4;
|
||||||
|
google.protobuf.Timestamp timestamp = 5;
|
||||||
|
string id = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetHoldingsRequest {
|
||||||
|
uint64 userId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetHoldingsReply {
|
||||||
|
int64 cash = 1;
|
||||||
|
int64 bank = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WithdrawRequest {
|
||||||
|
uint64 userId = 1;
|
||||||
|
int64 amount = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WithdrawReply {
|
||||||
|
bool success = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DepositRequest {
|
||||||
|
uint64 userId = 1;
|
||||||
|
int64 amount = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DepositReply {
|
||||||
|
bool success = 1;
|
||||||
|
}
|
51
src/NadekoBot.GrpcApiBase/protos/greet.proto
Normal file
51
src/NadekoBot.GrpcApiBase/protos/greet.proto
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option csharp_namespace = "NadekoBot.GrpcApi";
|
||||||
|
|
||||||
|
package greet;
|
||||||
|
|
||||||
|
service GrpcGreet {
|
||||||
|
rpc GetGreetSettings (GetGreetRequest) returns (GrpcGreetSettings);
|
||||||
|
rpc UpdateGreet (UpdateGreetRequest) returns (UpdateGreetReply);
|
||||||
|
rpc TestGreet (TestGreetRequest) returns (TestGreetReply);
|
||||||
|
}
|
||||||
|
|
||||||
|
message GrpcGreetSettings {
|
||||||
|
string channelId = 1;
|
||||||
|
string message = 2;
|
||||||
|
bool isEnabled = 3;
|
||||||
|
GrpcGreetType type = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetGreetRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
GrpcGreetType type = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message UpdateGreetRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
GrpcGreetSettings settings = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum GrpcGreetType {
|
||||||
|
Greet = 0;
|
||||||
|
GreetDm = 1;
|
||||||
|
Bye = 2;
|
||||||
|
Boost = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message UpdateGreetReply {
|
||||||
|
bool Success = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestGreetRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
uint64 channelId = 2;
|
||||||
|
uint64 userId = 3;
|
||||||
|
GrpcGreetType type = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestGreetReply {
|
||||||
|
bool success = 1;
|
||||||
|
string error = 2;
|
||||||
|
}
|
144
src/NadekoBot.GrpcApiBase/protos/other.proto
Normal file
144
src/NadekoBot.GrpcApiBase/protos/other.proto
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option csharp_namespace = "NadekoBot.GrpcApi";
|
||||||
|
|
||||||
|
import "google/protobuf/empty.proto";
|
||||||
|
|
||||||
|
package other;
|
||||||
|
|
||||||
|
service GrpcOther {
|
||||||
|
rpc BotOnGuild(BotOnGuildRequest) returns (BotOnGuildReply);
|
||||||
|
rpc GetTextChannels(GetTextChannelsRequest) returns (GetTextChannelsReply);
|
||||||
|
rpc GetRoles(GetRolesRequest) returns (GetRolesReply);
|
||||||
|
|
||||||
|
rpc GetCurrencyLb(GetLbRequest) returns (CurrencyLbReply);
|
||||||
|
rpc GetXpLb(GetLbRequest) returns (XpLbReply);
|
||||||
|
rpc GetWaifuLb(GetLbRequest) returns (WaifuLbReply);
|
||||||
|
|
||||||
|
rpc GetShardStats(google.protobuf.Empty) returns (stream ShardStatsReply);
|
||||||
|
rpc GetCommandFeed(google.protobuf.Empty) returns (stream CommandFeedEntry);
|
||||||
|
rpc GetServerInfo(ServerInfoRequest) returns (GetServerInfoReply);
|
||||||
|
}
|
||||||
|
|
||||||
|
message CommandFeedEntry {
|
||||||
|
string command = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetRolesRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetRolesReply {
|
||||||
|
repeated RoleReply roles = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message BotOnGuildRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message BotOnGuildReply {
|
||||||
|
bool success = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ShardStatsReply {
|
||||||
|
int32 id = 1;
|
||||||
|
string status = 2;
|
||||||
|
|
||||||
|
int32 guildCount = 3;
|
||||||
|
string uptime = 4;
|
||||||
|
int64 commands = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTextChannelsRequest{
|
||||||
|
uint64 guildId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTextChannelsReply {
|
||||||
|
repeated TextChannelReply textChannels = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TextChannelReply {
|
||||||
|
uint64 id = 1;
|
||||||
|
string name = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CurrencyLbReply {
|
||||||
|
repeated CurrencyLbEntryReply entries = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CurrencyLbEntryReply {
|
||||||
|
string user = 1;
|
||||||
|
uint64 userId = 2;
|
||||||
|
int64 amount = 3;
|
||||||
|
string avatar = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetLbRequest {
|
||||||
|
int32 page = 1;
|
||||||
|
int32 perPage = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message XpLbReply {
|
||||||
|
repeated XpLbEntryReply entries = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message XpLbEntryReply {
|
||||||
|
string user = 1;
|
||||||
|
uint64 userId = 2;
|
||||||
|
int64 totalXp = 3;
|
||||||
|
int64 level = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WaifuLbReply {
|
||||||
|
repeated WaifuLbEntry entries = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WaifuLbEntry {
|
||||||
|
string user = 1;
|
||||||
|
string claimedBy = 2;
|
||||||
|
int64 value = 3;
|
||||||
|
bool isMutual = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ServerInfoRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetServerInfoReply {
|
||||||
|
uint64 id = 1;
|
||||||
|
string name = 2;
|
||||||
|
string iconUrl = 3;
|
||||||
|
uint64 ownerId = 4;
|
||||||
|
string ownerName = 5;
|
||||||
|
repeated RoleReply roles = 6;
|
||||||
|
repeated EmojiReply emojis = 7;
|
||||||
|
repeated string features = 8;
|
||||||
|
int32 textChannels = 9;
|
||||||
|
int32 voiceChannels = 10;
|
||||||
|
int32 memberCount = 11;
|
||||||
|
int64 createdAt = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RoleReply {
|
||||||
|
uint64 id = 1;
|
||||||
|
string name = 2;
|
||||||
|
string iconUrl = 3;
|
||||||
|
string color = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message EmojiReply {
|
||||||
|
string name = 1;
|
||||||
|
string url = 2;
|
||||||
|
string code = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ChannelReply {
|
||||||
|
uint64 id = 1;
|
||||||
|
string name = 2;
|
||||||
|
ChannelType type = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ChannelType {
|
||||||
|
Text = 0;
|
||||||
|
Voice = 1;
|
||||||
|
}
|
107
src/NadekoBot.GrpcApiBase/protos/warn.proto
Normal file
107
src/NadekoBot.GrpcApiBase/protos/warn.proto
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option csharp_namespace = "NadekoBot.GrpcApi";
|
||||||
|
|
||||||
|
package warn;
|
||||||
|
|
||||||
|
service GrpcWarn {
|
||||||
|
rpc GetWarnSettings (WarnSettingsRequest) returns (WarnSettingsReply);
|
||||||
|
|
||||||
|
rpc SetWarnExpiry(SetWarnExpiryRequest) returns (SetWarnExpiryReply);
|
||||||
|
rpc AddWarnp (AddWarnpRequest) returns (AddWarnpReply);
|
||||||
|
rpc DeleteWarnp (DeleteWarnpRequest) returns (DeleteWarnpReply);
|
||||||
|
|
||||||
|
rpc GetLatestWarnings(GetLatestWarningsRequest) returns (GetLatestWarningsReply);
|
||||||
|
rpc GetUserWarnings(GetUserWarningsRequest) returns (GetUserWarningsReply);
|
||||||
|
|
||||||
|
rpc ForgiveWarning(ForgiveWarningRequest) returns (ForgiveWarningReply);
|
||||||
|
rpc DeleteWarning(ForgiveWarningRequest) returns (ForgiveWarningReply);
|
||||||
|
|
||||||
|
}
|
||||||
|
message WarnSettingsRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WarnPunishment {
|
||||||
|
int32 threshold = 1;
|
||||||
|
string action = 2;
|
||||||
|
int32 duration = 3;
|
||||||
|
string role = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message WarnSettingsReply {
|
||||||
|
repeated WarnPunishment punishments = 1;
|
||||||
|
int32 expiryDays = 2;
|
||||||
|
bool deleteOnExpire = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddWarnpRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
WarnPunishment punishment = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddWarnpReply {
|
||||||
|
bool success = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteWarnpRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
int32 threshold = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteWarnpReply {
|
||||||
|
bool success = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserWarningsRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
string user = 2;
|
||||||
|
int32 page = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetUserWarningsReply {
|
||||||
|
repeated Warning warnings = 1;
|
||||||
|
int32 totalCount = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Warning {
|
||||||
|
string id = 1;
|
||||||
|
string reason = 2;
|
||||||
|
int64 timestamp = 3;
|
||||||
|
int64 weight = 4;
|
||||||
|
bool forgiven = 5;
|
||||||
|
string forgivenBy = 6;
|
||||||
|
string user = 7;
|
||||||
|
uint64 userId = 8;
|
||||||
|
string moderator = 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ForgiveWarningRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
string warnId = 2;
|
||||||
|
string modName = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ForgiveWarningReply {
|
||||||
|
bool success = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SetWarnExpiryRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
int32 expiryDays = 2;
|
||||||
|
bool deleteOnExpire = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SetWarnExpiryReply {
|
||||||
|
bool success = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetLatestWarningsRequest {
|
||||||
|
uint64 guildId = 1;
|
||||||
|
int32 page = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetLatestWarningsReply {
|
||||||
|
repeated Warning warnings = 1;
|
||||||
|
int32 totalCount = 2;
|
||||||
|
}
|
@@ -1,76 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Nadeko.Common;
|
|
||||||
using NadekoBot.Services;
|
|
||||||
using NUnit.Framework;
|
|
||||||
|
|
||||||
namespace NadekoBot.Tests
|
|
||||||
{
|
|
||||||
public class GroupGreetTests
|
|
||||||
{
|
|
||||||
private GreetGrouper<int> _grouper;
|
|
||||||
|
|
||||||
[SetUp]
|
|
||||||
public void Setup()
|
|
||||||
=> _grouper = new GreetGrouper<int>();
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void CreateTest()
|
|
||||||
{
|
|
||||||
var created = _grouper.CreateOrAdd(0, 5);
|
|
||||||
|
|
||||||
Assert.True(created);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void CreateClearTest()
|
|
||||||
{
|
|
||||||
_grouper.CreateOrAdd(0, 5);
|
|
||||||
_grouper.ClearGroup(0, 5, out var items);
|
|
||||||
|
|
||||||
Assert.AreEqual(0, items.Count());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void NotCreatedTest()
|
|
||||||
{
|
|
||||||
_grouper.CreateOrAdd(0, 5);
|
|
||||||
var created = _grouper.CreateOrAdd(0, 4);
|
|
||||||
|
|
||||||
Assert.False(created);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void ClearAddedTest()
|
|
||||||
{
|
|
||||||
_grouper.CreateOrAdd(0, 5);
|
|
||||||
_grouper.CreateOrAdd(0, 4);
|
|
||||||
_grouper.ClearGroup(0, 5, out var items);
|
|
||||||
|
|
||||||
var list = items.ToList();
|
|
||||||
|
|
||||||
Assert.AreEqual(1, list.Count, $"Count was {list.Count}");
|
|
||||||
Assert.AreEqual(4, list[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public async Task ClearManyTest()
|
|
||||||
{
|
|
||||||
_grouper.CreateOrAdd(0, 5);
|
|
||||||
|
|
||||||
// add 15 items
|
|
||||||
await Enumerable.Range(10, 15)
|
|
||||||
.Select(x => Task.Run(() => _grouper.CreateOrAdd(0, x))).WhenAll();
|
|
||||||
|
|
||||||
// get 5 at most
|
|
||||||
_grouper.ClearGroup(0, 5, out var items);
|
|
||||||
var list = items.ToList();
|
|
||||||
Assert.AreEqual(5, list.Count, $"Count was {list.Count}");
|
|
||||||
|
|
||||||
// try to get 15, but there should be 10 left
|
|
||||||
_grouper.ClearGroup(0, 15, out items);
|
|
||||||
list = items.ToList();
|
|
||||||
Assert.AreEqual(10, list.Count, $"Count was {list.Count}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -8,7 +8,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
|
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
@@ -77,7 +77,6 @@ csharp_style_var_when_type_is_apparent = true:suggestion
|
|||||||
|
|
||||||
# Expression-bodied members
|
# Expression-bodied members
|
||||||
csharp_style_expression_bodied_accessors = true:suggestion
|
csharp_style_expression_bodied_accessors = true:suggestion
|
||||||
csharp_style_expression_bodied_constructors = when_on_single_line:suggestion
|
|
||||||
csharp_style_expression_bodied_indexers = true:suggestion
|
csharp_style_expression_bodied_indexers = true:suggestion
|
||||||
csharp_style_expression_bodied_lambdas = true:suggestion
|
csharp_style_expression_bodied_lambdas = true:suggestion
|
||||||
csharp_style_expression_bodied_local_functions = true:suggestion
|
csharp_style_expression_bodied_local_functions = true:suggestion
|
||||||
@@ -181,9 +180,9 @@ dotnet_naming_rule.private_readonly_field.symbols = private_readonly_field
|
|||||||
dotnet_naming_rule.private_readonly_field.style = begins_with_underscore
|
dotnet_naming_rule.private_readonly_field.style = begins_with_underscore
|
||||||
dotnet_naming_rule.private_readonly_field.severity = warning
|
dotnet_naming_rule.private_readonly_field.severity = warning
|
||||||
|
|
||||||
dotnet_naming_rule.private_field.symbols = private_field
|
# dotnet_naming_rule.private_field.symbols = private_field
|
||||||
dotnet_naming_rule.private_field.style = camel_case
|
# dotnet_naming_rule.private_field.style = camel_case
|
||||||
dotnet_naming_rule.private_field.severity = warning
|
# dotnet_naming_rule.private_field.severity = warning
|
||||||
|
|
||||||
dotnet_naming_rule.const_fields.symbols = const_fields
|
dotnet_naming_rule.const_fields.symbols = const_fields
|
||||||
dotnet_naming_rule.const_fields.style = all_upper
|
dotnet_naming_rule.const_fields.style = all_upper
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
using DryIoc;
|
using DryIoc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using NadekoBot.Common.Configs;
|
using NadekoBot.Common.Configs;
|
||||||
@@ -24,7 +25,7 @@ public sealed class Bot : IBot
|
|||||||
public bool IsReady { get; private set; }
|
public bool IsReady { get; private set; }
|
||||||
public int ShardId { get; set; }
|
public int ShardId { get; set; }
|
||||||
|
|
||||||
private readonly IBotCredentials _creds;
|
private readonly IBotCreds _creds;
|
||||||
private readonly CommandService _commandService;
|
private readonly CommandService _commandService;
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
|
|
||||||
@@ -41,6 +42,9 @@ public sealed class Bot : IBot
|
|||||||
_credsProvider = new BotCredsProvider(totalShards, credPath);
|
_credsProvider = new BotCredsProvider(totalShards, credPath);
|
||||||
_creds = _credsProvider.GetCreds();
|
_creds = _credsProvider.GetCreds();
|
||||||
|
|
||||||
|
LogSetup.SetupLogger(shardId, _creds);
|
||||||
|
Log.Information("Pid: {ProcessId}", Environment.ProcessId);
|
||||||
|
|
||||||
_db = new NadekoDbService(_credsProvider);
|
_db = new NadekoDbService(_credsProvider);
|
||||||
|
|
||||||
var messageCacheSize =
|
var messageCacheSize =
|
||||||
@@ -80,26 +84,26 @@ public sealed class Bot : IBot
|
|||||||
// _interactionService = new(Client.Rest);
|
// _interactionService = new(Client.Rest);
|
||||||
|
|
||||||
Client.Log += Client_Log;
|
Client.Log += Client_Log;
|
||||||
_loadedAssemblies = new[]
|
_loadedAssemblies =
|
||||||
{
|
[
|
||||||
typeof(Bot).Assembly, // bot
|
typeof(Bot).Assembly // bot
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IReadOnlyList<ulong> GetCurrentGuildIds()
|
public IReadOnlyList<ulong> GetCurrentGuildIds()
|
||||||
=> Client.Guilds.Select(x => x.Id).ToList();
|
=> Client.Guilds.Select(x => x.Id).ToList().AsReadOnly();
|
||||||
|
|
||||||
private void AddServices()
|
private async Task AddServices()
|
||||||
{
|
{
|
||||||
var startingGuildIdList = GetCurrentGuildIds();
|
var startingGuildIdList = GetCurrentGuildIds().ToList();
|
||||||
var sw = Stopwatch.StartNew();
|
var startTime = Stopwatch.GetTimestamp();
|
||||||
var bot = Client.CurrentUser;
|
var bot = Client.CurrentUser;
|
||||||
|
|
||||||
using (var uow = _db.GetDbContext())
|
await using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
|
AllGuildConfigs = await uow.GuildConfigs.GetAllGuildConfigs(startingGuildIdList);
|
||||||
uow.EnsureUserCreated(bot.Id, bot.Username, bot.Discriminator, bot.AvatarId);
|
uow.EnsureUserCreated(bot.Id, bot.Username, bot.Discriminator, bot.AvatarId);
|
||||||
AllGuildConfigs = uow.Set<GuildConfig>().GetAllGuildConfigs(startingGuildIdList).ToImmutableArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// var svcs = new StandardKernel(new NinjectSettings()
|
// var svcs = new StandardKernel(new NinjectSettings()
|
||||||
@@ -109,12 +113,12 @@ public sealed class Bot : IBot
|
|||||||
// });
|
// });
|
||||||
|
|
||||||
var svcs = new Container();
|
var svcs = new Container();
|
||||||
|
|
||||||
// this is required in order for medusa unloading to work
|
// this is required in order for medusa unloading to work
|
||||||
// svcs.Components.Remove<IPlanner, Planner>();
|
// svcs.Components.Remove<IPlanner, Planner>();
|
||||||
// svcs.Components.Add<IPlanner, RemovablePlanner>();
|
// svcs.Components.Add<IPlanner, RemovablePlanner>();
|
||||||
|
|
||||||
svcs.AddSingleton<IBotCredentials, IBotCredentials>(_ => _credsProvider.GetCreds());
|
svcs.AddSingleton<IBotCreds>(_ => _credsProvider.GetCreds());
|
||||||
svcs.AddSingleton<DbService, DbService>(_db);
|
svcs.AddSingleton<DbService, DbService>(_db);
|
||||||
svcs.AddSingleton<IBotCredsProvider>(_credsProvider);
|
svcs.AddSingleton<IBotCredsProvider>(_credsProvider);
|
||||||
svcs.AddSingleton<DiscordSocketClient>(Client);
|
svcs.AddSingleton<DiscordSocketClient>(Client);
|
||||||
@@ -161,8 +165,8 @@ public sealed class Bot : IBot
|
|||||||
LoadTypeReaders(a);
|
LoadTypeReaders(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.Stop();
|
Log.Information("All services loaded in {ServiceLoadTime:F2}s",
|
||||||
Log.Information("All services loaded in {ServiceLoadTime:F2}s", sw.Elapsed.TotalSeconds);
|
Stopwatch.GetElapsedTime(startTime).TotalSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadTypeReaders(Assembly assembly)
|
private void LoadTypeReaders(Assembly assembly)
|
||||||
@@ -259,14 +263,14 @@ public sealed class Bot : IBot
|
|||||||
if (ShardId == 0)
|
if (ShardId == 0)
|
||||||
await _db.SetupAsync();
|
await _db.SetupAsync();
|
||||||
|
|
||||||
var sw = Stopwatch.StartNew();
|
var startTime = Stopwatch.GetTimestamp();
|
||||||
|
|
||||||
await LoginAsync(_creds.Token);
|
await LoginAsync(_creds.Token);
|
||||||
|
|
||||||
Log.Information("Shard {ShardId} loading services...", Client.ShardId);
|
Log.Information("Shard {ShardId} loading services...", Client.ShardId);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AddServices();
|
await AddServices();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -274,8 +278,9 @@ public sealed class Bot : IBot
|
|||||||
Helpers.ReadErrorAndExit(9);
|
Helpers.ReadErrorAndExit(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.Stop();
|
Log.Information("Shard {ShardId} connected in {Elapsed:F2}s",
|
||||||
Log.Information("Shard {ShardId} connected in {Elapsed:F2}s", Client.ShardId, sw.Elapsed.TotalSeconds);
|
Client.ShardId,
|
||||||
|
Stopwatch.GetElapsedTime(startTime).TotalSeconds);
|
||||||
var commandHandler = Services.GetRequiredService<CommandHandler>();
|
var commandHandler = Services.GetRequiredService<CommandHandler>();
|
||||||
|
|
||||||
// start handling messages received in commandhandler
|
// start handling messages received in commandhandler
|
||||||
@@ -340,26 +345,26 @@ public sealed class Bot : IBot
|
|||||||
if (arg.Exception is { InnerException: WebSocketClosedException { CloseCode: 4014 } })
|
if (arg.Exception is { InnerException: WebSocketClosedException { CloseCode: 4014 } })
|
||||||
{
|
{
|
||||||
Log.Error("""
|
Log.Error("""
|
||||||
Login failed.
|
Login failed.
|
||||||
|
|
||||||
*** Please enable privileged intents ***
|
*** Please enable privileged intents ***
|
||||||
|
|
||||||
Certain Nadeko features require Discord's privileged gateway intents.
|
Certain Nadeko features require Discord's privileged gateway intents.
|
||||||
These include greeting and goodbye messages, as well as creating the Owner message channels for DM forwarding.
|
These include greeting and goodbye messages, as well as creating the Owner message channels for DM forwarding.
|
||||||
|
|
||||||
How to enable privileged intents:
|
How to enable privileged intents:
|
||||||
1. Head over to the Discord Developer Portal https://discord.com/developers/applications/
|
1. Head over to the Discord Developer Portal https://discord.com/developers/applications/
|
||||||
2. Select your Application.
|
2. Select your Application.
|
||||||
3. Click on `Bot` in the left side navigation panel, and scroll down to the intents section.
|
3. Click on `Bot` in the left side navigation panel, and scroll down to the intents section.
|
||||||
4. Enable all intents.
|
4. Enable all intents.
|
||||||
5. Restart your bot.
|
5. Restart your bot.
|
||||||
|
|
||||||
Read this only if your bot is in 100 or more servers:
|
Read this only if your bot is in 100 or more servers:
|
||||||
|
|
||||||
You'll need to apply to use the intents with Discord, but for small selfhosts, all that is required is enabling the intents in the developer portal.
|
You'll need to apply to use the intents with Discord, but for small selfhosts, all that is required is enabling the intents in the developer portal.
|
||||||
Yes, this is a new thing from Discord, as of October 2020. No, there's nothing we can do about it. Yes, we're aware it worked before.
|
Yes, this is a new thing from Discord, as of October 2020. No, there's nothing we can do about it. Yes, we're aware it worked before.
|
||||||
While waiting for your bot to be accepted, you can change the 'usePrivilegedIntents' inside your creds.yml to 'false', although this will break many of the nadeko's features
|
While waiting for your bot to be accepted, you can change the 'usePrivilegedIntents' inside your creds.yml to 'false', although this will break many of the nadeko's features
|
||||||
""");
|
""");
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,48 +20,48 @@ public static class DiscordUserExtensions
|
|||||||
string discrim,
|
string discrim,
|
||||||
string avatarId)
|
string avatarId)
|
||||||
=> ctx.GetTable<DiscordUser>()
|
=> ctx.GetTable<DiscordUser>()
|
||||||
.InsertOrUpdate(
|
.InsertOrUpdate(
|
||||||
() => new()
|
() => new()
|
||||||
{
|
{
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
Username = username,
|
Username = username,
|
||||||
Discriminator = discrim,
|
Discriminator = discrim,
|
||||||
AvatarId = avatarId,
|
AvatarId = avatarId,
|
||||||
TotalXp = 0,
|
TotalXp = 0,
|
||||||
CurrencyAmount = 0
|
CurrencyAmount = 0
|
||||||
},
|
},
|
||||||
old => new()
|
old => new()
|
||||||
{
|
{
|
||||||
Username = username,
|
Username = username,
|
||||||
Discriminator = discrim,
|
Discriminator = discrim,
|
||||||
AvatarId = avatarId
|
AvatarId = avatarId
|
||||||
},
|
},
|
||||||
() => new()
|
() => new()
|
||||||
{
|
{
|
||||||
UserId = userId
|
UserId = userId
|
||||||
});
|
});
|
||||||
|
|
||||||
public static Task EnsureUserCreatedAsync(
|
public static Task EnsureUserCreatedAsync(
|
||||||
this DbContext ctx,
|
this DbContext ctx,
|
||||||
ulong userId)
|
ulong userId)
|
||||||
=> ctx.GetTable<DiscordUser>()
|
=> ctx.GetTable<DiscordUser>()
|
||||||
.InsertOrUpdateAsync(
|
.InsertOrUpdateAsync(
|
||||||
() => new()
|
() => new()
|
||||||
{
|
{
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
Username = "Unknown",
|
Username = "Unknown",
|
||||||
Discriminator = "????",
|
Discriminator = "????",
|
||||||
AvatarId = string.Empty,
|
AvatarId = string.Empty,
|
||||||
TotalXp = 0,
|
TotalXp = 0,
|
||||||
CurrencyAmount = 0
|
CurrencyAmount = 0
|
||||||
},
|
},
|
||||||
old => new()
|
old => new()
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
() => new()
|
() => new()
|
||||||
{
|
{
|
||||||
UserId = userId
|
UserId = userId
|
||||||
});
|
});
|
||||||
|
|
||||||
//temp is only used in updatecurrencystate, so that i don't overwrite real usernames/discrims with Unknown
|
//temp is only used in updatecurrencystate, so that i don't overwrite real usernames/discrims with Unknown
|
||||||
public static DiscordUser GetOrCreateUser(
|
public static DiscordUser GetOrCreateUser(
|
||||||
@@ -83,25 +83,22 @@ public static class DiscordUserExtensions
|
|||||||
|
|
||||||
public static int GetUserGlobalRank(this DbSet<DiscordUser> users, ulong id)
|
public static int GetUserGlobalRank(this DbSet<DiscordUser> users, ulong id)
|
||||||
=> users.AsQueryable()
|
=> users.AsQueryable()
|
||||||
.Where(x => x.TotalXp
|
.Where(x => x.TotalXp
|
||||||
> users.AsQueryable().Where(y => y.UserId == id).Select(y => y.TotalXp).FirstOrDefault())
|
> users.AsQueryable().Where(y => y.UserId == id).Select(y => y.TotalXp).FirstOrDefault())
|
||||||
.Count()
|
.Count()
|
||||||
+ 1;
|
+ 1;
|
||||||
|
|
||||||
public static DiscordUser[] GetUsersXpLeaderboardFor(this DbSet<DiscordUser> users, int page, int perPage)
|
|
||||||
=> users.AsQueryable().OrderByDescending(x => x.TotalXp).Skip(page * perPage).Take(perPage).AsEnumerable()
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
public static Task<List<DiscordUser>> GetTopRichest(
|
public static Task<List<DiscordUser>> GetTopRichest(
|
||||||
this DbSet<DiscordUser> users,
|
this DbSet<DiscordUser> users,
|
||||||
ulong botId,
|
ulong botId,
|
||||||
int page = 0, int perPage = 9)
|
int page = 0,
|
||||||
|
int perPage = 9)
|
||||||
=> users.AsQueryable()
|
=> users.AsQueryable()
|
||||||
.Where(c => c.CurrencyAmount > 0 && botId != c.UserId)
|
.Where(c => c.CurrencyAmount > 0 && botId != c.UserId)
|
||||||
.OrderByDescending(c => c.CurrencyAmount)
|
.OrderByDescending(c => c.CurrencyAmount)
|
||||||
.Skip(page * perPage)
|
.Skip(page * perPage)
|
||||||
.Take(perPage)
|
.Take(perPage)
|
||||||
.ToListAsyncLinqToDB();
|
.ToListAsyncLinqToDB();
|
||||||
|
|
||||||
public static async Task<long> GetUserCurrencyAsync(this DbSet<DiscordUser> users, ulong userId)
|
public static async Task<long> GetUserCurrencyAsync(this DbSet<DiscordUser> users, ulong userId)
|
||||||
=> (await users.FirstOrDefaultAsyncLinqToDB(x => x.UserId == userId))?.CurrencyAmount ?? 0;
|
=> (await users.FirstOrDefaultAsyncLinqToDB(x => x.UserId == userId))?.CurrencyAmount ?? 0;
|
||||||
@@ -118,8 +115,8 @@ public static class DiscordUserExtensions
|
|||||||
|
|
||||||
public static decimal GetTopOnePercentCurrency(this DbSet<DiscordUser> users, ulong botId)
|
public static decimal GetTopOnePercentCurrency(this DbSet<DiscordUser> users, ulong botId)
|
||||||
=> users.AsQueryable()
|
=> users.AsQueryable()
|
||||||
.Where(x => x.UserId != botId)
|
.Where(x => x.UserId != botId)
|
||||||
.OrderByDescending(x => x.CurrencyAmount)
|
.OrderByDescending(x => x.CurrencyAmount)
|
||||||
.Take(users.Count() / 100 == 0 ? 1 : users.Count() / 100)
|
.Take(users.Count() / 100 == 0 ? 1 : users.Count() / 100)
|
||||||
.Sum(x => x.CurrencyAmount);
|
.Sum(x => x.CurrencyAmount);
|
||||||
}
|
}
|
@@ -1,4 +1,5 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
using LinqToDB.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using NadekoBot.Db.Models;
|
using NadekoBot.Db.Models;
|
||||||
|
|
||||||
@@ -7,19 +8,20 @@ namespace NadekoBot.Db;
|
|||||||
public static class GuildConfigExtensions
|
public static class GuildConfigExtensions
|
||||||
{
|
{
|
||||||
private static List<WarningPunishment> DefaultWarnPunishments
|
private static List<WarningPunishment> DefaultWarnPunishments
|
||||||
=> new()
|
=>
|
||||||
{
|
[
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Count = 3,
|
Count = 3,
|
||||||
Punishment = PunishmentAction.Kick
|
Punishment = PunishmentAction.Kick
|
||||||
},
|
},
|
||||||
|
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Count = 5,
|
Count = 5,
|
||||||
Punishment = PunishmentAction.Ban
|
Punishment = PunishmentAction.Ban
|
||||||
}
|
}
|
||||||
};
|
];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets full stream role settings for the guild with the specified id.
|
/// Gets full stream role settings for the guild with the specified id.
|
||||||
@@ -31,8 +33,8 @@ public static class GuildConfigExtensions
|
|||||||
{
|
{
|
||||||
var conf = ctx.GuildConfigsForId(guildId,
|
var conf = ctx.GuildConfigsForId(guildId,
|
||||||
set => set.Include(y => y.StreamRole)
|
set => set.Include(y => y.StreamRole)
|
||||||
.Include(y => y.StreamRole.Whitelist)
|
.Include(y => y.StreamRole.Whitelist)
|
||||||
.Include(y => y.StreamRole.Blacklist));
|
.Include(y => y.StreamRole.Blacklist));
|
||||||
|
|
||||||
if (conf.StreamRole is null)
|
if (conf.StreamRole is null)
|
||||||
conf.StreamRole = new();
|
conf.StreamRole = new();
|
||||||
@@ -41,19 +43,27 @@ public static class GuildConfigExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static IQueryable<GuildConfig> IncludeEverything(this DbSet<GuildConfig> configs)
|
private static IQueryable<GuildConfig> IncludeEverything(this DbSet<GuildConfig> configs)
|
||||||
=> configs.AsQueryable()
|
=> configs
|
||||||
.AsSplitQuery()
|
.AsSplitQuery()
|
||||||
.Include(gc => gc.CommandCooldowns)
|
.Include(gc => gc.CommandCooldowns)
|
||||||
.Include(gc => gc.FollowedStreams)
|
.Include(gc => gc.FollowedStreams)
|
||||||
.Include(gc => gc.StreamRole)
|
.Include(gc => gc.StreamRole)
|
||||||
.Include(gc => gc.XpSettings)
|
.Include(gc => gc.DelMsgOnCmdChannels)
|
||||||
.ThenInclude(x => x.ExclusionList)
|
.Include(gc => gc.XpSettings)
|
||||||
.Include(gc => gc.DelMsgOnCmdChannels);
|
.ThenInclude(x => x.ExclusionList);
|
||||||
|
|
||||||
public static IEnumerable<GuildConfig> GetAllGuildConfigs(
|
public static async Task<GuildConfig[]> GetAllGuildConfigs(
|
||||||
this DbSet<GuildConfig> configs,
|
this DbSet<GuildConfig> configs,
|
||||||
IReadOnlyList<ulong> availableGuilds)
|
List<ulong> availableGuilds)
|
||||||
=> configs.IncludeEverything().AsNoTracking().Where(x => availableGuilds.Contains(x.GuildId)).ToList();
|
{
|
||||||
|
var result = await configs
|
||||||
|
.IncludeEverything()
|
||||||
|
.Where(x => availableGuilds.Contains(x.GuildId))
|
||||||
|
.AsNoTracking()
|
||||||
|
.ToArrayAsync();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets and creates if it doesn't exist a config for a guild.
|
/// Gets and creates if it doesn't exist a config for a guild.
|
||||||
@@ -79,20 +89,19 @@ public static class GuildConfigExtensions
|
|||||||
|
|
||||||
if (config is null)
|
if (config is null)
|
||||||
{
|
{
|
||||||
ctx.Set<GuildConfig>().Add(config = new()
|
ctx.Set<GuildConfig>()
|
||||||
{
|
.Add(config = new()
|
||||||
GuildId = guildId,
|
{
|
||||||
Permissions = Permissionv2.GetDefaultPermlist,
|
GuildId = guildId,
|
||||||
WarningsInitialized = true,
|
Permissions = Permissionv2.GetDefaultPermlist,
|
||||||
WarnPunishments = DefaultWarnPunishments
|
WarningsInitialized = true,
|
||||||
});
|
});
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.WarningsInitialized)
|
if (!config.WarningsInitialized)
|
||||||
{
|
{
|
||||||
config.WarningsInitialized = true;
|
config.WarningsInitialized = true;
|
||||||
config.WarnPunishments = DefaultWarnPunishments;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
@@ -121,18 +130,18 @@ public static class GuildConfigExtensions
|
|||||||
public static LogSetting LogSettingsFor(this DbContext ctx, ulong guildId)
|
public static LogSetting LogSettingsFor(this DbContext ctx, ulong guildId)
|
||||||
{
|
{
|
||||||
var logSetting = ctx.Set<LogSetting>()
|
var logSetting = ctx.Set<LogSetting>()
|
||||||
.AsQueryable()
|
.AsQueryable()
|
||||||
.Include(x => x.LogIgnores)
|
.Include(x => x.LogIgnores)
|
||||||
.Where(x => x.GuildId == guildId)
|
.Where(x => x.GuildId == guildId)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (logSetting is null)
|
if (logSetting is null)
|
||||||
{
|
{
|
||||||
ctx.Set<LogSetting>()
|
ctx.Set<LogSetting>()
|
||||||
.Add(logSetting = new()
|
.Add(logSetting = new()
|
||||||
{
|
{
|
||||||
GuildId = guildId
|
GuildId = guildId
|
||||||
});
|
});
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,18 +157,20 @@ public static class GuildConfigExtensions
|
|||||||
|
|
||||||
public static GuildConfig GcWithPermissionsFor(this DbContext ctx, ulong guildId)
|
public static GuildConfig GcWithPermissionsFor(this DbContext ctx, ulong guildId)
|
||||||
{
|
{
|
||||||
var config = ctx.Set<GuildConfig>().AsQueryable()
|
var config = ctx.Set<GuildConfig>()
|
||||||
.Where(gc => gc.GuildId == guildId)
|
.AsQueryable()
|
||||||
.Include(gc => gc.Permissions)
|
.Where(gc => gc.GuildId == guildId)
|
||||||
.FirstOrDefault();
|
.Include(gc => gc.Permissions)
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (config is null) // if there is no guildconfig, create new one
|
if (config is null) // if there is no guildconfig, create new one
|
||||||
{
|
{
|
||||||
ctx.Set<GuildConfig>().Add(config = new()
|
ctx.Set<GuildConfig>()
|
||||||
{
|
.Add(config = new()
|
||||||
GuildId = guildId,
|
{
|
||||||
Permissions = Permissionv2.GetDefaultPermlist
|
GuildId = guildId,
|
||||||
});
|
Permissions = Permissionv2.GetDefaultPermlist
|
||||||
|
});
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
}
|
}
|
||||||
else if (config.Permissions is null || !config.Permissions.Any()) // if no perms, add default ones
|
else if (config.Permissions is null || !config.Permissions.Any()) // if no perms, add default ones
|
||||||
@@ -176,30 +187,21 @@ public static class GuildConfigExtensions
|
|||||||
|
|
||||||
public static IEnumerable<FollowedStream> GetFollowedStreams(this DbSet<GuildConfig> configs, List<ulong> included)
|
public static IEnumerable<FollowedStream> GetFollowedStreams(this DbSet<GuildConfig> configs, List<ulong> included)
|
||||||
=> configs.AsQueryable()
|
=> configs.AsQueryable()
|
||||||
.Where(gc => included.Contains(gc.GuildId))
|
.Where(gc => included.Contains(gc.GuildId))
|
||||||
.Include(gc => gc.FollowedStreams)
|
.Include(gc => gc.FollowedStreams)
|
||||||
.SelectMany(gc => gc.FollowedStreams)
|
.SelectMany(gc => gc.FollowedStreams)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
public static void SetCleverbotEnabled(this DbSet<GuildConfig> configs, ulong id, bool cleverbotEnabled)
|
|
||||||
{
|
|
||||||
var conf = configs.FirstOrDefault(gc => gc.GuildId == id);
|
|
||||||
|
|
||||||
if (conf is null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
conf.CleverbotEnabled = cleverbotEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static XpSettings XpSettingsFor(this DbContext ctx, ulong guildId)
|
public static XpSettings XpSettingsFor(this DbContext ctx, ulong guildId)
|
||||||
{
|
{
|
||||||
var gc = ctx.GuildConfigsForId(guildId,
|
var gc = ctx.GuildConfigsForId(guildId,
|
||||||
set => set.Include(x => x.XpSettings)
|
set => set.Include(x => x.XpSettings)
|
||||||
.ThenInclude(x => x.RoleRewards)
|
.ThenInclude(x => x.RoleRewards)
|
||||||
.Include(x => x.XpSettings)
|
.Include(x => x.XpSettings)
|
||||||
.ThenInclude(x => x.CurrencyRewards)
|
.ThenInclude(x => x.CurrencyRewards)
|
||||||
.Include(x => x.XpSettings)
|
.Include(x => x.XpSettings)
|
||||||
.ThenInclude(x => x.ExclusionList));
|
.ThenInclude(x => x.ExclusionList));
|
||||||
|
|
||||||
if (gc.XpSettings is null)
|
if (gc.XpSettings is null)
|
||||||
gc.XpSettings = new();
|
gc.XpSettings = new();
|
||||||
@@ -209,15 +211,15 @@ public static class GuildConfigExtensions
|
|||||||
|
|
||||||
public static IEnumerable<GeneratingChannel> GetGeneratingChannels(this DbSet<GuildConfig> configs)
|
public static IEnumerable<GeneratingChannel> GetGeneratingChannels(this DbSet<GuildConfig> configs)
|
||||||
=> configs.AsQueryable()
|
=> configs.AsQueryable()
|
||||||
.Include(x => x.GenerateCurrencyChannelIds)
|
.Include(x => x.GenerateCurrencyChannelIds)
|
||||||
.Where(x => x.GenerateCurrencyChannelIds.Any())
|
.Where(x => x.GenerateCurrencyChannelIds.Any())
|
||||||
.SelectMany(x => x.GenerateCurrencyChannelIds)
|
.SelectMany(x => x.GenerateCurrencyChannelIds)
|
||||||
.Select(x => new GeneratingChannel
|
.Select(x => new GeneratingChannel
|
||||||
{
|
{
|
||||||
ChannelId = x.ChannelId,
|
ChannelId = x.ChannelId,
|
||||||
GuildId = x.GuildConfig.GuildId
|
GuildId = x.GuildConfig.GuildId
|
||||||
})
|
})
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
public class GeneratingChannel
|
public class GeneratingChannel
|
||||||
{
|
{
|
||||||
|
@@ -1,53 +0,0 @@
|
|||||||
#nullable disable
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using NadekoBot.Db.Models;
|
|
||||||
|
|
||||||
namespace NadekoBot.Db;
|
|
||||||
|
|
||||||
public static class QuoteExtensions
|
|
||||||
{
|
|
||||||
public static IEnumerable<Quote> GetForGuild(this DbSet<Quote> quotes, ulong guildId)
|
|
||||||
=> quotes.AsQueryable().Where(x => x.GuildId == guildId);
|
|
||||||
|
|
||||||
public static IReadOnlyCollection<Quote> GetGroup(
|
|
||||||
this DbSet<Quote> quotes,
|
|
||||||
ulong guildId,
|
|
||||||
int page,
|
|
||||||
OrderType order)
|
|
||||||
{
|
|
||||||
var q = quotes.AsQueryable().Where(x => x.GuildId == guildId);
|
|
||||||
if (order == OrderType.Keyword)
|
|
||||||
q = q.OrderBy(x => x.Keyword);
|
|
||||||
else
|
|
||||||
q = q.OrderBy(x => x.Id);
|
|
||||||
|
|
||||||
return q.Skip(15 * page).Take(15).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task<Quote> GetRandomQuoteByKeywordAsync(
|
|
||||||
this DbSet<Quote> quotes,
|
|
||||||
ulong guildId,
|
|
||||||
string keyword)
|
|
||||||
{
|
|
||||||
return (await quotes.AsQueryable().Where(q => q.GuildId == guildId && q.Keyword == keyword).ToArrayAsync())
|
|
||||||
.RandomOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task<Quote> SearchQuoteKeywordTextAsync(
|
|
||||||
this DbSet<Quote> quotes,
|
|
||||||
ulong guildId,
|
|
||||||
string keyword,
|
|
||||||
string text)
|
|
||||||
{
|
|
||||||
return (await quotes.AsQueryable()
|
|
||||||
.Where(q => q.GuildId == guildId
|
|
||||||
&& (keyword == null || q.Keyword == keyword)
|
|
||||||
&& (EF.Functions.Like(q.Text.ToUpper(), $"%{text.ToUpper()}%")
|
|
||||||
|| EF.Functions.Like(q.AuthorName, text)))
|
|
||||||
.ToArrayAsync())
|
|
||||||
.RandomOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void RemoveAllByKeyword(this DbSet<Quote> quotes, ulong guildId, string keyword)
|
|
||||||
=> quotes.RemoveRange(quotes.AsQueryable().Where(x => x.GuildId == guildId && x.Keyword.ToUpper() == keyword));
|
|
||||||
}
|
|
@@ -2,7 +2,6 @@
|
|||||||
using LinqToDB;
|
using LinqToDB;
|
||||||
using LinqToDB.EntityFrameworkCore;
|
using LinqToDB.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
using NadekoBot.Db.Models;
|
using NadekoBot.Db.Models;
|
||||||
|
|
||||||
namespace NadekoBot.Db;
|
namespace NadekoBot.Db;
|
||||||
@@ -27,33 +26,22 @@ public static class UserXpExtensions
|
|||||||
return usr;
|
return usr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<UserXpStats> GetUsersFor(this DbSet<UserXpStats> xps, ulong guildId, int page)
|
public static async Task<List<UserXpStats>> GetTopUserXps(this DbSet<UserXpStats> xps, ulong guildId, int count)
|
||||||
=> xps.AsQueryable()
|
=> await xps.ToLinqToDBTable()
|
||||||
.AsNoTracking()
|
.Where(x => x.GuildId == guildId)
|
||||||
.Where(x => x.GuildId == guildId)
|
.OrderByDescending(x => x.Xp + x.AwardedXp)
|
||||||
.OrderByDescending(x => x.Xp + x.AwardedXp)
|
.Take(count)
|
||||||
.Skip(page * 9)
|
.ToListAsyncLinqToDB();
|
||||||
.Take(9)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
public static List<UserXpStats> GetTopUserXps(this DbSet<UserXpStats> xps, ulong guildId, int count)
|
public static async Task<int> GetUserGuildRanking(this DbSet<UserXpStats> xps, ulong userId, ulong guildId)
|
||||||
=> xps.AsQueryable()
|
=> await xps.ToLinqToDBTable()
|
||||||
.AsNoTracking()
|
.Where(x => x.GuildId == guildId
|
||||||
.Where(x => x.GuildId == guildId)
|
&& x.Xp + x.AwardedXp
|
||||||
.OrderByDescending(x => x.Xp + x.AwardedXp)
|
> xps.AsQueryable()
|
||||||
.Take(count)
|
.Where(y => y.UserId == userId && y.GuildId == guildId)
|
||||||
.ToList();
|
.Select(y => y.Xp + y.AwardedXp)
|
||||||
|
.FirstOrDefault())
|
||||||
public static int GetUserGuildRanking(this DbSet<UserXpStats> xps, ulong userId, ulong guildId)
|
.CountAsyncLinqToDB()
|
||||||
=> xps.AsQueryable()
|
|
||||||
.AsNoTracking()
|
|
||||||
.Where(x => x.GuildId == guildId
|
|
||||||
&& x.Xp + x.AwardedXp
|
|
||||||
> xps.AsQueryable()
|
|
||||||
.Where(y => y.UserId == userId && y.GuildId == guildId)
|
|
||||||
.Select(y => y.Xp + y.AwardedXp)
|
|
||||||
.FirstOrDefault())
|
|
||||||
.Count()
|
|
||||||
+ 1;
|
+ 1;
|
||||||
|
|
||||||
public static void ResetGuildUserXp(this DbSet<UserXpStats> xps, ulong userId, ulong guildId)
|
public static void ResetGuildUserXp(this DbSet<UserXpStats> xps, ulong userId, ulong guildId)
|
||||||
@@ -61,12 +49,11 @@ public static class UserXpExtensions
|
|||||||
|
|
||||||
public static void ResetGuildXp(this DbSet<UserXpStats> xps, ulong guildId)
|
public static void ResetGuildXp(this DbSet<UserXpStats> xps, ulong guildId)
|
||||||
=> xps.Delete(x => x.GuildId == guildId);
|
=> xps.Delete(x => x.GuildId == guildId);
|
||||||
|
|
||||||
public static async Task<LevelStats> GetLevelDataFor(this ITable<UserXpStats> userXp, ulong guildId, ulong userId)
|
public static async Task<LevelStats> GetLevelDataFor(this ITable<UserXpStats> userXp, ulong guildId, ulong userId)
|
||||||
=> await userXp
|
=> await userXp
|
||||||
.Where(x => x.GuildId == guildId && x.UserId == userId)
|
.Where(x => x.GuildId == guildId && x.UserId == userId)
|
||||||
.FirstOrDefaultAsyncLinqToDB() is UserXpStats uxs
|
.FirstOrDefaultAsyncLinqToDB() is UserXpStats uxs
|
||||||
? new(uxs.Xp + uxs.AwardedXp)
|
? new(uxs.Xp + uxs.AwardedXp)
|
||||||
: new(0);
|
: new(0);
|
||||||
|
|
||||||
}
|
}
|
@@ -22,8 +22,7 @@ public static class WarningExtensions
|
|||||||
string mod,
|
string mod,
|
||||||
int index)
|
int index)
|
||||||
{
|
{
|
||||||
if (index < 0)
|
ArgumentOutOfRangeException.ThrowIfNegative(index);
|
||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
|
||||||
|
|
||||||
var warn = warnings.AsQueryable()
|
var warn = warnings.AsQueryable()
|
||||||
.Where(x => x.GuildId == guildId && x.UserId == userId)
|
.Where(x => x.GuildId == guildId && x.UserId == userId)
|
||||||
|
@@ -3,6 +3,8 @@ namespace NadekoBot.Db.Models;
|
|||||||
|
|
||||||
public class DelMsgOnCmdChannel : DbEntity
|
public class DelMsgOnCmdChannel : DbEntity
|
||||||
{
|
{
|
||||||
|
public int GuildConfigId { get; set; }
|
||||||
|
|
||||||
public ulong ChannelId { get; set; }
|
public ulong ChannelId { get; set; }
|
||||||
public bool State { get; set; }
|
public bool State { get; set; }
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@ namespace NadekoBot.Db.Models;
|
|||||||
|
|
||||||
public class GuildConfig : DbEntity
|
public class GuildConfig : DbEntity
|
||||||
{
|
{
|
||||||
|
// public bool Keep { get; set; }
|
||||||
public ulong GuildId { get; set; }
|
public ulong GuildId { get; set; }
|
||||||
|
|
||||||
public string Prefix { get; set; }
|
public string Prefix { get; set; }
|
||||||
@@ -12,21 +13,23 @@ public class GuildConfig : DbEntity
|
|||||||
|
|
||||||
public string AutoAssignRoleIds { get; set; }
|
public string AutoAssignRoleIds { get; set; }
|
||||||
|
|
||||||
//greet stuff
|
// //greet stuff
|
||||||
public int AutoDeleteGreetMessagesTimer { get; set; } = 30;
|
// public int AutoDeleteGreetMessagesTimer { get; set; } = 30;
|
||||||
public int AutoDeleteByeMessagesTimer { get; set; } = 30;
|
// public int AutoDeleteByeMessagesTimer { get; set; } = 30;
|
||||||
|
//
|
||||||
public ulong GreetMessageChannelId { get; set; }
|
// public ulong GreetMessageChannelId { get; set; }
|
||||||
public ulong ByeMessageChannelId { get; set; }
|
// public ulong ByeMessageChannelId { get; set; }
|
||||||
|
//
|
||||||
public bool SendDmGreetMessage { get; set; }
|
// public bool SendDmGreetMessage { get; set; }
|
||||||
public string DmGreetMessageText { get; set; } = "Welcome to the %server% server, %user%!";
|
// public string DmGreetMessageText { get; set; } = "Welcome to the %server% server, %user%!";
|
||||||
|
//
|
||||||
public bool SendChannelGreetMessage { get; set; }
|
// public bool SendChannelGreetMessage { get; set; }
|
||||||
public string ChannelGreetMessageText { get; set; } = "Welcome to the %server% server, %user%!";
|
// public string ChannelGreetMessageText { get; set; } = "Welcome to the %server% server, %user%!";
|
||||||
|
//
|
||||||
public bool SendChannelByeMessage { get; set; }
|
// public bool SendChannelByeMessage { get; set; }
|
||||||
public string ChannelByeMessageText { get; set; } = "%user% has left!";
|
// public string ChannelByeMessageText { get; set; } = "%user% has left!";
|
||||||
|
// public bool SendBoostMessage { get; set; }
|
||||||
|
// pulic int BoostMessageDeleteAfter { get; set; }
|
||||||
|
|
||||||
//self assignable roles
|
//self assignable roles
|
||||||
public bool ExclusiveSelfAssignedRoles { get; set; }
|
public bool ExclusiveSelfAssignedRoles { get; set; }
|
||||||
@@ -74,7 +77,6 @@ public class GuildConfig : DbEntity
|
|||||||
public HashSet<UnroleTimer> UnroleTimer { get; set; } = new();
|
public HashSet<UnroleTimer> UnroleTimer { get; set; } = new();
|
||||||
public HashSet<VcRoleInfo> VcRoleInfos { get; set; }
|
public HashSet<VcRoleInfo> VcRoleInfos { get; set; }
|
||||||
public HashSet<CommandAlias> CommandAliases { get; set; } = new();
|
public HashSet<CommandAlias> CommandAliases { get; set; } = new();
|
||||||
public List<WarningPunishment> WarnPunishments { get; set; } = new();
|
|
||||||
public bool WarningsInitialized { get; set; }
|
public bool WarningsInitialized { get; set; }
|
||||||
public HashSet<SlowmodeIgnoredUser> SlowmodeIgnoredUsers { get; set; }
|
public HashSet<SlowmodeIgnoredUser> SlowmodeIgnoredUsers { get; set; }
|
||||||
public HashSet<SlowmodeIgnoredRole> SlowmodeIgnoredRoles { get; set; }
|
public HashSet<SlowmodeIgnoredRole> SlowmodeIgnoredRoles { get; set; }
|
||||||
@@ -97,10 +99,6 @@ public class GuildConfig : DbEntity
|
|||||||
|
|
||||||
#region Boost Message
|
#region Boost Message
|
||||||
|
|
||||||
public bool SendBoostMessage { get; set; }
|
|
||||||
public string BoostMessage { get; set; } = "%user% just boosted this server!";
|
|
||||||
public ulong BoostMessageChannelId { get; set; }
|
|
||||||
public int BoostMessageDeleteAfter { get; set; }
|
|
||||||
public bool StickyRoles { get; set; }
|
public bool StickyRoles { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
11
src/NadekoBot/Db/Models/HoneypotChannel.cs
Normal file
11
src/NadekoBot/Db/Models/HoneypotChannel.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace NadekoBot.Db.Models;
|
||||||
|
|
||||||
|
public class HoneypotChannel
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public ulong GuildId { get; set; }
|
||||||
|
|
||||||
|
public ulong ChannelId { get; set; }
|
||||||
|
}
|
@@ -1,8 +0,0 @@
|
|||||||
#nullable disable
|
|
||||||
namespace NadekoBot.Db.Models;
|
|
||||||
|
|
||||||
public class IgnoredVoicePresenceChannel : DbEntity
|
|
||||||
{
|
|
||||||
public LogSetting LogSetting { get; set; }
|
|
||||||
public ulong ChannelId { get; set; }
|
|
||||||
}
|
|
19
src/NadekoBot/Db/Models/NCanvas/NCanvas.cs
Normal file
19
src/NadekoBot/Db/Models/NCanvas/NCanvas.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace NadekoBot.Db.Models;
|
||||||
|
|
||||||
|
public class NCPixel
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public required int Position { get; init; }
|
||||||
|
|
||||||
|
public required long Price { get; init; }
|
||||||
|
|
||||||
|
public required ulong OwnerId { get; init; }
|
||||||
|
public required uint Color { get; init; }
|
||||||
|
|
||||||
|
[MaxLength(256)]
|
||||||
|
public required string Text { get; init; }
|
||||||
|
}
|
@@ -33,10 +33,7 @@ public class Permissionv2 : DbEntity, IIndexed
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static List<Permissionv2> GetDefaultPermlist
|
public static List<Permissionv2> GetDefaultPermlist
|
||||||
=> new()
|
=> [AllowAllPerm];
|
||||||
{
|
|
||||||
AllowAllPerm
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PrimaryPermissionType
|
public enum PrimaryPermissionType
|
||||||
|
@@ -40,6 +40,9 @@ public class StreamRoleSettings : DbEntity
|
|||||||
|
|
||||||
public class StreamRoleBlacklistedUser : DbEntity
|
public class StreamRoleBlacklistedUser : DbEntity
|
||||||
{
|
{
|
||||||
|
public int StreamRoleSettingsId { get; set; }
|
||||||
|
public StreamRoleSettings StreamRoleSettings { get; set; }
|
||||||
|
|
||||||
public ulong UserId { get; set; }
|
public ulong UserId { get; set; }
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
@@ -57,6 +60,9 @@ public class StreamRoleBlacklistedUser : DbEntity
|
|||||||
|
|
||||||
public class StreamRoleWhitelistedUser : DbEntity
|
public class StreamRoleWhitelistedUser : DbEntity
|
||||||
{
|
{
|
||||||
|
public int StreamRoleSettingsId { get; set; }
|
||||||
|
public StreamRoleSettings StreamRoleSettings { get; set; }
|
||||||
|
|
||||||
public ulong UserId { get; set; }
|
public ulong UserId { get; set; }
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
public class AntiAltSetting
|
public class AntiAltSetting
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
public int GuildConfigId { get; set; }
|
public int GuildConfigId { get; set; }
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
public TimeSpan MinAge { get; set; }
|
public TimeSpan MinAge { get; set; }
|
||||||
public PunishmentAction Action { get; set; }
|
public PunishmentAction Action { get; set; }
|
||||||
public int ActionDurationMinutes { get; set; }
|
public int ActionDurationMinutes { get; set; }
|
||||||
|
@@ -5,8 +5,7 @@ namespace NadekoBot.Db.Models;
|
|||||||
public class AntiRaidSetting : DbEntity
|
public class AntiRaidSetting : DbEntity
|
||||||
{
|
{
|
||||||
public int GuildConfigId { get; set; }
|
public int GuildConfigId { get; set; }
|
||||||
public GuildConfig GuildConfig { get; set; }
|
|
||||||
|
|
||||||
public int UserThreshold { get; set; }
|
public int UserThreshold { get; set; }
|
||||||
public int Seconds { get; set; }
|
public int Seconds { get; set; }
|
||||||
public PunishmentAction Action { get; set; }
|
public PunishmentAction Action { get; set; }
|
||||||
|
@@ -4,8 +4,7 @@
|
|||||||
public class AntiSpamSetting : DbEntity
|
public class AntiSpamSetting : DbEntity
|
||||||
{
|
{
|
||||||
public int GuildConfigId { get; set; }
|
public int GuildConfigId { get; set; }
|
||||||
public GuildConfig GuildConfig { get; set; }
|
|
||||||
|
|
||||||
public PunishmentAction Action { get; set; }
|
public PunishmentAction Action { get; set; }
|
||||||
public int MessageThreshold { get; set; } = 3;
|
public int MessageThreshold { get; set; } = 3;
|
||||||
public int MuteTime { get; set; }
|
public int MuteTime { get; set; }
|
||||||
|
@@ -14,17 +14,3 @@ public class FilterChannelId : DbEntity
|
|||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
=> ChannelId.GetHashCode();
|
=> ChannelId.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FilterWordsChannelId : DbEntity
|
|
||||||
{
|
|
||||||
public ulong ChannelId { get; set; }
|
|
||||||
|
|
||||||
public bool Equals(FilterWordsChannelId other)
|
|
||||||
=> ChannelId == other.ChannelId;
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
=> obj is FilterWordsChannelId fci && Equals(fci);
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
=> ChannelId.GetHashCode();
|
|
||||||
}
|
|
17
src/NadekoBot/Db/Models/filter/FilterWordsChannelId.cs
Normal file
17
src/NadekoBot/Db/Models/filter/FilterWordsChannelId.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#nullable disable
|
||||||
|
namespace NadekoBot.Db.Models;
|
||||||
|
|
||||||
|
public class FilterWordsChannelId : DbEntity
|
||||||
|
{
|
||||||
|
public int? GuildConfigId { get; set; }
|
||||||
|
public ulong ChannelId { get; set; }
|
||||||
|
|
||||||
|
public bool Equals(FilterWordsChannelId other)
|
||||||
|
=> ChannelId == other.ChannelId;
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
=> obj is FilterWordsChannelId fci && Equals(fci);
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
=> ChannelId.GetHashCode();
|
||||||
|
}
|
@@ -3,6 +3,7 @@ namespace NadekoBot.Db.Models;
|
|||||||
|
|
||||||
public class WarningPunishment : DbEntity
|
public class WarningPunishment : DbEntity
|
||||||
{
|
{
|
||||||
|
public ulong GuildId { get; set; }
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
public PunishmentAction Punishment { get; set; }
|
public PunishmentAction Punishment { get; set; }
|
||||||
public int Time { get; set; }
|
public int Time { get; set; }
|
||||||
|
@@ -1,30 +1,6 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
namespace NadekoBot.Db.Models;
|
namespace NadekoBot.Db.Models;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Contains data about usage of Patron-Only commands per user
|
|
||||||
/// in order to provide support for quota limitations
|
|
||||||
/// (allow user x who is pledging amount y to use the specified command only
|
|
||||||
/// x amount of times in the specified time period)
|
|
||||||
/// </summary>
|
|
||||||
public class PatronQuota
|
|
||||||
{
|
|
||||||
public ulong UserId { get; set; }
|
|
||||||
public FeatureType FeatureType { get; set; }
|
|
||||||
public string Feature { get; set; }
|
|
||||||
public uint HourlyCount { get; set; }
|
|
||||||
public uint DailyCount { get; set; }
|
|
||||||
public uint MonthlyCount { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum FeatureType
|
|
||||||
{
|
|
||||||
Command,
|
|
||||||
Group,
|
|
||||||
Module,
|
|
||||||
Limit
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PatronUser
|
public class PatronUser
|
||||||
{
|
{
|
||||||
public string UniquePlatformUserId { get; set; }
|
public string UniquePlatformUserId { get; set; }
|
||||||
|
@@ -8,6 +8,4 @@ public class UserXpStats : DbEntity
|
|||||||
public long Xp { get; set; }
|
public long Xp { get; set; }
|
||||||
public long AwardedXp { get; set; }
|
public long AwardedXp { get; set; }
|
||||||
public XpNotificationLocation NotifyOnLevelUp { get; set; }
|
public XpNotificationLocation NotifyOnLevelUp { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum XpNotificationLocation { None, Dm, Channel }
|
|
8
src/NadekoBot/Db/Models/xp/XpNotificationLocation.cs
Normal file
8
src/NadekoBot/Db/Models/xp/XpNotificationLocation.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace NadekoBot.Db.Models;
|
||||||
|
|
||||||
|
public enum XpNotificationLocation
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Dm,
|
||||||
|
Channel
|
||||||
|
}
|
@@ -51,6 +51,8 @@ public class XpCurrencyReward : DbEntity
|
|||||||
|
|
||||||
public class ExcludedItem : DbEntity
|
public class ExcludedItem : DbEntity
|
||||||
{
|
{
|
||||||
|
public XpSettings XpSettings { get; set; }
|
||||||
|
|
||||||
public ulong ItemId { get; set; }
|
public ulong ItemId { get; set; }
|
||||||
public ExcludedItemType ItemType { get; set; }
|
public ExcludedItemType ItemType { get; set; }
|
||||||
|
|
||||||
|
@@ -1,38 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using NadekoBot.Db.Models;
|
|
||||||
|
|
||||||
namespace NadekoBot.Db;
|
|
||||||
|
|
||||||
public sealed class MysqlContext : NadekoContext
|
|
||||||
{
|
|
||||||
private readonly string _connStr;
|
|
||||||
private readonly string _version;
|
|
||||||
|
|
||||||
protected override string CurrencyTransactionOtherIdDefaultValue
|
|
||||||
=> "NULL";
|
|
||||||
|
|
||||||
public MysqlContext(string connStr = "Server=localhost", string version = "8.0")
|
|
||||||
{
|
|
||||||
_connStr = connStr;
|
|
||||||
_version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
||||||
{
|
|
||||||
base.OnConfiguring(optionsBuilder);
|
|
||||||
optionsBuilder
|
|
||||||
.UseLowerCaseNamingConvention()
|
|
||||||
.UseMySql(_connStr, ServerVersion.Parse(_version));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
base.OnModelCreating(modelBuilder);
|
|
||||||
|
|
||||||
// mysql is case insensitive by default
|
|
||||||
// we can set binary collation to change that
|
|
||||||
modelBuilder.Entity<ClubInfo>()
|
|
||||||
.Property(x => x.Name)
|
|
||||||
.UseCollation("utf8mb4_bin");
|
|
||||||
}
|
|
||||||
}
|
|
@@ -10,6 +10,7 @@ namespace NadekoBot.Db;
|
|||||||
public abstract class NadekoContext : DbContext
|
public abstract class NadekoContext : DbContext
|
||||||
{
|
{
|
||||||
public DbSet<GuildConfig> GuildConfigs { get; set; }
|
public DbSet<GuildConfig> GuildConfigs { get; set; }
|
||||||
|
public DbSet<GreetSettings> GreetSettings { get; set; }
|
||||||
|
|
||||||
public DbSet<Quote> Quotes { get; set; }
|
public DbSet<Quote> Quotes { get; set; }
|
||||||
public DbSet<Reminder> Reminders { get; set; }
|
public DbSet<Reminder> Reminders { get; set; }
|
||||||
@@ -28,7 +29,6 @@ public abstract class NadekoContext : DbContext
|
|||||||
|
|
||||||
//logging
|
//logging
|
||||||
public DbSet<LogSetting> LogSettings { get; set; }
|
public DbSet<LogSetting> LogSettings { get; set; }
|
||||||
public DbSet<IgnoredVoicePresenceChannel> IgnoredVoicePresenceCHannels { get; set; }
|
|
||||||
public DbSet<IgnoredLogItem> IgnoredLogChannels { get; set; }
|
public DbSet<IgnoredLogItem> IgnoredLogChannels { get; set; }
|
||||||
|
|
||||||
public DbSet<RotatingPlayingStatus> RotatingStatus { get; set; }
|
public DbSet<RotatingPlayingStatus> RotatingStatus { get; set; }
|
||||||
@@ -54,16 +54,14 @@ public abstract class NadekoContext : DbContext
|
|||||||
|
|
||||||
public DbSet<PatronUser> Patrons { get; set; }
|
public DbSet<PatronUser> Patrons { get; set; }
|
||||||
|
|
||||||
public DbSet<PatronQuota> PatronQuotas { get; set; }
|
|
||||||
|
|
||||||
public DbSet<StreamOnlineMessage> StreamOnlineMessages { get; set; }
|
public DbSet<StreamOnlineMessage> StreamOnlineMessages { get; set; }
|
||||||
|
|
||||||
public DbSet<StickyRole> StickyRoles { get; set; }
|
public DbSet<StickyRole> StickyRoles { get; set; }
|
||||||
|
|
||||||
public DbSet<TodoModel> Todos { get; set; }
|
public DbSet<TodoModel> Todos { get; set; }
|
||||||
public DbSet<ArchivedTodoListModel> TodosArchive { get; set; }
|
public DbSet<ArchivedTodoListModel> TodosArchive { get; set; }
|
||||||
|
public DbSet<HoneypotChannel> HoneyPotChannels { get; set; }
|
||||||
// todo add guild colors
|
|
||||||
// public DbSet<GuildColors> GuildColors { get; set; }
|
// public DbSet<GuildColors> GuildColors { get; set; }
|
||||||
|
|
||||||
|
|
||||||
@@ -75,6 +73,16 @@ public abstract class NadekoContext : DbContext
|
|||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
#region NCanvas
|
||||||
|
|
||||||
|
modelBuilder.Entity<NCPixel>()
|
||||||
|
.HasAlternateKey(x => x.Position);
|
||||||
|
|
||||||
|
modelBuilder.Entity<NCPixel>()
|
||||||
|
.HasIndex(x => x.OwnerId);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region QUOTES
|
#region QUOTES
|
||||||
|
|
||||||
var quoteEntity = modelBuilder.Entity<Quote>();
|
var quoteEntity = modelBuilder.Entity<Quote>();
|
||||||
@@ -86,15 +94,84 @@ public abstract class NadekoContext : DbContext
|
|||||||
#region GuildConfig
|
#region GuildConfig
|
||||||
|
|
||||||
var configEntity = modelBuilder.Entity<GuildConfig>();
|
var configEntity = modelBuilder.Entity<GuildConfig>();
|
||||||
|
|
||||||
configEntity.HasIndex(c => c.GuildId)
|
configEntity.HasIndex(c => c.GuildId)
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
configEntity.Property(x => x.VerboseErrors)
|
configEntity.Property(x => x.VerboseErrors)
|
||||||
.HasDefaultValue(true);
|
.HasDefaultValue(true);
|
||||||
|
|
||||||
modelBuilder.Entity<AntiSpamSetting>().HasOne(x => x.GuildConfig).WithOne(x => x.AntiSpamSetting);
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.DelMsgOnCmdChannels)
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey(x => x.GuildConfigId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
modelBuilder.Entity<AntiRaidSetting>().HasOne(x => x.GuildConfig).WithOne(x => x.AntiRaidSetting);
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.FollowedStreams)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.GenerateCurrencyChannelIds)
|
||||||
|
.WithOne(x => x.GuildConfig)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.Permissions)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.CommandCooldowns)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.FilterInvitesChannelIds)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.FilterLinksChannelIds)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.FilteredWords)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.FilterWordsChannelIds)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.MutedUsers)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasOne(x => x.AntiRaidSetting)
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey<AntiRaidSetting>(x => x.GuildConfigId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
// start antispam
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasOne(x => x.AntiSpamSetting)
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey<AntiSpamSetting>(x => x.GuildConfigId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<AntiSpamSetting>()
|
||||||
|
.HasMany(x => x.IgnoredChannels)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
// end antispam
|
||||||
|
|
||||||
modelBuilder.Entity<GuildConfig>()
|
modelBuilder.Entity<GuildConfig>()
|
||||||
.HasOne(x => x.AntiAltSetting)
|
.HasOne(x => x.AntiAltSetting)
|
||||||
@@ -102,6 +179,93 @@ public abstract class NadekoContext : DbContext
|
|||||||
.HasForeignKey<AntiAltSetting>(x => x.GuildConfigId)
|
.HasForeignKey<AntiAltSetting>(x => x.GuildConfigId)
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.UnmuteTimers)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.UnbanTimer)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.UnroleTimer)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.VcRoleInfos)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.CommandAliases)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.SlowmodeIgnoredRoles)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.SlowmodeIgnoredUsers)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
// start shop
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.ShopEntries)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<ShopEntry>()
|
||||||
|
.HasMany(x => x.Items)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
// end shop
|
||||||
|
|
||||||
|
// start streamrole
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasOne(x => x.StreamRole)
|
||||||
|
.WithOne(x => x.GuildConfig)
|
||||||
|
.HasForeignKey<StreamRoleSettings>(x => x.GuildConfigId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<StreamRoleSettings>()
|
||||||
|
.HasMany(x => x.Whitelist)
|
||||||
|
.WithOne(x => x.StreamRoleSettings)
|
||||||
|
.HasForeignKey(x => x.StreamRoleSettingsId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<StreamRoleSettings>()
|
||||||
|
.HasMany(x => x.Blacklist)
|
||||||
|
.WithOne(x => x.StreamRoleSettings)
|
||||||
|
.HasForeignKey(x => x.StreamRoleSettingsId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
// end streamrole
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasOne(x => x.XpSettings)
|
||||||
|
.WithOne(x => x.GuildConfig)
|
||||||
|
.HasForeignKey<XpSettings>(x => x.GuildConfigId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.FeedSubs)
|
||||||
|
.WithOne(x => x.GuildConfig)
|
||||||
|
.HasForeignKey(x => x.GuildConfigId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<GuildConfig>()
|
||||||
|
.HasMany(x => x.SelfAssignableRoleGroupNames)
|
||||||
|
.WithOne()
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
modelBuilder.Entity<FeedSub>()
|
modelBuilder.Entity<FeedSub>()
|
||||||
.HasAlternateKey(x => new
|
.HasAlternateKey(x => new
|
||||||
{
|
{
|
||||||
@@ -117,9 +281,16 @@ public abstract class NadekoContext : DbContext
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region streamrole
|
#region WarningPunishments
|
||||||
|
|
||||||
modelBuilder.Entity<StreamRoleSettings>().HasOne(x => x.GuildConfig).WithOne(x => x.StreamRole);
|
var warnpunishmentEntity = modelBuilder.Entity<WarningPunishment>(b =>
|
||||||
|
{
|
||||||
|
b.HasAlternateKey(x => new
|
||||||
|
{
|
||||||
|
x.GuildId,
|
||||||
|
x.Count
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -184,6 +355,7 @@ public abstract class NadekoContext : DbContext
|
|||||||
du.HasIndex(x => x.TotalXp);
|
du.HasIndex(x => x.TotalXp);
|
||||||
du.HasIndex(x => x.CurrencyAmount);
|
du.HasIndex(x => x.CurrencyAmount);
|
||||||
du.HasIndex(x => x.UserId);
|
du.HasIndex(x => x.UserId);
|
||||||
|
du.HasIndex(x => x.Username);
|
||||||
});
|
});
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -217,12 +389,6 @@ public abstract class NadekoContext : DbContext
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region XpSettings
|
|
||||||
|
|
||||||
modelBuilder.Entity<XpSettings>().HasOne(x => x.GuildConfig).WithOne(x => x.XpSettings);
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region XpRoleReward
|
#region XpRoleReward
|
||||||
|
|
||||||
modelBuilder.Entity<XpRoleReward>()
|
modelBuilder.Entity<XpRoleReward>()
|
||||||
@@ -233,6 +399,21 @@ public abstract class NadekoContext : DbContext
|
|||||||
})
|
})
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
|
modelBuilder.Entity<XpSettings>()
|
||||||
|
.HasMany(x => x.RoleRewards)
|
||||||
|
.WithOne(x => x.XpSettings)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<XpSettings>()
|
||||||
|
.HasMany(x => x.CurrencyRewards)
|
||||||
|
.WithOne(x => x.XpSettings)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
modelBuilder.Entity<XpSettings>()
|
||||||
|
.HasMany(x => x.ExclusionList)
|
||||||
|
.WithOne(x => x.XpSettings)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Club
|
#region Club
|
||||||
@@ -331,9 +512,9 @@ public abstract class NadekoContext : DbContext
|
|||||||
|
|
||||||
modelBuilder.Entity<BanTemplate>().HasIndex(x => x.GuildId).IsUnique();
|
modelBuilder.Entity<BanTemplate>().HasIndex(x => x.GuildId).IsUnique();
|
||||||
modelBuilder.Entity<BanTemplate>()
|
modelBuilder.Entity<BanTemplate>()
|
||||||
.Property(x => x.PruneDays)
|
.Property(x => x.PruneDays)
|
||||||
.HasDefaultValue(null)
|
.HasDefaultValue(null)
|
||||||
.IsRequired(false);
|
.IsRequired(false);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -433,19 +614,9 @@ public abstract class NadekoContext : DbContext
|
|||||||
});
|
});
|
||||||
|
|
||||||
// quotes are per user id
|
// quotes are per user id
|
||||||
modelBuilder.Entity<PatronQuota>(pq =>
|
|
||||||
{
|
|
||||||
pq.HasIndex(x => x.UserId).IsUnique(false);
|
|
||||||
pq.HasKey(x => new
|
|
||||||
{
|
|
||||||
x.UserId,
|
|
||||||
x.FeatureType,
|
|
||||||
x.Feature
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Xp Item Shop
|
#region Xp Item Shop
|
||||||
|
|
||||||
modelBuilder.Entity<XpShopOwnedItem>(
|
modelBuilder.Entity<XpShopOwnedItem>(
|
||||||
@@ -453,76 +624,100 @@ public abstract class NadekoContext : DbContext
|
|||||||
{
|
{
|
||||||
// user can own only one of each item
|
// user can own only one of each item
|
||||||
x.HasIndex(model => new
|
x.HasIndex(model => new
|
||||||
{
|
{
|
||||||
model.UserId,
|
model.UserId,
|
||||||
model.ItemType,
|
model.ItemType,
|
||||||
model.ItemKey
|
model.ItemKey
|
||||||
})
|
})
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
});
|
});
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region AutoPublish
|
#region AutoPublish
|
||||||
|
|
||||||
modelBuilder.Entity<AutoPublishChannel>(apc => apc
|
modelBuilder.Entity<AutoPublishChannel>(apc => apc
|
||||||
.HasIndex(x => x.GuildId)
|
.HasIndex(x => x.GuildId)
|
||||||
.IsUnique());
|
.IsUnique());
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region GamblingStats
|
#region GamblingStats
|
||||||
|
|
||||||
modelBuilder.Entity<GamblingStats>(gs => gs
|
modelBuilder.Entity<GamblingStats>(gs => gs
|
||||||
.HasIndex(x => x.Feature)
|
.HasIndex(x => x.Feature)
|
||||||
.IsUnique());
|
.IsUnique());
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Sticky Roles
|
#region Sticky Roles
|
||||||
|
|
||||||
modelBuilder.Entity<StickyRole>(sr => sr.HasIndex(x => new
|
modelBuilder.Entity<StickyRole>(sr => sr.HasIndex(x => new
|
||||||
{
|
{
|
||||||
x.GuildId,
|
x.GuildId,
|
||||||
x.UserId
|
x.UserId
|
||||||
}).IsUnique());
|
})
|
||||||
|
.IsUnique());
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Giveaway
|
#region Giveaway
|
||||||
|
|
||||||
modelBuilder.Entity<GiveawayModel>()
|
modelBuilder.Entity<GiveawayModel>()
|
||||||
.HasMany(x => x.Participants)
|
.HasMany(x => x.Participants)
|
||||||
.WithOne()
|
.WithOne()
|
||||||
.HasForeignKey(x => x.GiveawayId)
|
.HasForeignKey(x => x.GiveawayId)
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
modelBuilder.Entity<GiveawayUser>(gu => gu
|
modelBuilder.Entity<GiveawayUser>(gu => gu
|
||||||
.HasIndex(x => new
|
.HasIndex(x => new
|
||||||
{
|
{
|
||||||
x.GiveawayId,
|
x.GiveawayId,
|
||||||
x.UserId
|
x.UserId
|
||||||
})
|
})
|
||||||
.IsUnique());
|
.IsUnique());
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Todo
|
#region Todo
|
||||||
|
|
||||||
modelBuilder.Entity<TodoModel>()
|
modelBuilder.Entity<TodoModel>()
|
||||||
.HasKey(x => x.Id);
|
.HasKey(x => x.Id);
|
||||||
|
|
||||||
modelBuilder.Entity<TodoModel>()
|
modelBuilder.Entity<TodoModel>()
|
||||||
.HasIndex(x => x.UserId)
|
.HasIndex(x => x.UserId)
|
||||||
.IsUnique(false);
|
.IsUnique(false);
|
||||||
|
|
||||||
modelBuilder.Entity<ArchivedTodoListModel>()
|
modelBuilder.Entity<ArchivedTodoListModel>()
|
||||||
.HasMany(x => x.Items)
|
.HasMany(x => x.Items)
|
||||||
.WithOne()
|
.WithOne()
|
||||||
.HasForeignKey(x => x.ArchiveId)
|
.HasForeignKey(x => x.ArchiveId)
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GreetSettings
|
||||||
|
|
||||||
|
modelBuilder
|
||||||
|
.Entity<GreetSettings>(gs => gs.HasIndex(x => new
|
||||||
|
{
|
||||||
|
x.GuildId,
|
||||||
|
x.GreetType
|
||||||
|
})
|
||||||
|
.IsUnique());
|
||||||
|
|
||||||
|
modelBuilder.Entity<GreetSettings>(gs =>
|
||||||
|
{
|
||||||
|
gs
|
||||||
|
.Property(x => x.IsEnabled)
|
||||||
|
.HasDefaultValue(false);
|
||||||
|
|
||||||
|
gs
|
||||||
|
.Property(x => x.AutoDeleteTimer)
|
||||||
|
.HasDefaultValue(0);
|
||||||
|
});
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,8 +44,6 @@ public sealed class NadekoDbService : DbService
|
|||||||
case "postgres":
|
case "postgres":
|
||||||
case "pgsql":
|
case "pgsql":
|
||||||
return new PostgreSqlContext(connString);
|
return new PostgreSqlContext(connString);
|
||||||
case "mysql":
|
|
||||||
return new MysqlContext(connString);
|
|
||||||
case "sqlite":
|
case "sqlite":
|
||||||
return new SqliteContext(connString);
|
return new SqliteContext(connString);
|
||||||
default:
|
default:
|
||||||
|
@@ -7,16 +7,7 @@ public static class MigrationQueries
|
|||||||
{
|
{
|
||||||
public static void MigrateRero(MigrationBuilder migrationBuilder)
|
public static void MigrateRero(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
if (migrationBuilder.IsMySql())
|
if (migrationBuilder.IsSqlite())
|
||||||
{
|
|
||||||
migrationBuilder.Sql(
|
|
||||||
@"INSERT IGNORE into reactionroles(guildid, channelid, messageid, emote, roleid, `group`, levelreq, dateadded)
|
|
||||||
select guildid, channelid, messageid, emotename, roleid, exclusive, 0, reactionrolemessage.dateadded
|
|
||||||
from reactionrole
|
|
||||||
left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid
|
|
||||||
left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;");
|
|
||||||
}
|
|
||||||
else if (migrationBuilder.IsSqlite())
|
|
||||||
{
|
{
|
||||||
migrationBuilder.Sql(
|
migrationBuilder.Sql(
|
||||||
@"insert or ignore into reactionroles(guildid, channelid, messageid, emote, roleid, 'group', levelreq, dateadded)
|
@"insert or ignore into reactionroles(guildid, channelid, messageid, emote, roleid, 'group', levelreq, dateadded)
|
||||||
@@ -27,7 +18,8 @@ left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;")
|
|||||||
}
|
}
|
||||||
else if (migrationBuilder.IsNpgsql())
|
else if (migrationBuilder.IsNpgsql())
|
||||||
{
|
{
|
||||||
migrationBuilder.Sql(@"insert into reactionroles(guildid, channelid, messageid, emote, roleid, ""group"", levelreq, dateadded)
|
migrationBuilder.Sql(
|
||||||
|
@"insert into reactionroles(guildid, channelid, messageid, emote, roleid, ""group"", levelreq, dateadded)
|
||||||
select guildid, channelid, messageid, emotename, roleid, exclusive::int, 0, reactionrolemessage.dateadded
|
select guildid, channelid, messageid, emotename, roleid, exclusive::int, 0, reactionrolemessage.dateadded
|
||||||
from reactionrole
|
from reactionrole
|
||||||
left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid
|
left join reactionrolemessage on reactionrolemessage.id = reactionrole.reactionrolemessageid
|
||||||
@@ -39,4 +31,55 @@ left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;")
|
|||||||
throw new NotSupportedException("This database provider doesn't have an implementation for MigrateRero");
|
throw new NotSupportedException("This database provider doesn't have an implementation for MigrateRero");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void GuildConfigCleanup(MigrationBuilder builder)
|
||||||
|
{
|
||||||
|
builder.Sql($"""
|
||||||
|
DELETE FROM "DelMsgOnCmdChannel" WHERE "GuildConfigId" is NULL;
|
||||||
|
DELETE FROM "WarningPunishment" WHERE "GuildConfigId" NOT IN (SELECT "Id" from "GuildConfigs");
|
||||||
|
DELETE FROM "StreamRoleBlacklistedUser" WHERE "StreamRoleSettingsId" is NULL;
|
||||||
|
DELETE FROM "Permissions" WHERE "GuildConfigId" NOT IN (SELECT "Id" from "GuildConfigs");
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void GreetSettingsCopy(MigrationBuilder builder)
|
||||||
|
{
|
||||||
|
builder.Sql("""
|
||||||
|
INSERT INTO GreetSettings (GuildId, GreetType, MessageText, IsEnabled, ChannelId, AutoDeleteTimer)
|
||||||
|
SELECT GuildId, 0, ChannelGreetMessageText, SendChannelGreetMessage, GreetMessageChannelId, AutoDeleteGreetMessagesTimer
|
||||||
|
FROM GuildConfigs
|
||||||
|
WHERE SendChannelGreetMessage = TRUE;
|
||||||
|
|
||||||
|
INSERT INTO GreetSettings (GuildId, GreetType, MessageText, IsEnabled, ChannelId, AutoDeleteTimer)
|
||||||
|
SELECT GuildId, 1, DmGreetMessageText, SendDmGreetMessage, GreetMessageChannelId, 0
|
||||||
|
FROM GuildConfigs
|
||||||
|
WHERE SendDmGreetMessage = TRUE;
|
||||||
|
|
||||||
|
INSERT INTO GreetSettings (GuildId, GreetType, MessageText, IsEnabled, ChannelId, AutoDeleteTimer)
|
||||||
|
SELECT GuildId, 2, ChannelByeMessageText, SendChannelByeMessage, ByeMessageChannelId, AutoDeleteByeMessagesTimer
|
||||||
|
FROM GuildConfigs
|
||||||
|
WHERE SendChannelByeMessage = TRUE;
|
||||||
|
|
||||||
|
INSERT INTO GreetSettings (GuildId, GreetType, MessageText, IsEnabled, ChannelId, AutoDeleteTimer)
|
||||||
|
SELECT GuildId, 3, BoostMessage, SendBoostMessage, BoostMessageChannelId, BoostMessageDeleteAfter
|
||||||
|
FROM GuildConfigs
|
||||||
|
WHERE SendBoostMessage = TRUE;
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddGuildIdsToWarningPunishment(MigrationBuilder builder)
|
||||||
|
{
|
||||||
|
builder.Sql("""
|
||||||
|
DELETE FROM WarningPunishment WHERE GuildConfigId IS NULL OR GuildConfigId NOT IN (SELECT Id FROM GuildConfigs);
|
||||||
|
UPDATE WarningPunishment
|
||||||
|
SET GuildId = (SELECT GuildId FROM GuildConfigs WHERE Id = GuildConfigId);
|
||||||
|
|
||||||
|
DELETE FROM WarningPunishment as wp
|
||||||
|
WHERE (wp.Count, wp.GuildConfigId) in (
|
||||||
|
SELECT wp2.Count, wp2.GuildConfigId FROM WarningPunishment as wp2
|
||||||
|
GROUP BY wp2.Count, wp2.GuildConfigId
|
||||||
|
HAVING COUNT(id) > 1
|
||||||
|
);
|
||||||
|
""");
|
||||||
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class stondel : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "deletestreamonlinemessage",
|
|
||||||
table: "guildconfigs",
|
|
||||||
type: "tinyint(1)",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "deletestreamonlinemessage",
|
|
||||||
table: "guildconfigs");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class bank : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "bankusers",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
userid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
balance = table.Column<long>(type: "bigint", nullable: false),
|
|
||||||
dateadded = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_bankusers", x => x.id);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_bankusers_userid",
|
|
||||||
table: "bankusers",
|
|
||||||
column: "userid",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "bankusers");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,121 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class newrero : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "reactionroles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
guildid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
channelid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
messageid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
emote = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
roleid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
group = table.Column<int>(type: "int", nullable: false),
|
|
||||||
levelreq = table.Column<int>(type: "int", nullable: false),
|
|
||||||
dateadded = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_reactionroles", x => x.id);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_reactionroles_guildid",
|
|
||||||
table: "reactionroles",
|
|
||||||
column: "guildid");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_reactionroles_messageid_emote",
|
|
||||||
table: "reactionroles",
|
|
||||||
columns: new[] { "messageid", "emote" },
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
MigrationQueries.MigrateRero(migrationBuilder);
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "reactionrole");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "reactionrolemessage");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "reactionroles");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "reactionrolemessage",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
guildconfigid = table.Column<int>(type: "int", nullable: false),
|
|
||||||
channelid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
dateadded = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
||||||
exclusive = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
||||||
index = table.Column<int>(type: "int", nullable: false),
|
|
||||||
messageid = table.Column<ulong>(type: "bigint unsigned", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_reactionrolemessage", x => x.id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_reactionrolemessage_guildconfigs_guildconfigid",
|
|
||||||
column: x => x.guildconfigid,
|
|
||||||
principalTable: "guildconfigs",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "reactionrole",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
dateadded = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
||||||
emotename = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
reactionrolemessageid = table.Column<int>(type: "int", nullable: true),
|
|
||||||
roleid = table.Column<ulong>(type: "bigint unsigned", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_reactionrole", x => x.id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "fk_reactionrole_reactionrolemessage_reactionrolemessageid",
|
|
||||||
column: x => x.reactionrolemessageid,
|
|
||||||
principalTable: "reactionrolemessage",
|
|
||||||
principalColumn: "id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_reactionrole_reactionrolemessageid",
|
|
||||||
table: "reactionrole",
|
|
||||||
column: "reactionrolemessageid");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_reactionrolemessage_guildconfigid",
|
|
||||||
table: "reactionrolemessage",
|
|
||||||
column: "guildconfigid");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,176 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class patronagesystem : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "patreonuserid",
|
|
||||||
table: "rewardedusers",
|
|
||||||
newName: "platformuserid");
|
|
||||||
|
|
||||||
migrationBuilder.RenameIndex(
|
|
||||||
name: "ix_rewardedusers_patreonuserid",
|
|
||||||
table: "rewardedusers",
|
|
||||||
newName: "ix_rewardedusers_platformuserid");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<long>(
|
|
||||||
name: "xp",
|
|
||||||
table: "userxpstats",
|
|
||||||
type: "bigint",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<long>(
|
|
||||||
name: "awardedxp",
|
|
||||||
table: "userxpstats",
|
|
||||||
type: "bigint",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<long>(
|
|
||||||
name: "amountrewardedthismonth",
|
|
||||||
table: "rewardedusers",
|
|
||||||
type: "bigint",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<bool>(
|
|
||||||
name: "verboseerrors",
|
|
||||||
table: "guildconfigs",
|
|
||||||
type: "tinyint(1)",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: true,
|
|
||||||
oldClrType: typeof(bool),
|
|
||||||
oldType: "tinyint(1)");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<long>(
|
|
||||||
name: "totalxp",
|
|
||||||
table: "discorduser",
|
|
||||||
type: "bigint",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0L,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int",
|
|
||||||
oldDefaultValue: 0);
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "patronquotas",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
userid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
featuretype = table.Column<int>(type: "int", nullable: false),
|
|
||||||
feature = table.Column<string>(type: "varchar(255)", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
hourlycount = table.Column<uint>(type: "int unsigned", nullable: false),
|
|
||||||
dailycount = table.Column<uint>(type: "int unsigned", nullable: false),
|
|
||||||
monthlycount = table.Column<uint>(type: "int unsigned", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_patronquotas", x => new { x.userid, x.featuretype, x.feature });
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "patrons",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
userid = table.Column<ulong>(type: "bigint unsigned", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
uniqueplatformuserid = table.Column<string>(type: "varchar(255)", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
amountcents = table.Column<int>(type: "int", nullable: false),
|
|
||||||
lastcharge = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
||||||
validthru = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_patrons", x => x.userid);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_patronquotas_userid",
|
|
||||||
table: "patronquotas",
|
|
||||||
column: "userid");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_patrons_uniqueplatformuserid",
|
|
||||||
table: "patrons",
|
|
||||||
column: "uniqueplatformuserid",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "patronquotas");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "patrons");
|
|
||||||
|
|
||||||
migrationBuilder.RenameColumn(
|
|
||||||
name: "platformuserid",
|
|
||||||
table: "rewardedusers",
|
|
||||||
newName: "patreonuserid");
|
|
||||||
|
|
||||||
migrationBuilder.RenameIndex(
|
|
||||||
name: "ix_rewardedusers_platformuserid",
|
|
||||||
table: "rewardedusers",
|
|
||||||
newName: "ix_rewardedusers_patreonuserid");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "xp",
|
|
||||||
table: "userxpstats",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(long),
|
|
||||||
oldType: "bigint");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "awardedxp",
|
|
||||||
table: "userxpstats",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(long),
|
|
||||||
oldType: "bigint");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "amountrewardedthismonth",
|
|
||||||
table: "rewardedusers",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(long),
|
|
||||||
oldType: "bigint");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<bool>(
|
|
||||||
name: "verboseerrors",
|
|
||||||
table: "guildconfigs",
|
|
||||||
type: "tinyint(1)",
|
|
||||||
nullable: false,
|
|
||||||
oldClrType: typeof(bool),
|
|
||||||
oldType: "tinyint(1)",
|
|
||||||
oldDefaultValue: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "totalxp",
|
|
||||||
table: "discorduser",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0,
|
|
||||||
oldClrType: typeof(long),
|
|
||||||
oldType: "bigint",
|
|
||||||
oldDefaultValue: 0L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,39 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class stondeldbcache : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "streamonlinemessages",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
channelid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
messageid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
type = table.Column<int>(type: "int", nullable: false),
|
|
||||||
name = table.Column<string>(type: "longtext", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
dateadded = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_streamonlinemessages", x => x.id);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "streamonlinemessages");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class logwarns : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<ulong>(
|
|
||||||
name: "logwarnsid",
|
|
||||||
table: "logsettings",
|
|
||||||
type: "bigint unsigned",
|
|
||||||
nullable: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "logwarnsid",
|
|
||||||
table: "logsettings");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,45 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class xpitemshop : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "xpshopowneditem",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
userid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
itemtype = table.Column<int>(type: "int", nullable: false),
|
|
||||||
isusing = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
||||||
itemkey = table.Column<string>(type: "varchar(255)", nullable: false)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
dateadded = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_xpshopowneditem", x => x.id);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_xpshopowneditem_userid_itemtype_itemkey",
|
|
||||||
table: "xpshopowneditem",
|
|
||||||
columns: new[] { "userid", "itemtype", "itemkey" },
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "xpshopowneditem");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class linkonlychannels : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "type",
|
|
||||||
table: "imageonlychannels",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "type",
|
|
||||||
table: "imageonlychannels");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,49 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class removeobsoletexpcolumns : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "lastlevelup",
|
|
||||||
table: "userxpstats");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "lastlevelup",
|
|
||||||
table: "discorduser");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "lastxpgain",
|
|
||||||
table: "discorduser");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
|
||||||
name: "lastlevelup",
|
|
||||||
table: "userxpstats",
|
|
||||||
type: "datetime(6)",
|
|
||||||
nullable: false,
|
|
||||||
defaultValueSql: "(UTC_TIMESTAMP)");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
|
||||||
name: "lastlevelup",
|
|
||||||
table: "discorduser",
|
|
||||||
type: "datetime(6)",
|
|
||||||
nullable: false,
|
|
||||||
defaultValueSql: "(UTC_TIMESTAMP)");
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<DateTime>(
|
|
||||||
name: "lastxpgain",
|
|
||||||
table: "discorduser",
|
|
||||||
type: "datetime(6)",
|
|
||||||
nullable: false,
|
|
||||||
defaultValueSql: "(UTC_TIMESTAMP - INTERVAL 1 year)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class banprune : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "prunedays",
|
|
||||||
table: "bantemplates",
|
|
||||||
type: "int",
|
|
||||||
nullable: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "prunedays",
|
|
||||||
table: "bantemplates");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,25 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class shoprolereq : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<ulong>(
|
|
||||||
name: "rolerequirement",
|
|
||||||
table: "shopentry",
|
|
||||||
type: "bigint unsigned",
|
|
||||||
nullable: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "rolerequirement",
|
|
||||||
table: "shopentry");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class autopub : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "autopublishchannel",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
guildid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
channelid = table.Column<ulong>(type: "bigint unsigned", nullable: false),
|
|
||||||
dateadded = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_autopublishchannel", x => x.id);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_autopublishchannel_guildid",
|
|
||||||
table: "autopublishchannel",
|
|
||||||
column: "guildid",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "autopublishchannel");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,44 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class gamblingstats : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "gamblingstats",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
||||||
feature = table.Column<string>(type: "varchar(255)", nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
||||||
bet = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
||||||
paidout = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
|
|
||||||
dateadded = table.Column<DateTime>(type: "datetime(6)", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("pk_gamblingstats", x => x.id);
|
|
||||||
})
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "ix_gamblingstats_feature",
|
|
||||||
table: "gamblingstats",
|
|
||||||
column: "feature",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "gamblingstats");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class toggleglobalexpressions : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
|
||||||
name: "disableglobalexpressions",
|
|
||||||
table: "guildconfigs",
|
|
||||||
type: "tinyint(1)",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "disableglobalexpressions",
|
|
||||||
table: "guildconfigs");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,35 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class logthread : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<ulong>(
|
|
||||||
name: "threadcreatedid",
|
|
||||||
table: "logsettings",
|
|
||||||
type: "bigint unsigned",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<ulong>(
|
|
||||||
name: "threaddeletedid",
|
|
||||||
table: "logsettings",
|
|
||||||
type: "bigint unsigned",
|
|
||||||
nullable: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "threadcreatedid",
|
|
||||||
table: "logsettings");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "threaddeletedid",
|
|
||||||
table: "logsettings");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace NadekoBot.Migrations.Mysql
|
|
||||||
{
|
|
||||||
public partial class feedtext : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "message",
|
|
||||||
table: "feedsub",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true)
|
|
||||||
.Annotation("MySql:CharSet", "utf8mb4");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "message",
|
|
||||||
table: "feedsub");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user