Compare commits

..

1 Commits

Author SHA1 Message Date
Kwoth
7d5c4666b8 Fixed VoiceXP bug, closes #374. Upped version to 4.3.4, Updated changelog 2022-08-07 13:07:51 +02:00
311 changed files with 2845 additions and 90330 deletions

View File

@@ -14,16 +14,8 @@ variables:
tests: "NadekoBot.Tests" tests: "NadekoBot.Tests"
LINUX_X64_OUTPUT_DIR: "nadekobot-linux-x64" LINUX_X64_OUTPUT_DIR: "nadekobot-linux-x64"
LINUX_X64_RELEASE: "$CI_COMMIT_TAG-linux-x64-build.tar" LINUX_X64_RELEASE: "$CI_COMMIT_TAG-linux-x64-build.tar"
LINUX_ARM64_OUTPUT_DIR: "nadekobot-linux-arm64"
LINUX_ARM64_RELEASE: "$CI_COMMIT_TAG-linux-arm64-build.tar"
MACOS_X64_OUTPUT_DIR: "nadekobot-osx-x64"
MACOS_X64_RELEASE: "$CI_COMMIT_TAG-osx-x64-build.tar"
MACOS_ARM64_OUTPUT_DIR: "nadekobot-osx-arm64"
MACOS_ARM64_RELEASE: "$CI_COMMIT_TAG-osx-arm64-build.tar"
WIN_X64_OUTPUT_DIR: "nadekobot-windows-x64" WIN_X64_OUTPUT_DIR: "nadekobot-windows-x64"
WIN_X64_RELEASE: "$CI_COMMIT_TAG-windows-x64-build.zip" WIN_X64_RELEASE: "$CI_COMMIT_TAG-windows-x64-build.zip"
WIN_ARM64_OUTPUT_DIR: "nadekobot-windows-arm64"
WIN_ARM64_RELEASE: "$CI_COMMIT_TAG-windows-arm64-build.zip"
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/NadekoBot-build/${CI_COMMIT_TAG}" PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/NadekoBot-build/${CI_COMMIT_TAG}"
INSTALLER_OUTPUT_DIR: "nadeko-installers/${CI_COMMIT_TAG}" INSTALLER_OUTPUT_DIR: "nadeko-installers/${CI_COMMIT_TAG}"
INSTALLER_FILE_NAME: "nadeko-setup-${CI_COMMIT_TAG}.exe" INSTALLER_FILE_NAME: "nadeko-setup-${CI_COMMIT_TAG}.exe"
@@ -32,19 +24,11 @@ build:
stage: build stage: build
script: script:
- "dotnet publish -c Release -r linux-x64 --self-contained -o $LINUX_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj" - "dotnet publish -c Release -r linux-x64 --self-contained -o $LINUX_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
- "dotnet publish -c Release -r linux-arm64 --self-contained -o $LINUX_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
- "dotnet publish -c Release -r win7-x64 --self-contained -o $WIN_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj" - "dotnet publish -c Release -r win7-x64 --self-contained -o $WIN_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
- "dotnet publish -c Release -r win7-arm64 --self-contained -o $WIN_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
- "dotnet publish -c Release -r osx-x64 --self-contained -o $MACOS_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
- "dotnet publish -c Release -r osx-arm64 --self-contained -o $MACOS_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
artifacts: artifacts:
paths: paths:
- "$LINUX_X64_OUTPUT_DIR/" - "$LINUX_X64_OUTPUT_DIR/"
- "$LINUX_ARM64_OUTPUT_DIR/"
- "$WIN_X64_OUTPUT_DIR/" - "$WIN_X64_OUTPUT_DIR/"
- "$WIN_ARM64_OUTPUT_DIR/"
- "$MACOS_X64_OUTPUT_DIR/"
- "$MACOS_ARM64_OUTPUT_DIR/"
upload-builds: upload-builds:
stage: upload-builds stage: upload-builds
@@ -54,23 +38,12 @@ upload-builds:
script: script:
- apk add --no-cache curl tar zip - apk add --no-cache curl tar zip
- "tar cvf $LINUX_X64_RELEASE $LINUX_X64_OUTPUT_DIR/*" - "tar cvf $LINUX_X64_RELEASE $LINUX_X64_OUTPUT_DIR/*"
- "tar cvf $LINUX_ARM64_RELEASE $LINUX_ARM64_OUTPUT_DIR/*"
- "tar cvf $MACOS_X64_RELEASE $MACOS_X64_OUTPUT_DIR/*"
- "tar cvf $MACOS_ARM64_RELEASE $MACOS_ARM64_OUTPUT_DIR/*"
- "zip -r $WIN_X64_RELEASE $WIN_X64_OUTPUT_DIR/*" - "zip -r $WIN_X64_RELEASE $WIN_X64_OUTPUT_DIR/*"
- "zip -r $WIN_ARM64_RELEASE $WIN_ARM64_OUTPUT_DIR/*"
- | - |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $LINUX_X64_RELEASE $PACKAGE_REGISTRY_URL/$LINUX_X64_RELEASE curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $LINUX_X64_RELEASE $PACKAGE_REGISTRY_URL/$LINUX_X64_RELEASE
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $LINUX_ARM64_RELEASE $PACKAGE_REGISTRY_URL/$LINUX_ARM64_RELEASE
- | - |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $WIN_X64_RELEASE $PACKAGE_REGISTRY_URL/$WIN_X64_RELEASE curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $WIN_X64_RELEASE $PACKAGE_REGISTRY_URL/$WIN_X64_RELEASE
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $WIN_ARM64_RELEASE $PACKAGE_REGISTRY_URL/$WIN_ARM64_RELEASE
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $MACOS_X64_RELEASE $PACKAGE_REGISTRY_URL/$MACOS_X64_RELEASE
- |
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $MACOS_ARM64_RELEASE $PACKAGE_REGISTRY_URL/$MACOS_ARM64_RELEASE
release: release:
stage: release stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest image: registry.gitlab.com/gitlab-org/release-cli:latest
@@ -80,11 +53,7 @@ release:
- | - |
release-cli create --name "NadekoBot v$CI_COMMIT_TAG" --description "## [Changelog](https://gitlab.com/Kwoth/nadekobot/-/blob/v4/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/v4/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\":\"${WIN_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_X64_RELEASE}\"}"
--assets-link "{\"name\":\"${WIN_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_X64_RELEASE}\"}" \
--assets-link "{\"name\":\"${WIN_ARM64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_ARM64_RELEASE}\"}" \
--assets-link "{\"name\":\"${MACOS_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${MACOS_X64_RELEASE}\"}" \
--assets-link "{\"name\":\"${MACOS_ARM64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${MACOS_ARM64_RELEASE}\"}"
test: test:
stage: test stage: test
@@ -135,7 +104,7 @@ publish-medusa-package:
- 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)
- if [ $CI_COMMIT_TAG ];then MEDUSA_VERSION="$CI_COMMIT_TAG"; else MEDUSA_VERSION="$LAST_TAG-$CI_COMMIT_SHORT_SHA"; fi - if [ $CI_COMMIT_TAG ];then MEDUSA_VERSION="$CI_COMMIT_TAG"; else MEDUSA_VERSION="$LAST_TAG-$CI_COMMIT_SHA"; fi
- cd src/Nadeko.Medusa/ - cd src/Nadeko.Medusa/
- dotnet pack -c Release /p:Version=$MEDUSA_VERSION -o bin/Release/packed - dotnet pack -c Release /p:Version=$MEDUSA_VERSION -o bin/Release/packed
- dotnet nuget push bin/Release/packed/ --source https://www.myget.org/F/nadeko/api/v2/package --api-key "$MYGET_API_KEY" - dotnet nuget push bin/Release/packed/ --source https://www.myget.org/F/nadeko/api/v2/package --api-key "$MYGET_API_KEY"

View File

@@ -2,266 +2,7 @@
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
## [4.3.21] ## Unreleased
### Fixed
- Possible fix for a duplicate in `.h bank`
- Fixed `.stock` command
- Fixed `.clubapply` and `.clubaccept`
- Removed some redundant discriminators
## [4.3.20] - 20.01.2024
### Fixed
- Fixed `.config searches followedStreams.maxCount` not working
## [4.3.19] - 20.01.2024
### Added
- Added `followedStreams.maxCount` to `searches.yml` which lets bot owners change the default of 10 per server
### Changed
- Improvements to GPT ChatterBot (thx alexandra)
- Add a personality prompt to tweak the way chatgpt bot behaves
- Added Chat history support to chatgpt ChatterBot
- Chatgpt token usage now correctly calculated
- More chatgpt configs in `games.yml`
## [4.3.18] - 26.12.2023
### Added
- Added `.cacheusers` command (thx Kotz)
- Added `.clubreject` which lets you reject club applications
### Changed
- Updated discord lib, there should be less console errors now
### Fixed
- Fixed `icon_url` when using `.showembed`
- Fixed `.quoteshow` not showing sometimes (thx Cata)
- Notifications will no longer be sent if dms are off when using `.give`
- Users should no longer be able to apply to clubs while in a club already (especially not to the same club they're already in)
### Removed
- `.revimg` and `.revav` as google removed reverse image search
## [4.3.17] - 06.09.2023
### Fixed
- Fix to waifu gifts being character limited
- Fixes UserUpdated and UserPresence not correctly ignoring users that are logignored
- Added Trim() to activity names since apparently some activities have trailing spaces.
## [4.3.16] - 24.05.2023
### Fixed
- Fixed missing events from `.logevents`
- Fixed `.log` thread deleted and thread created events not working properly
## [4.3.15] - 21.05.2023
### Fixed
- Fixed -w 0 in trivia
- Fixed `.rps` amount field in the response
- Fixed `.showembed` output
- Fixed bank award's incorrect output message
## [4.3.14] - 02.04.2023
### Fixed
- Fixed voice hearbeat issue
- `.banktake` had ok/error responses flipped. No functional change
- PermRole should deny messages in threads todo
- Fixed chucknorris jokes
- `.logserver` will now
## [4.3.13] - 20.02.2023
### Fixed
- Fixed `.log userpresence`
- `.q` will now use `yt-dlp` if anything other than `ytProvider: Ytdl` is set in `data/searches.yml`
- Fixed Title links on some embeds
## [4.3.12] - 12.02.2023
### Fixed
- Fixed `.betstats` not working on european locales
- Timed `.ban` will work on users who are not in the server
- Fixed some bugs in the medusa system
## [4.3.11] - 21.01.2023
### Added
- Added `.doas` Bot owner only command
- Added `.stickeradd` command
### Changed
- `.waifuinfo` optimized
- You can now specify an optional custom message in `.feed` and `.yun` which will be posted along with an update
- Greet/bye messages will now get disabled if they're set to a deleted/unknown channel
- Updated response strings
- `.translate` now supports many more languages
- `.translangs` prettier output
### Fixed
- Added logging for thread events
- Fixed a bug for `.quotedeleteauthor` causing the executing user to delete own messages
- Fixed TimeOut punishment not alklowing duration
- Fixed a nullref in streamrole service
- Fixed some potential causes for ratelimit due to default message retry settings
- Fixed a patron rewards bug caused by monthly donation checking not accounting for year increase
- Fixed a patron rewards bug for users who connected the same discord account with multiple patreon accounts
- `.deletecurrency` will now also reset banked currency
- Fixed DMHelpText reply
- `.h` command show now properly show both channel and server user permission requirements
- Many fixes and improvements to medusa system
- Fixed trivia --nohint
- `.joinrace` will no longer fail if the user isn't in the database yet
## [4.3.10] - 10.11.2022
### Added
- `.filterlist` / `.fl` command which lists link and invite filtering channels and status
- Added support for `%target%` placeholder in `.alias` command
- Added .forwardtochannel which will forward messages to the current channel. It has lower priority than fwtoall
- Added .exprtoggleglobal / .extg which can be used to toggle usage of global expressions on the server
### Changed
- .meload and .meunload are now case sensitive. Previously loaded medusae may need to be reloaded or data/medusae/medusa.yml may need to be edited manually
- Several club related command have their error messages improved
- Updated help text for .antispam and .antiraid
- You can now specify time and date (time is optional) in `.remind` command instead of relative time, in the format `HH:mm dd.MM.YYYY`
- OwnerId will be automatically added to `creds.yml` at bot startup if it's missing
### Fixed
- Fixed `.cmdcd` console error
- Fixed an error when currency is add per xp
- Fixed an issue preventing execution of expressions starting with @Bot when cleverbot is enabled on the server
- Fixed `.feedadd`
- Fixed `.prune @target` not working
- Medusa modules (sneks) should now inherit medusa description when listed in .mdls command
- Fixed command cooldown calculation
## [4.3.9] - 12.10.2022
### Added
- `.betstats` shows sum of all bets, payouts and the payout rate in %. Updates once an hour
### Changed
- `.betstats` looks way better (except on Mac)
- `.feedadd` errors clarified and separated in individual error messages for each issue.
- `.clubban` and `.clubunban` errors clarified and separated in individual error messages for each issue.
- `.clubapply` better error messages
### Fixed
- `.timely` 'Remind' button fixed in DMs
- `.cmdcd` database bugs fixed
- Fixed bugged mysql and postgresql migrations
- Fixed issues with lodaing medusae due to strict versioning
### Removed
- `.slotstats` Superseded by `.betstats`
## [4.3.8] - 02.10.2022
### Added
- Added `.autopublish` command which will automatically publish messages posted in the channel.
- Added `--after <messageid>` option to prune which will make prune only delete messages after the specified message id.
### Changed
- `.prune` options `--after` and `--safe` are now proper command options, and will show in .h help
- `.cmdcd` code mostly rewritten, slight QoL improvements.
- Clarified `.remind` permission requirements in help text
- `.cmdcds` looks a little better, and is paginated
### Fixed
- Fixed trivia bugs
- Fixed `.yun` not working with channels with underscore in the name
## [4.3.7] - 14.09.2022
### Added
- Added `.exprdelserv` (.exds) to completement .exas. Deletes an expression on the current server and is susceptible to .dpo, unlike .exd
- Added `.shopreq` which lets you set role requirement for specific shop items
- Added `.shopbuy` alias to `.buy`
### Fixed
- Fixed `.convertlist` showing currencies twice (this may not apply to existing users and it may require you to manually remove all currencies from units.json)
### Removed
- Removed `Viewer` field from stream online notification as it is (almost?) always 0.
## [4.3.6] - 08.09.2022
### Added
- Added `.expraddserver` (.exas) which will server as a server-only alternative to '.exa' in case users want to override default Admin permissions with .dpo
- Added .banprune command which sets how many days worth of messages will be pruned when bot (soft)bans a person either through a command or another punishment feature.
- Added .qdelauth - Delete all quotes by the specified author on this server. If you target yourself - no permission required
- Added `.timeout` command
- Added an option to award currency based on received xp
### Changed
- Reminders now have embed support, but plaintext field is not supported.
- User friendlier errors when parsing a number in a command fails
### Fixed
- Awarded xp is now correctly used in level up calculations
## [4.3.5] - 17.08.2022
### Added
- Added a 'Use' button when a user already owns an item
- Added a 'Pull Again' button to slots
- Added `.roleinfo` command
- Added `.emojiremove` command
- Added `.threadcreate` and `.threaddelete` commands
- Added `.bank seize` / `.bank award` owner only commands
### Changed
- Running a .timely command early now shows a pending color
- .xp system is once again no longer opt in for servers
- It's still opt-in for global and requires users to run .xp at least once in order to start gaining global xp
### Fixed
- Fixed users not getting club xp
## [4.3.4] - 07.08.2022
### Fixed
- Fixed users getting XP out of nowhere while voice xp is enabled
## [4.3.3] - 06.08.2022 ## [4.3.3] - 06.08.2022

View File

@@ -28,11 +28,12 @@ WORKDIR /app
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 libopus0 libsodium23 libsqlite3-0 curl ffmpeg python3 python3-pip sudo; \
update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1; \ update-alternatives --install /usr/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; \ pip3 install --no-cache-dir --upgrade youtube-dl; \
chmod a+rx /usr/local/bin/yt-dlp; \ apt-get purge -y python3-pip; \
chmod +x /usr/local/bin/youtube-dl; \
apt-get autoremove -y; \ apt-get autoremove -y; \
apt-get autoclean -y apt-get autoclean -y

View File

@@ -1,3 +1,8 @@
[![Discord](https://discordapp.com/api/guilds/117523346618318850/widget.png)](https://discord.gg/nadekobot)
[![Documentation Status](https://readthedocs.org/projects/nadekobot/badge/?version=latest)](http://nadekobot.readthedocs.io/en/v4/?badge=v4)
[![Discord Bots](https://discordbots.org/api/widget/status/116275390695079945.svg)](https://top.gg/bot/116275390695079945)
[![nadeko0](https://cdn.nadeko.bot/tutorial/docs-top.png)](https://nadeko.bot/) [![nadeko0](https://cdn.nadeko.bot/tutorial/docs-top.png)](https://nadeko.bot/)
[![nadeko1](https://cdn.nadeko.bot/tutorial/docs-mid.png)](https://invite.nadeko.bot/) [![nadeko1](https://cdn.nadeko.bot/tutorial/docs-mid.png)](https://invite.nadeko.bot/)

View File

@@ -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

View File

@@ -24,10 +24,6 @@ The list below is not complete. Use commands above to see up-to-date list for yo
`trivia.min_win_req` - Restricts a user's ability to make a trivia game with a win requirement less than the set value. `trivia.min_win_req` - Restricts a user's ability to make a trivia game with a win requirement less than the set value.
`trivia.currency_reward` - Sets the amount of currency a user will win if they place first in a completed trivia game. `trivia.currency_reward` - Sets the amount of currency a user will win if they place first in a completed trivia game.
`hangman.currency_reward` - Sets the amount of currency a user will win if they win a game of hangman.
`chatbot` - Sets which chatbot API the bot should use, values: `gpt3`, `cleverbot`.
`gpt.model` - Sets which GPT-3 model the bot should use, values: `ada001`, `babbage001`, `curie001`, `davinci003`.
`gpt.max_tokens` - Sets the limit of tokens GPT-3 can use per call. Find out more about tokens [here](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them).
*more settings may be available in `data/games.yml` file* *more settings may be available in `data/games.yml` file*

View File

@@ -1,4 +1,4 @@
w# Setting up NadekoBot on Linux # Setting up NadekoBot on Linux
| Table of Contents | | Table of Contents |
| :-------------------------------------------------- | | :-------------------------------------------------- |
@@ -15,14 +15,11 @@ w# Setting up NadekoBot on Linux
It is recommended that you use **Ubuntu 20.04**, as there have been nearly no problems with it. Also, **32-bit systems are incompatible**. It is recommended that you use **Ubuntu 20.04**, as there have been nearly no problems with it. Also, **32-bit systems are incompatible**.
### Ubuntu 22.04 is ruled as incompatible so double check which ubuntu version you are using.
##### Compatible operating systems: ##### Compatible operating systems:
- Ubuntu: 16.04, 18.04, 20.04 - Ubuntu: 16.04, 18.04, 20.04, 21.04, 21.10 22.04
- Mint: 19, 20 - Mint: 19, 20
- Debian: 10, 11 - Debian: 9, 10
- CentOS: 7 - CentOS: 7
- openSUSE - openSUSE
- Fedora: 33, 34, 35 - Fedora: 33, 34, 35
@@ -163,30 +160,15 @@ If you are presented with the installer main menu, exit it by choosing Option `8
The above command will create a new session named **nadeko** *(you can replace “nadeko” with anything you prefer, it's your session name)*. The above command will create a new session named **nadeko** *(you can replace “nadeko” with anything you prefer, it's your session name)*.
2. Run the installer: `bash linuxAIO.sh` 2. Navigate to the project's root directory
- Project root directory location example: `cd /home/user/nadekobot/`
3. There are a few options when it comes to running Nadeko. 3. Enter the `output` directory:
- `cd output`
- Run `3` to *Run the bot normally* 4. Run the bot using:
- Run `4` to *Run the bot with Auto Restart* (This is may or may not work) - `dotnet NadekoBot.dll`
5. Detatch the tmux session:
4. If option `4` was selected, you have the following options
```
1. Run Auto Restart normally without updating NadekoBot.
2. Run Auto Restart and update NadekoBot.
3. Exit
Choose:
[1] to Run NadekoBot with Auto Restart on "die" command without updating.
[2] to Run with Auto Updating on restart after using "die" command.
```
- Run `1` to update the bot upon restart. (This is done using the `.die` command)
- Run `2` to restart the bot without updating. (This is also done using the `.die` command)
5. That's it! to detatch the tmux session:
- Press `Ctrl` + `B` - Press `Ctrl` + `B`
- Then press `D` - Then press `D`
Now check your Discord server, the bot should be online. Nadeko should now be running in the background of your system. Now check your Discord server, the bot should be online. Nadeko should now be running in the background of your system.
To re-open the tmux session to either update, restart, or whatever, execute `tmux a -t nadeko`. *(Make sure to replace "nadeko" with your session name. If you didn't change it, leave it as it.)* To re-open the tmux session to either update, restart, or whatever, execute `tmux a -t nadeko`. *(Make sure to replace "nadeko" with your session name. If you didn't change it, leave it as it.)*
@@ -319,26 +301,6 @@ This method is similar to the one above, but requires one extra step, with the a
If you want Nadeko to play music for you 24/7 without having to hosting it on your PC and want to keep it cheap, reliable and convenient as possible, you can try Nadeko on Linux Digital Ocean Droplet using the link [DigitalOcean](http://m.do.co/c/46b4d3d44795/) (by using this link, you will get **$10 credit** and also support Nadeko) If you want Nadeko to play music for you 24/7 without having to hosting it on your PC and want to keep it cheap, reliable and convenient as possible, you can try Nadeko on Linux Digital Ocean Droplet using the link [DigitalOcean](http://m.do.co/c/46b4d3d44795/) (by using this link, you will get **$10 credit** and also support Nadeko)
To set up the VPS, please select the options below
```
These are the min requirements you must follow:
OS: Any between Ubuntu, Fedora, and Debian
Plan: Basic
CPU options: regular with SSD
1 GB / 1 CPU
25 GB SSD Disk
1000 GB transfer
Note: You can select the cheapest option with 512 MB /1 CPU but this has been a hit or miss.
Datacenter region: Choose one depending on where you are located.
Authentication: Password or SSH
(Select SSH if you know what you are doing, otherwise choose password)
```
**Setting up NadekoBot** **Setting up NadekoBot**
Assuming you have followed the link above to setup an account and a Droplet with a 64-bit operational system on Digital Ocean and got the `IP address and root password (in your e-mail)` to login, it's time to get started. Assuming you have followed the link above to setup an account and a Droplet with a 64-bit operational system on Digital Ocean and got the `IP address and root password (in your e-mail)` to login, it's time to get started.

View File

@@ -7,7 +7,7 @@ Open Terminal (if you don't know how to, click on the magnifying glass on the to
###### Homebrew/wget ###### Homebrew/wget
*Skip this step if you already have homebrew installed* *Skip this step if you already have homebrew installed*
- Copy and paste this command, then press Enter: - Copy and paste this command, then press Enter:
- `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` - `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
- Install wget - Install wget
- `brew install wget` - `brew install wget`

View File

@@ -123,7 +123,7 @@ In order to use music commands, you need ffmpeg and youtube-dl installed.
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `ffmpeg.exe` file to `NadekoBot/output`. - [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `ffmpeg.exe` file to `NadekoBot/output`.
- [youtube-dl] - Click to download the file, then move `youtube-dl.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `youtube-dl.exe` file to `NadekoBot/system`. - [youtube-dl] - Click to download the file, then move `youtube-dl.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `youtube-dl.exe` file to `NadekoBot/system`.
[Updater]: https://dl.nadeko.bot/v3/ [Updater]: https://dl.nadeko.bot/
[Notepad++]: https://notepad-plus-plus.org/ [Notepad++]: https://notepad-plus-plus.org/
[.net]: https://dotnet.microsoft.com/download/dotnet/5.0 [.net]: https://dotnet.microsoft.com/download/dotnet/5.0
[Redis]: https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi [Redis]: https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi

View File

@@ -147,7 +147,6 @@ This section will guide you through how to create a simple custom medusa. You ca
<!-- Use latest .net features --> <!-- Use latest .net features -->
<LangVersion>preview</LangVersion> <LangVersion>preview</LangVersion>
<EnablePreviewFeatures>true</EnablePreviewFeatures> <EnablePreviewFeatures>true</EnablePreviewFeatures>
<GenerateRequiresPreviewFeaturesAttribute>true</GenerateRequiresPreviewFeaturesAttribute>
<!-- tell .net that this library will be used as a plugin --> <!-- tell .net that this library will be used as a plugin -->
<EnableDynamicLoading>true</EnableDynamicLoading> <EnableDynamicLoading>true</EnableDynamicLoading>
@@ -156,7 +155,7 @@ This section will guide you through how to create a simple custom medusa. You ca
<ItemGroup> <ItemGroup>
<!-- Base medusa package. You MUST reference this in order to have a working medusa --> <!-- 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 --> <!-- 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"> <PackageReference Include="Nadeko.Medusa" Version="1.0.1">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

View File

@@ -68,6 +68,11 @@ Some features have their own specific placeholders which are noted in that featu
- `%ban.reason%` - Reason for the ban, if provided - `%ban.reason%` - Reason for the ban, if provided
- `%ban.duration%` - Duration of the ban in the form Days.Hours:Minutes (6.05:04) - `%ban.duration%` - Duration of the ban in the form Days.Hours:Minutes (6.05:04)
### Bot stats placeholders
- `%servers%` - Server count bot has joined
- `%users%` - Combined user count on servers the bot has joined
### Shard stats placeholders ### Shard stats placeholders
- `%shard.servercount%` - Server count on current shard - `%shard.servercount%` - Server count on current shard
@@ -84,5 +89,6 @@ Some features have their own specific placeholders which are noted in that featu
- `%rngX-Y%` - Returns a random number between X and Y - `%rngX-Y%` - Returns a random number between X and Y
- `%target%` - Returns anything the user has written after the trigger (only works on Expressions) - `%target%` - Returns anything the user has written after the trigger (only works on Expressions)
- `%img:stuff%` - Returns an `imgur.com` search for "stuff" (only works on Expressions)
![img](https://puu.sh/B7mgI.png) ![img](https://puu.sh/B7mgI.png)

View File

@@ -1,8 +1,5 @@
namespace Nadeko.Econ.Gambling; namespace Nadeko.Econ.Gambling;
//here is a payout chart
//https://lh6.googleusercontent.com/-i1hjAJy_kN4/UswKxmhrbPI/AAAAAAAAB1U/82wq_4ZZc-Y/DE6B0895-6FC1-48BE-AC4F-14D1B91AB75B.jpg
//thanks to judge for helping me with this
public class SlotGame public class SlotGame
{ {
private static readonly NadekoRandom _rng = new NadekoRandom(); private static readonly NadekoRandom _rng = new NadekoRandom();

View File

@@ -1,10 +0,0 @@
namespace Nadeko.Snake;
/// <summary>
/// Used as a marker class for bot_perm and user_perm Attributes
/// Has no functionality.
/// </summary>
public abstract class MedusaPermAttribute : Attribute
{
}

View File

@@ -1,7 +0,0 @@
namespace Nadeko.Snake;
[AttributeUsage(AttributeTargets.Method)]
public sealed class bot_owner_onlyAttribute : MedusaPermAttribute
{
}

View File

@@ -1,23 +0,0 @@
using Discord;
namespace Nadeko.Snake;
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public sealed class bot_permAttribute : MedusaPermAttribute
{
public GuildPermission? GuildPerm { get; }
public ChannelPermission? ChannelPerm { get; }
public bot_permAttribute(GuildPermission perm)
{
GuildPerm = perm;
ChannelPerm = null;
}
public bot_permAttribute(ChannelPermission perm)
{
ChannelPerm = perm;
GuildPerm = null;
}
}

View File

@@ -1,22 +0,0 @@
using Discord;
namespace Nadeko.Snake;
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public sealed class user_permAttribute : MedusaPermAttribute
{
public GuildPermission? GuildPerm { get; }
public ChannelPermission? ChannelPerm { get; }
public user_permAttribute(GuildPermission perm)
{
GuildPerm = perm;
ChannelPerm = null;
}
public user_permAttribute(ChannelPermission perm)
{
ChannelPerm = perm;
GuildPerm = null;
}
}

View File

@@ -23,11 +23,6 @@ public abstract class AnyContext
/// </summary> /// </summary>
public abstract IUser User { get; } public abstract IUser User { get; }
/// <summary>
/// Bot user
/// </summary>
public abstract ISelfUser Bot { get; }
/// <summary> /// <summary>
/// Provides access to strings used by this medusa /// Provides access to strings used by this medusa
/// </summary> /// </summary>

View File

@@ -10,7 +10,7 @@ public static class MedusaExtensions
embed: embed.Build(), embed: embed.Build(),
options: new() options: new()
{ {
RetryMode = RetryMode.Retry502 RetryMode = RetryMode.AlwaysRetry
}); });
// unlocalized // unlocalized

View File

@@ -10,7 +10,6 @@ public interface IEmbedBuilder
IEmbedBuilder WithFooter(string text, string? iconUrl = null); IEmbedBuilder WithFooter(string text, string? iconUrl = null);
IEmbedBuilder WithAuthor(string name, string? iconUrl = null, string? url = null); IEmbedBuilder WithAuthor(string name, string? iconUrl = null, string? url = null);
IEmbedBuilder WithColor(EmbedColor color); IEmbedBuilder WithColor(EmbedColor color);
IEmbedBuilder WithDiscordColor(Color color);
Embed Build(); Embed Build();
IEmbedBuilder WithUrl(string url); IEmbedBuilder WithUrl(string url);
IEmbedBuilder WithImageUrl(string url); IEmbedBuilder WithImageUrl(string url);

View File

@@ -12,12 +12,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Discord.Net.Core" Version="3.104.0" /> <PackageReference Include="Discord.Net.Core" Version="3.103.0" />
<PackageReference Include="Serilog" Version="2.11.0" /> <PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="YamlDotNet" Version="11.2.1" /> <PackageReference Include="YamlDotNet" Version="11.2.1" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition=" '$(Version)' == '' ">
<Version>5.0.0</Version>
</PropertyGroup>
</Project> </Project>

View File

@@ -10,7 +10,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" 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.1" PrivateAssets="all" GeneratePathProperty="true" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>

View File

@@ -3,12 +3,14 @@ using Microsoft.Extensions.DependencyInjection;
using NadekoBot.Common.Configs; using NadekoBot.Common.Configs;
using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Db; using NadekoBot.Db;
using NadekoBot.Modules.Administration;
using NadekoBot.Modules.Utility; using NadekoBot.Modules.Utility;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics; using System.Diagnostics;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using Nadeko.Common;
using RunMode = Discord.Commands.RunMode; using RunMode = Discord.Commands.RunMode;
namespace NadekoBot; namespace NadekoBot;
@@ -69,7 +71,7 @@ public sealed class Bot
: GatewayIntents.AllUnprivileged, : GatewayIntents.AllUnprivileged,
LogGatewayIntentWarnings = false, LogGatewayIntentWarnings = false,
FormatUsersInBidirectionalUnicode = false, FormatUsersInBidirectionalUnicode = false,
DefaultRetryMode = RetryMode.Retry502 DefaultRetryMode = RetryMode.AlwaysRetry ^ RetryMode.RetryRatelimit
}); });
_commandService = new(new() _commandService = new(new()
@@ -116,6 +118,10 @@ public sealed class Bot
// cache // cache
.AddCache(_creds); .AddCache(_creds);
// admin
#if GLOBAL_NADEKO
svcs.AddSingleton<ILogCommandService, DummyLogCommandService>();
#endif
svcs.AddHttpClient(); svcs.AddHttpClient();
svcs.AddHttpClient("memelist") svcs.AddHttpClient("memelist")
@@ -313,29 +319,10 @@ public sealed class Bot
await _commandService.AddModulesAsync(typeof(Bot).Assembly, Services); await _commandService.AddModulesAsync(typeof(Bot).Assembly, Services);
// await _interactionService.AddModulesAsync(typeof(Bot).Assembly, Services); // await _interactionService.AddModulesAsync(typeof(Bot).Assembly, Services);
IsReady = true; IsReady = true;
await EnsureBotOwnershipAsync();
_ = Task.Run(ExecuteReadySubscriptions); _ = Task.Run(ExecuteReadySubscriptions);
Log.Information("Shard {ShardId} ready", Client.ShardId); Log.Information("Shard {ShardId} ready", Client.ShardId);
} }
private async ValueTask EnsureBotOwnershipAsync()
{
try
{
if (_creds.OwnerIds.Count != 0)
return;
Log.Information("Initializing Owner Id...");
var info = await Client.GetApplicationInfoAsync();
_credsProvider.ModifyCredsFile(x => x.OwnerIds = new[] { info.Owner.Id });
}
catch (Exception ex)
{
Log.Warning("Getting application info failed: {ErrorMessage}", ex.Message);
}
}
private Task ExecuteReadySubscriptions() private Task ExecuteReadySubscriptions()
{ {
var readyExecutors = Services.GetServices<IReadyExecutor>(); var readyExecutors = Services.GetServices<IReadyExecutor>();

View File

@@ -3,7 +3,7 @@ using NadekoBot.Modules.Administration.Services;
namespace Discord; namespace Discord;
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] [AttributeUsage(AttributeTargets.Method)]
public class UserPermAttribute : RequireUserPermissionAttribute public class UserPermAttribute : RequireUserPermissionAttribute
{ {
public UserPermAttribute(GuildPerm permission) public UserPermAttribute(GuildPerm permission)

View File

@@ -12,7 +12,7 @@ namespace NadekoBot.Common.Configs;
public sealed partial class BotConfig : ICloneable<BotConfig> public sealed partial class BotConfig : ICloneable<BotConfig>
{ {
[Comment(@"DO NOT CHANGE")] [Comment(@"DO NOT CHANGE")]
public int Version { get; set; } = 5; public int Version { get; set; } = 4;
[Comment(@"Most commands, when executed, have a small colored line [Comment(@"Most commands, when executed, have a small colored line
next to the response. The color depends whether the command next to the response. The color depends whether the command
@@ -40,10 +40,6 @@ Allowed values: Simple, Normal, None")]
or all owners? (this might cause the bot to lag if there's a lot of owners specified)")] or all owners? (this might cause the bot to lag if there's a lot of owners specified)")]
public bool ForwardToAllOwners { get; set; } public bool ForwardToAllOwners { get; set; }
[Comment(@"Any messages sent by users in Bot's DM to be forwarded to the specified channel.
This option will only work when ForwardToAllOwners is set to false")]
public ulong? ForwardToChannel { get; set; }
[Comment(@"When a user DMs the bot with a message which is not a command [Comment(@"When a user DMs the bot with a message which is not a command
they will receive this message. Leave empty for no response. The string which will be sent whenever someone DMs the bot. they will receive this message. Leave empty for no response. The string which will be sent whenever someone DMs the bot.
Supports embeds. How it looks: https://puu.sh/B0BLV.png")] Supports embeds. How it looks: https://puu.sh/B0BLV.png")]

View File

@@ -54,9 +54,6 @@ go to https://www.patreon.com/portal -> my clients -> create client")]
[Comment(@"Official cleverbot api key.")] [Comment(@"Official cleverbot api key.")]
public string CleverbotApiKey { get; set; } public string CleverbotApiKey { get; set; }
[Comment(@"Official GPT-3 api key.")]
public string Gpt3ApiKey { get; set; }
[Comment(@"Which cache implementation should bot use. [Comment(@"Which cache implementation should bot use.
'memory' - Cache will be in memory of the bot's process itself. Only use this on bots with a single shard. When the bot is restarted the cache is reset. 'memory' - Cache will be in memory of the bot's process itself. Only use this on bots with a single shard. When the bot is restarted the cache is reset.
'redis' - Uses redis (which needs to be separately downloaded and installed). The cache will persist through bot restarts. You can configure connection string in creds.yml")] 'redis' - Uses redis (which needs to be separately downloaded and installed). The cache will persist through bot restarts. You can configure connection string in creds.yml")]
@@ -121,7 +118,7 @@ Windows default
public Creds() public Creds()
{ {
Version = 7; Version = 6;
Token = string.Empty; Token = string.Empty;
UsePrivilegedIntents = true; UsePrivilegedIntents = true;
OwnerIds = new List<ulong>(); OwnerIds = new List<ulong>();
@@ -131,7 +128,6 @@ Windows default
Patreon = new(string.Empty, string.Empty, string.Empty, string.Empty); Patreon = new(string.Empty, string.Empty, string.Empty, string.Empty);
BotListToken = string.Empty; BotListToken = string.Empty;
CleverbotApiKey = string.Empty; CleverbotApiKey = string.Empty;
Gpt3ApiKey = string.Empty;
BotCache = BotCacheImplemenation.Memory; BotCache = BotCacheImplemenation.Memory;
RedisOptions = "localhost:6379,syncTimeout=30000,responseTimeout=30000,allowAdmin=true,password="; RedisOptions = "localhost:6379,syncTimeout=30000,responseTimeout=30000,allowAdmin=true,password=";
Db = new() Db = new()

View File

@@ -14,7 +14,6 @@ public interface IBotCredentials
int TotalShards { get; } int TotalShards { get; }
Creds.PatreonSettings Patreon { get; } Creds.PatreonSettings Patreon { get; }
string CleverbotApiKey { get; } string CleverbotApiKey { get; }
string Gpt3ApiKey { get; }
RestartConfig RestartCommand { get; } RestartConfig RestartCommand { get; }
Creds.VotesSettings Votes { get; } Creds.VotesSettings Votes { get; }
string BotListToken { get; } string BotListToken { get; }

View File

@@ -29,7 +29,4 @@ public enum LogType
VoicePresenceTts, VoicePresenceTts,
UserMuted, UserMuted,
UserWarned, UserWarned,
ThreadDeleted,
ThreadCreated
} }

View File

@@ -1,8 +0,0 @@
namespace NadekoBot;
public interface INadekoInteractionService
{
public NadekoInteraction Create<T>(
ulong userId,
SimpleInteraction<T> inter);
}

View File

@@ -0,0 +1,29 @@
namespace NadekoBot;
public sealed class NadekoButtonActionInteraction : NadekoButtonOwnInteraction
{
private readonly NadekoInteractionData _data;
private readonly Func<SocketMessageComponent, Task> _action;
public NadekoButtonActionInteraction(
DiscordSocketClient client,
ulong authorId,
NadekoInteractionData data,
Func<SocketMessageComponent, Task> action
)
: base(client, authorId)
{
_data = data;
_action = action;
}
protected override string Name
=> _data.CustomId;
protected override IEmote Emote
=> _data.Emote;
protected override string? Text
=> _data.Text;
public override Task ExecuteOnActionAsync(SocketMessageComponent smc)
=> _action(smc);
}

View File

@@ -1,30 +1,25 @@
namespace NadekoBot; namespace NadekoBot;
public sealed class NadekoInteraction public abstract class NadekoButtonInteraction
{ {
private readonly ulong _authorId; // improvements:
private readonly ButtonBuilder _button; // - state in OnAction
private readonly Func<SocketMessageComponent, Task> _onClick; // - configurable delay
private readonly bool _onlyAuthor; // -
protected abstract string Name { get; }
protected abstract IEmote Emote { get; }
protected virtual string? Text { get; } = null;
public DiscordSocketClient Client { get; } public DiscordSocketClient Client { get; }
private readonly TaskCompletionSource<bool> _interactionCompletedSource; protected readonly TaskCompletionSource<bool> _interactionCompletedSource;
private IUserMessage message = null!; protected IUserMessage message = null!;
public NadekoInteraction(DiscordSocketClient client, protected NadekoButtonInteraction(DiscordSocketClient client)
ulong authorId,
ButtonBuilder button,
Func<SocketMessageComponent, Task> onClick,
bool onlyAuthor)
{ {
_authorId = authorId;
_button = button;
_onClick = onClick;
_onlyAuthor = onlyAuthor;
_interactionCompletedSource = new(TaskCreationOptions.RunContinuationsAsynchronously);
Client = client; Client = client;
_interactionCompletedSource = new(TaskCreationOptions.RunContinuationsAsynchronously);
} }
public async Task RunAsync(IUserMessage msg) public async Task RunAsync(IUserMessage msg)
@@ -32,25 +27,29 @@ public sealed class NadekoInteraction
message = msg; message = msg;
Client.InteractionCreated += OnInteraction; Client.InteractionCreated += OnInteraction;
await Task.WhenAny(Task.Delay(15_000), _interactionCompletedSource.Task); await Task.WhenAny(Task.Delay(10_000), _interactionCompletedSource.Task);
Client.InteractionCreated -= OnInteraction; Client.InteractionCreated -= OnInteraction;
await msg.ModifyAsync(m => m.Components = new ComponentBuilder().Build()); await msg.ModifyAsync(m => m.Components = new ComponentBuilder().Build());
} }
private Task OnInteraction(SocketInteraction arg) protected abstract ValueTask<bool> Validate(SocketMessageComponent smc);
private async Task OnInteraction(SocketInteraction arg)
{ {
if (arg is not SocketMessageComponent smc) if (arg is not SocketMessageComponent smc)
return Task.CompletedTask; return;
if (smc.Message.Id != message.Id) if (smc.Message.Id != message.Id)
return Task.CompletedTask; return;
if (_onlyAuthor && smc.User.Id != _authorId) if (smc.Data.CustomId != Name)
return Task.CompletedTask; return;
if (smc.Data.CustomId != _button.CustomId) if (!await Validate(smc))
return Task.CompletedTask; {
await smc.DeferAsync();
return;
}
_ = Task.Run(async () => _ = Task.Run(async () =>
{ {
@@ -64,19 +63,21 @@ public sealed class NadekoInteraction
await smc.DeferAsync(); await smc.DeferAsync();
} }
}); });
return Task.CompletedTask;
} }
public MessageComponent CreateComponent() public virtual MessageComponent CreateComponent()
{ {
var comp = new ComponentBuilder() var comp = new ComponentBuilder()
.WithButton(_button); .WithButton(GetButtonBuilder());
return comp.Build(); return comp.Build();
} }
public Task ExecuteOnActionAsync(SocketMessageComponent smc) public ButtonBuilder GetButtonBuilder()
=> _onClick(smc); => new ButtonBuilder(style: ButtonStyle.Secondary, emote: Emote, customId: Name, label: Text);
public abstract Task ExecuteOnActionAsync(SocketMessageComponent smc);
} }
// this is all so wrong ...

View File

@@ -0,0 +1,43 @@
// namespace NadekoBot;
//
// public class NadekoButtonInteractionArray : NadekoButtonInteraction
// {
// private readonly ButtonBuilder[] _bbs;
// private readonly NadekoButtonInteraction[] _inters;
//
// public NadekoButtonInteractionArray(params NadekoButtonInteraction[] inters)
// : base(inters[0].Client)
// {
// _inters = inters;
// _bbs = inters.Map(x => x.GetButtonBuilder());
// }
//
// protected override string Name
// => throw new NotSupportedException();
// protected override IEmote Emote
// => throw new NotSupportedException();
//
// protected override ValueTask<bool> Validate(SocketMessageComponent smc)
// => new(true);
//
// public override Task ExecuteOnActionAsync(SocketMessageComponent smc)
// {
// for (var i = 0; i < _bbs.Length; i++)
// {
// if (_bbs[i].CustomId == smc.Data.CustomId)
// return _inters[i].ExecuteOnActionAsync(smc);
// }
//
// return Task.CompletedTask;
// }
//
// public override MessageComponent CreateComponent()
// {
// var comp = new ComponentBuilder();
//
// foreach (var bb in _bbs)
// comp.WithButton(bb);
//
// return comp.Build();
// }
// }

View File

@@ -0,0 +1,42 @@
namespace NadekoBot;
/// <summary>
/// Builder class for NadekoInteractions
/// </summary>
public class NadekoInteractionBuilder
{
private NadekoInteractionData? iData;
private Func<SocketMessageComponent, Task>? action;
// private bool isOwn;
public NadekoInteractionBuilder WithData<T>(in T data)
where T : NadekoInteractionData
{
iData = data;
return this;
}
// public NadekoOwnInteractionBuiler WithIsOwn(bool isOwn = true)
// {
// this.isOwn = isOwn;
// return this;
// }
public NadekoInteractionBuilder WithAction(in Func<SocketMessageComponent, Task> fn)
{
this.action = fn;
return this;
}
public NadekoButtonActionInteraction Build(DiscordSocketClient client, ulong userId)
{
if (iData is null)
throw new InvalidOperationException("You have to specify the data before building the interaction");
if (action is null)
throw new InvalidOperationException("You have to specify the action before building the interaction");
return new(client, userId, iData, action);
}
}

View File

@@ -1,20 +0,0 @@
namespace NadekoBot;
public class NadekoInteractionService : INadekoInteractionService, INService
{
private readonly DiscordSocketClient _client;
public NadekoInteractionService(DiscordSocketClient client)
{
_client = client;
}
public NadekoInteraction Create<T>(
ulong userId,
SimpleInteraction<T> inter)
=> new NadekoInteraction(_client,
userId,
inter.Button,
inter.TriggerAsync,
onlyAuthor: true);
}

View File

@@ -0,0 +1,15 @@
namespace NadekoBot;
/// <summary>
/// Interaction which only the author can use
/// </summary>
public abstract class NadekoButtonOwnInteraction : NadekoButtonInteraction
{
protected readonly ulong _authorId;
protected NadekoButtonOwnInteraction(DiscordSocketClient client, ulong authorId) : base(client)
=> _authorId = authorId;
protected override ValueTask<bool> Validate(SocketMessageComponent smc)
=> new(smc.User.Id == _authorId);
}

View File

@@ -5,11 +5,9 @@ public sealed class DmContextAdapter : DmContext
public override IMedusaStrings Strings { get; } public override IMedusaStrings Strings { get; }
public override IDMChannel Channel { get; } public override IDMChannel Channel { get; }
public override IUserMessage Message { get; } public override IUserMessage Message { get; }
public override ISelfUser Bot { get; }
public override IUser User public override IUser User
=> Message.Author; => Message.Author;
private readonly IServiceProvider _services; private readonly IServiceProvider _services;
private readonly Lazy<IEmbedBuilderService> _ebs; private readonly Lazy<IEmbedBuilderService> _ebs;
private readonly Lazy<IBotStrings> _botStrings; private readonly Lazy<IBotStrings> _botStrings;
@@ -28,7 +26,6 @@ public sealed class DmContextAdapter : DmContext
Channel = ch; Channel = ch;
Message = ctx.Message; Message = ctx.Message;
Bot = ctx.Client.CurrentUser;
_ebs = new(_services.GetRequiredService<IEmbedBuilderService>()); _ebs = new(_services.GetRequiredService<IEmbedBuilderService>());

View File

@@ -1,31 +0,0 @@
namespace Nadeko.Medusa.Adapters;
public class FilterAdapter : PreconditionAttribute
{
private readonly FilterAttribute _filterAttribute;
private readonly IMedusaStrings _strings;
public FilterAdapter(FilterAttribute filterAttribute,
IMedusaStrings strings)
{
_filterAttribute = filterAttribute;
_strings = strings;
}
public override async Task<PreconditionResult> CheckPermissionsAsync(
ICommandContext context,
CommandInfo command,
IServiceProvider services)
{
var medusaContext = ContextAdapterFactory.CreateNew(context,
_strings,
services);
var result = await _filterAttribute.CheckAsync(medusaContext);
if (!result)
return PreconditionResult.FromError($"Precondition '{_filterAttribute.GetType().Name}' failed.");
return PreconditionResult.FromSuccess();
}
}

View File

@@ -11,7 +11,6 @@ public sealed class GuildContextAdapter : GuildContext
public override IMedusaStrings Strings { get; } public override IMedusaStrings Strings { get; }
public override IGuild Guild { get; } public override IGuild Guild { get; }
public override ITextChannel Channel { get; } public override ITextChannel Channel { get; }
public override ISelfUser Bot { get; }
public override IUserMessage Message public override IUserMessage Message
=> _ctx.Message; => _ctx.Message;
@@ -29,7 +28,6 @@ public sealed class GuildContextAdapter : GuildContext
Strings = strings; Strings = strings;
User = (IGuildUser)ctx.User; User = (IGuildUser)ctx.User;
Bot = ctx.Client.CurrentUser;
_services = services; _services = services;
_ebs = new(_services.GetRequiredService<IEmbedBuilderService>()); _ebs = new(_services.GetRequiredService<IEmbedBuilderService>());

View File

@@ -22,6 +22,8 @@ public sealed class MedusaConfigService : ConfigServiceBase<MedusaConfig>, IMedu
public void AddLoadedMedusa(string name) public void AddLoadedMedusa(string name)
{ {
name = name.Trim().ToLowerInvariant();
ModifyConfig(conf => ModifyConfig(conf =>
{ {
if (conf.Loaded is null) if (conf.Loaded is null)
@@ -34,6 +36,8 @@ public sealed class MedusaConfigService : ConfigServiceBase<MedusaConfig>, IMedu
public void RemoveLoadedMedusa(string name) public void RemoveLoadedMedusa(string name)
{ {
name = name.Trim().ToLowerInvariant();
ModifyConfig(conf => ModifyConfig(conf =>
{ {
if (conf.Loaded is null) if (conf.Loaded is null)

View File

@@ -1,6 +1,5 @@
using Discord.Commands.Builders; using Discord.Commands.Builders;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Nadeko.Medusa.Adapters;
using NadekoBot.Common.ModuleBehaviors; using NadekoBot.Common.ModuleBehaviors;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
@@ -187,6 +186,7 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
return MedusaLoadResult.AlreadyLoaded; return MedusaLoadResult.AlreadyLoaded;
var safeName = Uri.EscapeDataString(name); var safeName = Uri.EscapeDataString(name);
name = name.ToLowerInvariant();
await _lock.WaitAsync(); await _lock.WaitAsync();
try try
@@ -383,11 +383,6 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
{ {
var m = mb.WithName(snekInfo.Name); var m = mb.WithName(snekInfo.Name);
foreach (var f in snekInfo.Filters)
{
m.AddPrecondition(new FilterAdapter(f, strings));
}
foreach (var cmd in snekInfo.Commands) foreach (var cmd in snekInfo.Commands)
{ {
m.AddCommand(cmd.Aliases.First(), m.AddCommand(cmd.Aliases.First(),
@@ -396,7 +391,7 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
new(cmd), new(cmd),
new(medusaServices), new(medusaServices),
strings), strings),
CreateCommandFactory(medusaName, cmd, strings)); CreateCommandFactory(medusaName, cmd));
} }
foreach (var subInfo in snekInfo.Subsneks) foreach (var subInfo in snekInfo.Subsneks)
@@ -405,7 +400,7 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
private static readonly RequireContextAttribute _reqGuild = new RequireContextAttribute(ContextType.Guild); private static readonly RequireContextAttribute _reqGuild = new RequireContextAttribute(ContextType.Guild);
private static readonly RequireContextAttribute _reqDm = new RequireContextAttribute(ContextType.DM); private static readonly RequireContextAttribute _reqDm = new RequireContextAttribute(ContextType.DM);
private Action<CommandBuilder> CreateCommandFactory(string medusaName, SnekCommandData cmd, IMedusaStrings strings) private Action<CommandBuilder> CreateCommandFactory(string medusaName, SnekCommandData cmd)
=> (cb) => => (cb) =>
{ {
cb.AddAliases(cmd.Aliases.Skip(1).ToArray()); cb.AddAliases(cmd.Aliases.Skip(1).ToArray());
@@ -415,31 +410,6 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
else if (cmd.ContextType == CommandContextType.Dm) else if (cmd.ContextType == CommandContextType.Dm)
cb.AddPrecondition(_reqDm); cb.AddPrecondition(_reqDm);
foreach (var f in cmd.Filters)
cb.AddPrecondition(new FilterAdapter(f, strings));
foreach (var ubp in cmd.UserAndBotPerms)
{
if (ubp is user_permAttribute up)
{
if (up.GuildPerm is { } gp)
cb.AddPrecondition(new UserPermAttribute(gp));
else if (up.ChannelPerm is { } cp)
cb.AddPrecondition(new UserPermAttribute(cp));
}
else if (ubp is bot_permAttribute bp)
{
if (bp.GuildPerm is { } gp)
cb.AddPrecondition(new BotPermAttribute(gp));
else if (bp.ChannelPerm is { } cp)
cb.AddPrecondition(new BotPermAttribute(cp));
}
else if (ubp is bot_owner_onlyAttribute)
{
cb.AddPrecondition(new OwnerOnlyAttribute());
}
}
cb.WithPriority(cmd.Priority); cb.WithPriority(cmd.Priority);
// using summary to save method name // using summary to save method name
@@ -459,9 +429,6 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
pb.WithIsMultiple(paramData.IsParams) pb.WithIsMultiple(paramData.IsParams)
.WithIsOptional(paramData.IsOptional) .WithIsOptional(paramData.IsOptional)
.WithIsRemainder(paramData.IsLeftover); .WithIsRemainder(paramData.IsLeftover);
if (paramData.IsOptional)
pb.WithDefault(paramData.DefaultValue);
}; };
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
@@ -558,6 +525,7 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
private async Task<MedusaUnloadResult> InternalUnloadAsync(string name) private async Task<MedusaUnloadResult> InternalUnloadAsync(string name)
{ {
name = name.ToLowerInvariant();
if (!_resolved.Remove(name, out var lsi)) if (!_resolved.Remove(name, out var lsi))
return MedusaUnloadResult.NotLoaded; return MedusaUnloadResult.NotLoaded;
@@ -784,10 +752,8 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
var cmds = new List<SnekCommandData>(); var cmds = new List<SnekCommandData>();
foreach (var method in methodInfos) foreach (var method in methodInfos)
{ {
var filters = method.GetCustomAttributes<FilterAttribute>(true).ToArray(); var filters = method.GetCustomAttributes<FilterAttribute>().ToArray();
var userAndBotPerms = method.GetCustomAttributes<MedusaPermAttribute>(true) var prio = method.GetCustomAttribute<prioAttribute>()?.Priority ?? 0;
.ToArray();
var prio = method.GetCustomAttribute<prioAttribute>(true)?.Priority ?? 0;
var paramInfos = method.GetParameters(); var paramInfos = method.GetParameters();
var cmdParams = new List<ParamData>(); var cmdParams = new List<ParamData>();
@@ -803,7 +769,6 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
var leftoverAttribute = pi.GetCustomAttribute<leftoverAttribute>(true); var leftoverAttribute = pi.GetCustomAttribute<leftoverAttribute>(true);
var hasDefaultValue = pi.HasDefaultValue; var hasDefaultValue = pi.HasDefaultValue;
var defaultValue = pi.DefaultValue;
var isLeftover = leftoverAttribute != null; var isLeftover = leftoverAttribute != null;
var isParams = pi.GetCustomAttribute<ParamArrayAttribute>() is not null; var isParams = pi.GetCustomAttribute<ParamArrayAttribute>() is not null;
var paramType = pi.ParameterType; var paramType = pi.ParameterType;
@@ -861,11 +826,11 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
throw new ArgumentException("Leftover attribute error."); throw new ArgumentException("Leftover attribute error.");
} }
cmdParams.Add(new ParamData(paramType, paramName, hasDefaultValue, defaultValue, isLeftover, isParams)); cmdParams.Add(new ParamData(paramType, paramName, hasDefaultValue, isLeftover, isParams));
} }
var cmdAttribute = method.GetCustomAttribute<cmdAttribute>(true)!; var cmdAttribute = method.GetCustomAttribute<cmdAttribute>()!;
var aliases = cmdAttribute.Aliases; var aliases = cmdAttribute.Aliases;
if (aliases.Length == 0) if (aliases.Length == 0)
aliases = new[] { method.Name.ToLowerInvariant() }; aliases = new[] { method.Name.ToLowerInvariant() };
@@ -875,7 +840,6 @@ public sealed class MedusaLoaderService : IMedusaLoaderService, IReadyExecutor,
method, method,
instance, instance,
filters, filters,
userAndBotPerms,
cmdContext, cmdContext,
diParams, diParams,
cmdParams, cmdParams,

View File

@@ -4,7 +4,6 @@ public sealed record ParamData(
Type Type, Type Type,
string Name, string Name,
bool IsOptional, bool IsOptional,
object? DefaultValue,
bool IsLeftover, bool IsLeftover,
bool IsParams bool IsParams
); );

View File

@@ -11,7 +11,6 @@ public sealed class SnekCommandData
MethodInfo methodInfo, MethodInfo methodInfo,
Snek module, Snek module,
FilterAttribute[] filters, FilterAttribute[] filters,
MedusaPermAttribute[] userAndBotPerms,
CommandContextType contextType, CommandContextType contextType,
IReadOnlyList<Type> injectedParams, IReadOnlyList<Type> injectedParams,
IReadOnlyList<ParamData> parameters, IReadOnlyList<ParamData> parameters,
@@ -22,7 +21,6 @@ public sealed class SnekCommandData
MethodInfo = methodInfo; MethodInfo = methodInfo;
Module = module; Module = module;
Filters = filters; Filters = filters;
UserAndBotPerms = userAndBotPerms;
ContextType = contextType; ContextType = contextType;
InjectedParams = injectedParams; InjectedParams = injectedParams;
Parameters = parameters; Parameters = parameters;
@@ -30,8 +28,6 @@ public sealed class SnekCommandData
OptionalStrings = strings; OptionalStrings = strings;
} }
public MedusaPermAttribute[] UserAndBotPerms { get; set; }
public CommandStrings OptionalStrings { get; set; } public CommandStrings OptionalStrings { get; set; }
public IReadOnlyCollection<string> Aliases { get; } public IReadOnlyCollection<string> Aliases { get; }

View File

@@ -0,0 +1,26 @@
namespace NadekoBot.Common;
public abstract class NInteraction
{
private readonly DiscordSocketClient _client;
private readonly ulong _userId;
private readonly Func<SocketMessageComponent, Task> _action;
protected abstract NadekoInteractionData Data { get; }
public NInteraction(
DiscordSocketClient client,
ulong userId,
Func<SocketMessageComponent, Task> action)
{
_client = client;
_userId = userId;
_action = action;
}
public NadekoButtonInteraction GetInteraction()
=> new NadekoInteractionBuilder()
.WithData(Data)
.WithAction(_action)
.Build(_client, _userId);
}

View File

@@ -18,7 +18,6 @@ public abstract class NadekoModule : ModuleBase
public CommandHandler _cmdHandler { get; set; } public CommandHandler _cmdHandler { get; set; }
public ILocalization _localization { get; set; } public ILocalization _localization { get; set; }
public IEmbedBuilderService _eb { get; set; } public IEmbedBuilderService _eb { get; set; }
public INadekoInteractionService _inter { get; set; }
protected string prefix protected string prefix
=> _cmdHandler.GetPrefix(ctx.Guild); => _cmdHandler.GetPrefix(ctx.Guild);
@@ -37,7 +36,7 @@ public abstract class NadekoModule : ModuleBase
string error, string error,
string url = null, string url = null,
string footer = null, string footer = null,
NadekoInteraction inter = null) NadekoButtonInteraction inter = null)
=> ctx.Channel.SendErrorAsync(_eb, title, error, url, footer); => ctx.Channel.SendErrorAsync(_eb, title, error, url, footer);
public Task<IUserMessage> SendConfirmAsync( public Task<IUserMessage> SendConfirmAsync(
@@ -48,32 +47,32 @@ public abstract class NadekoModule : ModuleBase
=> ctx.Channel.SendConfirmAsync(_eb, title, text, url, footer); => ctx.Channel.SendConfirmAsync(_eb, title, text, url, footer);
// //
public Task<IUserMessage> SendErrorAsync(string text, NadekoInteraction inter = null) public Task<IUserMessage> SendErrorAsync(string text, NadekoButtonInteraction inter = null)
=> ctx.Channel.SendAsync(_eb, text, MessageType.Error, inter); => ctx.Channel.SendAsync(_eb, text, MessageType.Error, inter);
public Task<IUserMessage> SendConfirmAsync(string text, NadekoInteraction inter = null) public Task<IUserMessage> SendConfirmAsync(string text, NadekoButtonInteraction inter = null)
=> ctx.Channel.SendAsync(_eb, text, MessageType.Ok, inter); => ctx.Channel.SendAsync(_eb, text, MessageType.Ok, inter);
public Task<IUserMessage> SendPendingAsync(string text, NadekoInteraction inter = null) public Task<IUserMessage> SendPendingAsync(string text, NadekoButtonInteraction inter = null)
=> ctx.Channel.SendAsync(_eb, text, MessageType.Pending, inter); => ctx.Channel.SendAsync(_eb, text, MessageType.Pending, inter);
// localized normal // localized normal
public Task<IUserMessage> ErrorLocalizedAsync(LocStr str, NadekoInteraction inter = null) public Task<IUserMessage> ErrorLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
=> SendErrorAsync(GetText(str), inter); => SendErrorAsync(GetText(str), inter);
public Task<IUserMessage> PendingLocalizedAsync(LocStr str, NadekoInteraction inter = null) public Task<IUserMessage> PendingLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
=> SendPendingAsync(GetText(str), inter); => SendPendingAsync(GetText(str), inter);
public Task<IUserMessage> ConfirmLocalizedAsync(LocStr str, NadekoInteraction inter = null) public Task<IUserMessage> ConfirmLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
=> SendConfirmAsync(GetText(str), inter); => SendConfirmAsync(GetText(str), inter);
// localized replies // localized replies
public Task<IUserMessage> ReplyErrorLocalizedAsync(LocStr str, NadekoInteraction inter = null) public Task<IUserMessage> ReplyErrorLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
=> SendErrorAsync($"{Format.Bold(ctx.User.ToString())} {GetText(str)}", inter); => SendErrorAsync($"{Format.Bold(ctx.User.ToString())} {GetText(str)}", inter);
public Task<IUserMessage> ReplyPendingLocalizedAsync(LocStr str, NadekoInteraction inter = null) public Task<IUserMessage> ReplyPendingLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
=> SendPendingAsync($"{Format.Bold(ctx.User.ToString())} {GetText(str)}", inter); => SendPendingAsync($"{Format.Bold(ctx.User.ToString())} {GetText(str)}", inter);
public Task<IUserMessage> ReplyConfirmLocalizedAsync(LocStr str, NadekoInteraction inter = null) public Task<IUserMessage> ReplyConfirmLocalizedAsync(LocStr str, NadekoButtonInteraction inter = null)
=> SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} {GetText(str)}", inter); => SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} {GetText(str)}", inter);
public async Task<bool> PromptUserConfirmAsync(IEmbedBuilder embed) public async Task<bool> PromptUserConfirmAsync(IEmbedBuilder embed)

View File

@@ -1,14 +1,15 @@
using CommandLine; #nullable disable
using CommandLine;
namespace NadekoBot.Common; namespace NadekoBot.Common;
public static class OptionsParser public static class OptionsParser
{ {
public static T ParseFrom<T>(string[]? args) public static T ParseFrom<T>(string[] args)
where T : INadekoCommandOptions, new() where T : INadekoCommandOptions, new()
=> ParseFrom(new T(), args).Item1; => ParseFrom(new T(), args).Item1;
public static (T, bool) ParseFrom<T>(T options, string[]? args) public static (T, bool) ParseFrom<T>(T options, string[] args)
where T : INadekoCommandOptions where T : INadekoCommandOptions
{ {
using var p = new Parser(x => using var p = new Parser(x =>

View File

@@ -1,6 +1,5 @@
#nullable disable warnings #nullable disable warnings
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using System.Text.Json.Serialization;
namespace NadekoBot; namespace NadekoBot;
@@ -8,14 +7,14 @@ public sealed record SmartEmbedArrayElementText : SmartEmbedTextBase
{ {
public string Color { get; init; } = string.Empty; public string Color { get; init; } = string.Empty;
public SmartEmbedArrayElementText() public SmartEmbedArrayElementText() : base()
{ {
} }
public SmartEmbedArrayElementText(IEmbed eb) : base(eb) public SmartEmbedArrayElementText(IEmbed eb) : base(eb)
{ {
Color = eb.Color is { } c ? new Rgba32(c.R, c.G, c.B).ToHex() : string.Empty;
} }
protected override EmbedBuilder GetEmbedInternal() protected override EmbedBuilder GetEmbedInternal()
@@ -64,7 +63,6 @@ public abstract record SmartEmbedTextBase : SmartText
public SmartTextEmbedFooter Footer { get; init; } public SmartTextEmbedFooter Footer { get; init; }
public SmartTextEmbedField[] Fields { get; init; } public SmartTextEmbedField[] Fields { get; init; }
[JsonIgnore]
public bool IsValid public bool IsValid
=> !string.IsNullOrWhiteSpace(Title) => !string.IsNullOrWhiteSpace(Title)
|| !string.IsNullOrWhiteSpace(Description) || !string.IsNullOrWhiteSpace(Description)

View File

@@ -1,6 +1,4 @@
#nullable disable #nullable disable
using System.Text.Json.Serialization;
namespace NadekoBot; namespace NadekoBot;
public sealed record SmartEmbedTextArray : SmartText public sealed record SmartEmbedTextArray : SmartText
@@ -8,7 +6,6 @@ public sealed record SmartEmbedTextArray : SmartText
public string Content { get; set; } public string Content { get; set; }
public SmartEmbedArrayElementText[] Embeds { get; set; } public SmartEmbedArrayElementText[] Embeds { get; set; }
[JsonIgnore]
public bool IsValid public bool IsValid
=> Embeds?.All(x => x.IsValid) ?? false; => Embeds?.All(x => x.IsValid) ?? false;

View File

@@ -1,20 +1,16 @@
#nullable disable #nullable disable
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System.Text.Json.Serialization;
namespace NadekoBot; namespace NadekoBot;
public abstract record SmartText public abstract record SmartText
{ {
[JsonIgnore]
public bool IsEmbed public bool IsEmbed
=> this is SmartEmbedText; => this is SmartEmbedText;
[JsonIgnore]
public bool IsPlainText public bool IsPlainText
=> this is SmartPlainText; => this is SmartPlainText;
[JsonIgnore]
public bool IsEmbedArray public bool IsEmbedArray
=> this is SmartEmbedTextArray; => this is SmartEmbedTextArray;

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Text.Json.Serialization;
namespace NadekoBot; namespace NadekoBot;
@@ -9,7 +8,6 @@ public class SmartTextEmbedAuthor
public string Name { get; set; } public string Name { get; set; }
[JsonProperty("icon_url")] [JsonProperty("icon_url")]
[JsonPropertyName("icon_url")]
public string IconUrl { get; set; } public string IconUrl { get; set; }
public string Url { get; set; } public string Url { get; set; }

View File

@@ -1,6 +1,5 @@
#nullable disable #nullable disable
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Text.Json.Serialization;
namespace NadekoBot; namespace NadekoBot;
@@ -9,6 +8,5 @@ public class SmartTextEmbedFooter
public string Text { get; set; } public string Text { get; set; }
[JsonProperty("icon_url")] [JsonProperty("icon_url")]
[JsonPropertyName("icon_url")]
public string IconUrl { get; set; } public string IconUrl { get; set; }
} }

View File

@@ -46,7 +46,9 @@ public sealed class CommandOrExprTypeReader : NadekoTypeReader<CommandOrExprInfo
public override async ValueTask<TypeReaderResult<CommandOrExprInfo>> ReadAsync(ICommandContext ctx, string input) public override async ValueTask<TypeReaderResult<CommandOrExprInfo>> ReadAsync(ICommandContext ctx, string input)
{ {
if (_exprs.ExpressionExists(ctx.Guild?.Id, input)) input = input.ToUpperInvariant();
if (_exprs.ExpressionExists(ctx.Guild?.Id, input) || _exprs.ExpressionExists(null, input))
return TypeReaderResult.FromSuccess(new CommandOrExprInfo(input, CommandOrExprInfo.Type.Custom)); return TypeReaderResult.FromSuccess(new CommandOrExprInfo(input, CommandOrExprInfo.Type.Custom));
var cmd = await new CommandTypeReader(_commandHandler, _cmds).ReadAsync(ctx, input); var cmd = await new CommandTypeReader(_commandHandler, _cmds).ReadAsync(ctx, input);

View File

@@ -1,33 +0,0 @@
namespace NadekoBot.Common.TypeReaders;
public sealed class GuildUserTypeReader : NadekoTypeReader<IGuildUser>
{
public override async ValueTask<TypeReaderResult<IGuildUser>> ReadAsync(ICommandContext ctx, string input)
{
if (ctx.Guild is null)
return TypeReaderResult.FromError<IGuildUser>(CommandError.Unsuccessful, "Must be in a guild.");
input = input.Trim();
IGuildUser? user = null;
if (MentionUtils.TryParseUser(input, out var id))
user = await ctx.Guild.GetUserAsync(id, CacheMode.AllowDownload);
if (ulong.TryParse(input, out id))
user = await ctx.Guild.GetUserAsync(id, CacheMode.AllowDownload);
if (user is null)
{
var users = await ctx.Guild.GetUsersAsync(CacheMode.CacheOnly);
user = users.FirstOrDefault(x => x.Username == input)
?? users.FirstOrDefault(x =>
string.Equals(x.ToString(), input, StringComparison.InvariantCultureIgnoreCase))
?? users.FirstOrDefault(x =>
string.Equals(x.Username, input, StringComparison.InvariantCultureIgnoreCase));
}
if (user is null)
return TypeReaderResult.FromError<IGuildUser>(CommandError.ObjectNotFound, "User not found.");
return TypeReaderResult.FromSuccess(user);
}
}

View File

@@ -1,5 +1,4 @@
#nullable disable #nullable disable
using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
@@ -7,14 +6,12 @@ namespace NadekoBot.Db;
public static class CurrencyTransactionExtensions public static class CurrencyTransactionExtensions
{ {
public static Task<List<CurrencyTransaction>> GetPageFor( public static List<CurrencyTransaction> GetPageFor(this DbSet<CurrencyTransaction> set, ulong userId, int page)
this DbSet<CurrencyTransaction> set, => set.AsQueryable()
ulong userId, .AsNoTracking()
int page)
=> set.ToLinqToDBTable()
.Where(x => x.UserId == userId) .Where(x => x.UserId == userId)
.OrderByDescending(x => x.DateAdded) .OrderByDescending(x => x.DateAdded)
.Skip(15 * page) .Skip(15 * page)
.Take(15) .Take(15)
.ToListAsyncLinqToDB(); .ToList();
} }

View File

@@ -4,60 +4,11 @@ using LinqToDB.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using NadekoBot.Db.Models; using NadekoBot.Db.Models;
using NadekoBot.Services.Database; using NadekoBot.Services.Database;
using System.Collections.Immutable;
namespace NadekoBot.Db; namespace NadekoBot.Db;
public static class DiscordUserExtensions public static class DiscordUserExtensions
{ {
/// <summary>
/// Adds the specified <paramref name="users"/> to the database. If a database user with placeholder name
/// and discriminator is present in <paramref name="users"/>, their name and discriminator get updated accordingly.
/// </summary>
/// <param name="ctx">This database context.</param>
/// <param name="users">The users to add or update in the database.</param>
/// <returns>A tuple with the amount of new users added and old users updated.</returns>
public static async Task<(long UsersAdded, long UsersUpdated)> RefreshUsersAsync(this NadekoContext ctx, List<IUser> users)
{
var presentDbUsers = await ctx.DiscordUser
.Select(x => new { x.UserId, x.Username, x.Discriminator })
.Where(x => users.Select(y => y.Id).Contains(x.UserId))
.ToArrayAsyncEF();
var usersToAdd = users
.Where(x => !presentDbUsers.Select(x => x.UserId).Contains(x.Id))
.Select(x => new DiscordUser()
{
UserId = x.Id,
AvatarId = x.AvatarId,
Username = x.Username,
Discriminator = x.Discriminator
});
var added = (await ctx.BulkCopyAsync(usersToAdd)).RowsCopied;
var toUpdateUserIds = presentDbUsers
.Where(x => x.Username == "Unknown" && x.Discriminator == "????")
.Select(x => x.UserId)
.ToArray();
foreach (var user in users.Where(x => toUpdateUserIds.Contains(x.Id)))
{
await ctx.DiscordUser
.Where(x => x.UserId == user.Id)
.UpdateAsync(x => new DiscordUser()
{
Username = user.Username,
Discriminator = user.Discriminator,
// .award tends to set AvatarId and DateAdded to NULL, so account for that.
AvatarId = user.AvatarId,
DateAdded = x.DateAdded ?? DateTime.UtcNow
});
}
return (added, toUpdateUserIds.Length);
}
public static Task<DiscordUser> GetByUserIdAsync( public static Task<DiscordUser> GetByUserIdAsync(
this IQueryable<DiscordUser> set, this IQueryable<DiscordUser> set,
ulong userId) ulong userId)

View File

@@ -12,4 +12,10 @@ public static class NadekoExpressionExtensions
public static IEnumerable<NadekoExpression> ForId(this DbSet<NadekoExpression> exprs, ulong id) public static IEnumerable<NadekoExpression> ForId(this DbSet<NadekoExpression> exprs, ulong id)
=> exprs.AsNoTracking().AsQueryable().Where(x => x.GuildId == id).ToList(); => exprs.AsNoTracking().AsQueryable().Where(x => x.GuildId == id).ToList();
public static NadekoExpression GetByGuildIdAndInput(
this DbSet<NadekoExpression> exprs,
ulong? guildId,
string input)
=> exprs.FirstOrDefault(x => x.GuildId == guildId && x.Trigger.ToUpper() == input);
} }

View File

@@ -10,7 +10,6 @@ namespace NadekoBot.Db;
public class WaifuInfoStats public class WaifuInfoStats
{ {
public int WaifuId { get; init; }
public string FullName { get; init; } public string FullName { get; init; }
public long Price { get; init; } public long Price { get; init; }
public string ClaimerName { get; init; } public string ClaimerName { get; init; }
@@ -18,6 +17,9 @@ public class WaifuInfoStats
public int AffinityCount { get; init; } public int AffinityCount { get; init; }
public int DivorceCount { get; init; } public int DivorceCount { get; init; }
public int ClaimCount { get; init; } public int ClaimCount { get; init; }
public List<WaifuItem> Items { get; init; }
public List<string> Claims { get; init; }
public List<string> Fans { get; init; }
} }
public static class WaifuExtensions public static class WaifuExtensions
@@ -101,7 +103,6 @@ public static class WaifuExtensions
.FirstOrDefault()) .FirstOrDefault())
.Select(w => new WaifuInfoStats .Select(w => new WaifuInfoStats
{ {
WaifuId = w.WaifuId,
FullName = FullName =
ctx.Set<DiscordUser>() ctx.Set<DiscordUser>()
.AsQueryable() .AsQueryable()
@@ -134,6 +135,17 @@ public static class WaifuExtensions
&& x.NewId == null && x.NewId == null
&& x.UpdateType == WaifuUpdateType.Claimed), && x.UpdateType == WaifuUpdateType.Claimed),
Price = w.Price, Price = w.Price,
Claims = ctx.WaifuInfo.AsQueryable()
.Include(x => x.Waifu)
.Where(x => x.ClaimerId == w.WaifuId)
.Select(x => x.Waifu.Username + "#" + x.Waifu.Discriminator)
.ToList(),
Fans = ctx.WaifuInfo.AsQueryable()
.Include(x => x.Waifu)
.Where(x => x.AffinityId == w.WaifuId)
.Select(x => x.Waifu.Username + "#" + x.Waifu.Discriminator)
.ToList(),
Items = w.Items
}) })
.FirstOrDefault(); .FirstOrDefault();

View File

@@ -49,8 +49,7 @@ public enum PunishmentAction
ChatMute, ChatMute,
VoiceMute, VoiceMute,
AddRole, AddRole,
Warn, Warn
TimeOut
} }
public class AntiSpamIgnore : DbEntity public class AntiSpamIgnore : DbEntity

View File

@@ -1,9 +0,0 @@
using NadekoBot.Services.Database.Models;
namespace NadekoBot.Db.Models;
public class AutoPublishChannel : DbEntity
{
public ulong GuildId { get; set; }
public ulong ChannelId { get; set; }
}

View File

@@ -5,5 +5,4 @@ public class BanTemplate : DbEntity
{ {
public ulong GuildId { get; set; } public ulong GuildId { get; set; }
public string Text { get; set; } public string Text { get; set; }
public int? PruneDays { get; set; }
} }

View File

@@ -17,6 +17,8 @@ public class DiscordUser : DbEntity
public bool IsClubAdmin { get; set; } public bool IsClubAdmin { get; set; }
public long TotalXp { get; set; } public long TotalXp { get; set; }
public DateTime LastLevelUp { get; set; } = DateTime.UtcNow;
public DateTime LastXpGain { get; set; } = DateTime.MinValue;
public XpNotificationLocation NotifyOnLevelUp { get; set; } public XpNotificationLocation NotifyOnLevelUp { get; set; }
public long CurrencyAmount { get; set; } public long CurrencyAmount { get; set; }
@@ -28,10 +30,5 @@ public class DiscordUser : DbEntity
=> UserId.GetHashCode(); => UserId.GetHashCode();
public override string ToString() public override string ToString()
{ => Username + "#" + Discriminator;
if (string.IsNullOrWhiteSpace(Discriminator) || Discriminator == "0000")
return Username;
return Username + "#" + Discriminator;
}
} }

View File

@@ -9,8 +9,6 @@ public class FeedSub : DbEntity
public ulong ChannelId { get; set; } public ulong ChannelId { get; set; }
public string Url { get; set; } public string Url { get; set; }
public string Message { get; set; }
public override int GetHashCode() public override int GetHashCode()
=> Url.GetHashCode(StringComparison.InvariantCulture) ^ GuildConfigId.GetHashCode(); => Url.GetHashCode(StringComparison.InvariantCulture) ^ GuildConfigId.GetHashCode();

View File

@@ -1,9 +0,0 @@
#nullable disable
namespace NadekoBot.Services.Database.Models;
public class GamblingStats : DbEntity
{
public string Feature { get; set; }
public decimal Bet { get; set; }
public decimal PaidOut { get; set; }
}

View File

@@ -95,8 +95,6 @@ public class GuildConfig : DbEntity
public int WarnExpireHours { get; set; } public int WarnExpireHours { get; set; }
public WarnExpireAction WarnExpireAction { get; set; } = WarnExpireAction.Clear; public WarnExpireAction WarnExpireAction { get; set; } = WarnExpireAction.Clear;
public bool DisableGlobalExpressions { get; set; } = false;
#region Boost Message #region Boost Message
public bool SendBoostMessage { get; set; } public bool SendBoostMessage { get; set; }

View File

@@ -20,10 +20,6 @@ public class LogSetting : DbEntity
public ulong? ChannelDestroyedId { get; set; } public ulong? ChannelDestroyedId { get; set; }
public ulong? ChannelUpdatedId { get; set; } public ulong? ChannelUpdatedId { get; set; }
public ulong? ThreadDeletedId { get; set; }
public ulong? ThreadCreatedId { get; set; }
public ulong? UserMutedId { get; set; } public ulong? UserMutedId { get; set; }
//userpresence //userpresence

View File

@@ -24,7 +24,6 @@ public class ShopEntry : DbEntity, IIndexed
//list //list
public HashSet<ShopEntryItem> Items { get; set; } = new(); public HashSet<ShopEntryItem> Items { get; set; } = new();
public ulong? RoleRequirement { get; set; }
} }
public class ShopEntryItem : DbEntity public class ShopEntryItem : DbEntity

View File

@@ -8,6 +8,7 @@ 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 DateTime LastLevelUp { get; set; } = DateTime.UtcNow;
} }
public enum XpNotificationLocation { None, Dm, Channel } public enum XpNotificationLocation { None, Dm, Channel }

View File

@@ -19,25 +19,25 @@ public class WaifuInfo : DbEntity
public override string ToString() public override string ToString()
{ {
var claimer = "no one";
var status = string.Empty; var status = string.Empty;
var waifuUsername = Waifu.ToString().TrimTo(20); var waifuUsername = Waifu.Username.TrimTo(20);
var claimer = Claimer?.ToString().TrimTo(20) var claimerUsername = Claimer?.Username.TrimTo(20);
?? "no one";
var affinity = Affinity?.ToString().TrimTo(20);
if (ClaimerId is not null)
claimer = $"{claimerUsername}#{Claimer.Discriminator}";
if (AffinityId is null) if (AffinityId is null)
status = $"... but {waifuUsername}'s heart is empty"; status = $"... but {waifuUsername}'s heart is empty";
else if (AffinityId == ClaimerId) else if (AffinityId == ClaimerId)
status = $"... and {waifuUsername} likes {claimer} too <3"; status = $"... and {waifuUsername} likes {claimerUsername} too <3";
else else
{ {
status = status =
$"... but {waifuUsername}'s heart belongs to {affinity}"; $"... but {waifuUsername}'s heart belongs to {Affinity.Username.TrimTo(20)}#{Affinity.Discriminator}";
} }
return $"**{waifuUsername}** - claimed by **{claimer}**\n\t{status}"; return $"**{waifuUsername}#{Waifu.Discriminator}** - claimed by **{claimer}**\n\t{status}";
} }
} }

View File

@@ -13,6 +13,6 @@ public class XpShopOwnedItem : DbEntity
public enum XpShopItemType public enum XpShopItemType
{ {
Background = 0, Background,
Frame = 1, Frame,
} }

View File

@@ -10,6 +10,10 @@ public sealed class MysqlContext : NadekoContext
protected override string CurrencyTransactionOtherIdDefaultValue protected override string CurrencyTransactionOtherIdDefaultValue
=> "NULL"; => "NULL";
protected override string DiscordUserLastXpGainDefaultValue
=> "(UTC_TIMESTAMP - INTERVAL 1 year)";
protected override string LastLevelUpDefaultValue
=> "(UTC_TIMESTAMP)";
public MysqlContext(string connStr = "Server=localhost", string version = "8.0") public MysqlContext(string connStr = "Server=localhost", string version = "8.0")
{ {

View File

@@ -65,6 +65,8 @@ public abstract class NadekoContext : DbContext
#region Mandatory Provider-Specific Values #region Mandatory Provider-Specific Values
protected abstract string CurrencyTransactionOtherIdDefaultValue { get; } protected abstract string CurrencyTransactionOtherIdDefaultValue { get; }
protected abstract string DiscordUserLastXpGainDefaultValue { get; }
protected abstract string LastLevelUpDefaultValue { get; }
#endregion #endregion
@@ -164,6 +166,12 @@ public abstract class NadekoContext : DbContext
du.Property(x => x.NotifyOnLevelUp) du.Property(x => x.NotifyOnLevelUp)
.HasDefaultValue(XpNotificationLocation.None); .HasDefaultValue(XpNotificationLocation.None);
du.Property(x => x.LastXpGain)
.HasDefaultValueSql(DiscordUserLastXpGainDefaultValue);
du.Property(x => x.LastLevelUp)
.HasDefaultValueSql(LastLevelUpDefaultValue);
du.Property(x => x.TotalXp) du.Property(x => x.TotalXp)
.HasDefaultValue(0); .HasDefaultValue(0);
@@ -205,6 +213,9 @@ public abstract class NadekoContext : DbContext
}) })
.IsUnique(); .IsUnique();
xps.Property(x => x.LastLevelUp)
.HasDefaultValueSql(LastLevelUpDefaultValue);
xps.HasIndex(x => x.UserId); xps.HasIndex(x => x.UserId);
xps.HasIndex(x => x.GuildId); xps.HasIndex(x => x.GuildId);
xps.HasIndex(x => x.Xp); xps.HasIndex(x => x.Xp);
@@ -330,10 +341,6 @@ public abstract class NadekoContext : DbContext
#region BanTemplate #region BanTemplate
modelBuilder.Entity<BanTemplate>().HasIndex(x => x.GuildId).IsUnique(); modelBuilder.Entity<BanTemplate>().HasIndex(x => x.GuildId).IsUnique();
modelBuilder.Entity<BanTemplate>()
.Property(x => x.PruneDays)
.HasDefaultValue(null)
.IsRequired(false);
#endregion #endregion
@@ -464,22 +471,6 @@ public abstract class NadekoContext : DbContext
}); });
#endregion #endregion
#region AutoPublish
modelBuilder.Entity<AutoPublishChannel>(apc => apc
.HasIndex(x => x.GuildId)
.IsUnique());
#endregion
#region GamblingStats
modelBuilder.Entity<GamblingStats>(gs => gs
.HasIndex(x => x.Feature)
.IsUnique());
#endregion
} }
#if DEBUG #if DEBUG

View File

@@ -8,6 +8,10 @@ public sealed class PostgreSqlContext : NadekoContext
protected override string CurrencyTransactionOtherIdDefaultValue protected override string CurrencyTransactionOtherIdDefaultValue
=> "NULL"; => "NULL";
protected override string DiscordUserLastXpGainDefaultValue
=> "timezone('utc', now()) - interval '-1 year'";
protected override string LastLevelUpDefaultValue
=> "timezone('utc', now())";
public PostgreSqlContext(string connStr = "Host=localhost") public PostgreSqlContext(string connStr = "Host=localhost")
{ {

View File

@@ -9,6 +9,10 @@ public sealed class SqliteContext : NadekoContext
protected override string CurrencyTransactionOtherIdDefaultValue protected override string CurrencyTransactionOtherIdDefaultValue
=> "NULL"; => "NULL";
protected override string DiscordUserLastXpGainDefaultValue
=> "datetime('now', '-1 years')";
protected override string LastLevelUpDefaultValue
=> "datetime('now')";
public SqliteContext(string connectionString = "Data Source=data/NadekoBot.db", int commandTimeout = 60) public SqliteContext(string connectionString = "Data Source=data/NadekoBot.db", int commandTimeout = 60)
{ {

View File

@@ -19,35 +19,6 @@ namespace NadekoBot.Migrations.Mysql
.HasAnnotation("ProductVersion", "6.0.7") .HasAnnotation("ProductVersion", "6.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 64); .HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("NadekoBot.Db.Models.AutoPublishChannel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasColumnName("id");
b.Property<ulong>("ChannelId")
.HasColumnType("bigint unsigned")
.HasColumnName("channelid");
b.Property<DateTime?>("DateAdded")
.HasColumnType("datetime(6)")
.HasColumnName("dateadded");
b.Property<ulong>("GuildId")
.HasColumnType("bigint unsigned")
.HasColumnName("guildid");
b.HasKey("Id")
.HasName("pk_autopublishchannel");
b.HasIndex("GuildId")
.IsUnique()
.HasDatabaseName("ix_autopublishchannel_guildid");
b.ToTable("autopublishchannel", (string)null);
});
modelBuilder.Entity("NadekoBot.Db.Models.BankUser", b => modelBuilder.Entity("NadekoBot.Db.Models.BankUser", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -197,6 +168,18 @@ namespace NadekoBot.Migrations.Mysql
.HasDefaultValue(false) .HasDefaultValue(false)
.HasColumnName("isclubadmin"); .HasColumnName("isclubadmin");
b.Property<DateTime>("LastLevelUp")
.ValueGeneratedOnAdd()
.HasColumnType("datetime(6)")
.HasColumnName("lastlevelup")
.HasDefaultValueSql("(UTC_TIMESTAMP)");
b.Property<DateTime>("LastXpGain")
.ValueGeneratedOnAdd()
.HasColumnType("datetime(6)")
.HasColumnName("lastxpgain")
.HasDefaultValueSql("(UTC_TIMESTAMP - INTERVAL 1 year)");
b.Property<int>("NotifyOnLevelUp") b.Property<int>("NotifyOnLevelUp")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int") .HasColumnType("int")
@@ -704,10 +687,6 @@ namespace NadekoBot.Migrations.Mysql
.HasColumnType("bigint unsigned") .HasColumnType("bigint unsigned")
.HasColumnName("guildid"); .HasColumnName("guildid");
b.Property<int?>("PruneDays")
.HasColumnType("int")
.HasColumnName("prunedays");
b.Property<string>("Text") b.Property<string>("Text")
.HasColumnType("longtext") .HasColumnType("longtext")
.HasColumnName("text"); .HasColumnName("text");
@@ -975,10 +954,6 @@ namespace NadekoBot.Migrations.Mysql
.HasColumnType("int") .HasColumnType("int")
.HasColumnName("guildconfigid"); .HasColumnName("guildconfigid");
b.Property<string>("Message")
.HasColumnType("longtext")
.HasColumnName("message");
b.Property<string>("Url") b.Property<string>("Url")
.IsRequired() .IsRequired()
.HasColumnType("varchar(255)") .HasColumnType("varchar(255)")
@@ -1105,39 +1080,6 @@ namespace NadekoBot.Migrations.Mysql
b.ToTable("filterwordschannelid", (string)null); b.ToTable("filterwordschannelid", (string)null);
}); });
modelBuilder.Entity("NadekoBot.Services.Database.Models.GamblingStats", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasColumnName("id");
b.Property<decimal>("Bet")
.HasColumnType("decimal(65,30)")
.HasColumnName("bet");
b.Property<DateTime?>("DateAdded")
.HasColumnType("datetime(6)")
.HasColumnName("dateadded");
b.Property<string>("Feature")
.HasColumnType("varchar(255)")
.HasColumnName("feature");
b.Property<decimal>("PaidOut")
.HasColumnType("decimal(65,30)")
.HasColumnName("paidout");
b.HasKey("Id")
.HasName("pk_gamblingstats");
b.HasIndex("Feature")
.IsUnique()
.HasDatabaseName("ix_gamblingstats_feature");
b.ToTable("gamblingstats", (string)null);
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b => modelBuilder.Entity("NadekoBot.Services.Database.Models.GCChannelId", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -1262,10 +1204,6 @@ namespace NadekoBot.Migrations.Mysql
.HasColumnType("tinyint(1)") .HasColumnType("tinyint(1)")
.HasColumnName("deletestreamonlinemessage"); .HasColumnName("deletestreamonlinemessage");
b.Property<bool>("DisableGlobalExpressions")
.HasColumnType("tinyint(1)")
.HasColumnName("disableglobalexpressions");
b.Property<string>("DmGreetMessageText") b.Property<string>("DmGreetMessageText")
.HasColumnType("longtext") .HasColumnType("longtext")
.HasColumnName("dmgreetmessagetext"); .HasColumnName("dmgreetmessagetext");
@@ -1522,14 +1460,6 @@ namespace NadekoBot.Migrations.Mysql
.HasColumnType("bigint unsigned") .HasColumnType("bigint unsigned")
.HasColumnName("messageupdatedid"); .HasColumnName("messageupdatedid");
b.Property<ulong?>("ThreadCreatedId")
.HasColumnType("bigint unsigned")
.HasColumnName("threadcreatedid");
b.Property<ulong?>("ThreadDeletedId")
.HasColumnType("bigint unsigned")
.HasColumnName("threaddeletedid");
b.Property<ulong?>("UserBannedId") b.Property<ulong?>("UserBannedId")
.HasColumnType("bigint unsigned") .HasColumnType("bigint unsigned")
.HasColumnName("userbannedid"); .HasColumnName("userbannedid");
@@ -2314,10 +2244,6 @@ namespace NadekoBot.Migrations.Mysql
.HasColumnType("longtext") .HasColumnType("longtext")
.HasColumnName("rolename"); .HasColumnName("rolename");
b.Property<ulong?>("RoleRequirement")
.HasColumnType("bigint unsigned")
.HasColumnName("rolerequirement");
b.Property<int>("Type") b.Property<int>("Type")
.HasColumnType("int") .HasColumnType("int")
.HasColumnName("type"); .HasColumnName("type");
@@ -2639,6 +2565,12 @@ namespace NadekoBot.Migrations.Mysql
.HasColumnType("bigint unsigned") .HasColumnType("bigint unsigned")
.HasColumnName("guildid"); .HasColumnName("guildid");
b.Property<DateTime>("LastLevelUp")
.ValueGeneratedOnAdd()
.HasColumnType("datetime(6)")
.HasColumnName("lastlevelup")
.HasDefaultValueSql("(UTC_TIMESTAMP)");
b.Property<int>("NotifyOnLevelUp") b.Property<int>("NotifyOnLevelUp")
.HasColumnType("int") .HasColumnType("int")
.HasColumnName("notifyonlevelup"); .HasColumnName("notifyonlevelup");

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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");
}
}
}

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