diff --git a/CHANGELOG.md b/CHANGELOG.md index 2816440..2688201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,33 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.1.0/) except date format. a-c-f-r-o +## [5.1.6] - 08.08.2024 + +### Added + +- `'serverlist` is now paginated + +### Changed + +- `'listservers` renamed to `'serverlist` + +### Fixed + +- `'afk` messages can no longer ping, and the response is moved to DMs to avoid abuse +- Possible fix for `'remind` timestamp + +### Removed +- Removed old bloat / semi broken / dumb commands + - `'memelist` / `'memegen` (too inconvenient to use) + - `'activity` (useless owner-only command) + - `'rafflecur` (Just use raffle and then award manually instead) + - `'rollduel` (we had this command?) +- You can no longer bet on `'connect4` +- `'economy` Removed. + - Was buggy and didn't really show the real state of the economy. + - It might come back improved in the future +- `'mal` Removed. Useless information / semi broken + ## [5.1.5] - 01.08.2024 ### Added @@ -25,6 +52,7 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.1.0/) except da - You can once again disable cleverbot responses using fake 'cleverbot:response' module name in permission commands ### Removed + - Removed 'rip command ## [5.1.4] - 15.07.2024 diff --git a/Dockerfile b/Dockerfile index dcdedcf..889584a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,24 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +# Use the .NET 8.0 SDK as the base image for the build stage +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /source +# Copy the .csproj files for each project COPY src/Ellie.Marmalade/*.csproj src/Ellie.Marmalade/ COPY src/EllieBot/*.csproj src/EllieBot/ COPY src/EllieBot.Coordinator/*.csproj src/EllieBot.Coordinator/ COPY src/EllieBot.Generators/*.csproj src/EllieBot.Generators/ COPY src/EllieBot.Voice/*.csproj src/EllieBot.Voice/ -COPY NuGet.Config ./ + +# Restore the dependencies for the EllieBot project RUN dotnet restore src/EllieBot/ +# Copy the rest of the source code COPY . . + +# Set the working directory to the EllieBot project WORKDIR /source/src/EllieBot + +# Build and publish the EllieBot project, then clean up unnecessary files RUN set -xe; \ dotnet --version; \ dotnet publish -c Release -o /app --no-restore; \ @@ -19,28 +27,33 @@ RUN set -xe; \ find /app -type f -exec chmod -x {} \; ;\ chmod +x /app/EllieBot -# final stage/image -FROM mcr.microsoft.com/dotnet/runtime:6.0 +# Use the .NET 8.0 runtime as the base image for the final stage +FROM mcr.microsoft.com/dotnet/runtime:8.0 WORKDIR /app +# Create a new user, install dependencies, and set up sudoers file RUN set -xe; \ useradd -m ellie; \ apt-get update; \ apt-get install -y --no-install-recommends libopus0 libsodium23 libsqlite3-0 curl ffmpeg python3 sudo; \ - update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1; \ echo 'Defaults>ellie env_keep+="ASPNETCORE_* DOTNET_* EllieBot_* shard_id total_shards TZ"' > /etc/sudoers.d/ellie; \ curl -Lo /usr/local/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp; \ chmod a+rx /usr/local/bin/yt-dlp; \ apt-get autoremove -y; \ apt-get autoclean -y +# Copy the built application and the entrypoint script from the build stage COPY --from=build /app ./ COPY docker-entrypoint.sh /usr/local/sbin +# Set environment variables ENV shard_id=0 ENV total_shards=1 ENV EllieBot__creds=/app/data/creds.yml +# Define the data directory as a volume VOLUME [" /app/data "] + +# Set the entrypoint and default command ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ] CMD dotnet EllieBot.dll "$shard_id" "$total_shards" diff --git a/EllieBot.sln b/EllieBot.sln index f34ad17..7f96e39 100644 --- a/EllieBot.sln +++ b/EllieBot.sln @@ -13,7 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution migrate.ps1 = migrate.ps1 README.md = README.md remove-migrations.ps1 = remove-migrations.ps1 - TODO.md = TODO.md EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EllieBot", "src\EllieBot\EllieBot.csproj", "{4D9001F7-B3E8-48FE-97AA-CFD36DA65A64}" diff --git a/src/Ellie.Marmalade/Context/AnyContext.cs b/src/Ellie.Marmalade/Context/AnyContext.cs index 4f7207c..5af3930 100644 --- a/src/Ellie.Marmalade/Context/AnyContext.cs +++ b/src/Ellie.Marmalade/Context/AnyContext.cs @@ -1,5 +1,4 @@ using Discord; -using EllieBot; namespace EllieBot.Marmalade; diff --git a/src/EllieBot/Bot.cs b/src/EllieBot/Bot.cs index 9ab0f92..3ea8ffa 100644 --- a/src/EllieBot/Bot.cs +++ b/src/EllieBot/Bot.cs @@ -88,7 +88,7 @@ public sealed class Bot : IBot public IReadOnlyList GetCurrentGuildIds() - => Client.Guilds.Select(x => x.Id).ToList(); + => Client.Guilds.Select(x => x.Id).ToList().ToList(); private void AddServices() { @@ -114,7 +114,7 @@ public sealed class Bot : IBot // svcs.Components.Remove(); // svcs.Components.Add(); - svcs.AddSingleton(_ => _credsProvider.GetCreds()); + svcs.AddSingleton(_ => _credsProvider.GetCreds()); svcs.AddSingleton(_db); svcs.AddSingleton(_credsProvider); svcs.AddSingleton(Client); diff --git a/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs b/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs index b5e5f67..1e219eb 100644 --- a/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs +++ b/src/EllieBot/Db/Models/anti/AntiRaidSetting.cs @@ -1,6 +1,4 @@ #nullable disable -using System.ComponentModel.DataAnnotations.Schema; - namespace EllieBot.Db.Models; diff --git a/src/EllieBot/EllieBot.csproj b/src/EllieBot/EllieBot.csproj index 1f0a2f0..ff1c6ec 100644 --- a/src/EllieBot/EllieBot.csproj +++ b/src/EllieBot/EllieBot.csproj @@ -4,7 +4,7 @@ enable true en - 5.1.5 + 5.1.6 $(MSBuildProjectDirectory) diff --git a/src/EllieBot/Migrations/MigrationQueries.cs b/src/EllieBot/Migrations/MigrationQueries.cs index 8265ebb..a20f4a3 100644 --- a/src/EllieBot/Migrations/MigrationQueries.cs +++ b/src/EllieBot/Migrations/MigrationQueries.cs @@ -1,6 +1,5 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Migrations; -using EllieBot.Db.Models; namespace EllieBot.Migrations; @@ -50,5 +49,9 @@ left join guildconfigs on reactionrolemessage.guildconfigid = guildconfigs.id;") builder.Sql($""" DELETE FROM "DelMsgOnCmdChannel" WHERE "GuildConfigId" is NULL; """); + + builder.Sql(""" + DELETE FROM "WarningPunishment" WHERE "GuildConfigId" NOT IN (SELECT "Id" from "GuildConfigs"); + """); } } \ No newline at end of file diff --git a/src/EllieBot/Migrations/Mysql/20220409170652_mysql-init.cs b/src/EllieBot/Migrations/Mysql/20220409170652_mysql-init.cs index cdf1904..b857ff5 100644 --- a/src/EllieBot/Migrations/Mysql/20220409170652_mysql-init.cs +++ b/src/EllieBot/Migrations/Mysql/20220409170652_mysql-init.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Mysql/20220429044757_bank.cs b/src/EllieBot/Migrations/Mysql/20220429044757_bank.cs index 73e42f7..3fe3ee6 100644 --- a/src/EllieBot/Migrations/Mysql/20220429044757_bank.cs +++ b/src/EllieBot/Migrations/Mysql/20220429044757_bank.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Mysql/20220504162509_new-rero.cs b/src/EllieBot/Migrations/Mysql/20220504162509_new-rero.cs index e94af0b..9090ab2 100644 --- a/src/EllieBot/Migrations/Mysql/20220504162509_new-rero.cs +++ b/src/EllieBot/Migrations/Mysql/20220504162509_new-rero.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Mysql/20220614071410_patronage-system.cs b/src/EllieBot/Migrations/Mysql/20220614071410_patronage-system.cs index af53bf5..eb04272 100644 --- a/src/EllieBot/Migrations/Mysql/20220614071410_patronage-system.cs +++ b/src/EllieBot/Migrations/Mysql/20220614071410_patronage-system.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Mysql/20220623090718_stondel-db-cache.cs b/src/EllieBot/Migrations/Mysql/20220623090718_stondel-db-cache.cs index 1546ea1..b3e2d00 100644 --- a/src/EllieBot/Migrations/Mysql/20220623090718_stondel-db-cache.cs +++ b/src/EllieBot/Migrations/Mysql/20220623090718_stondel-db-cache.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Mysql/20220725155953_xpitemshop.cs b/src/EllieBot/Migrations/Mysql/20220725155953_xpitemshop.cs index e876590..be9530f 100644 --- a/src/EllieBot/Migrations/Mysql/20220725155953_xpitemshop.cs +++ b/src/EllieBot/Migrations/Mysql/20220725155953_xpitemshop.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Mysql/20220808141855_remove-obsolete-xp-columns.cs b/src/EllieBot/Migrations/Mysql/20220808141855_remove-obsolete-xp-columns.cs index dedceb3..96daeaf 100644 --- a/src/EllieBot/Migrations/Mysql/20220808141855_remove-obsolete-xp-columns.cs +++ b/src/EllieBot/Migrations/Mysql/20220808141855_remove-obsolete-xp-columns.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Mysql/20220916194514_autopub.cs b/src/EllieBot/Migrations/Mysql/20220916194514_autopub.cs index 16a0ed2..b3f24dc 100644 --- a/src/EllieBot/Migrations/Mysql/20220916194514_autopub.cs +++ b/src/EllieBot/Migrations/Mysql/20220916194514_autopub.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Mysql/20221003175743_gambling-stats.cs b/src/EllieBot/Migrations/Mysql/20221003175743_gambling-stats.cs index bb53a5e..351ed01 100644 --- a/src/EllieBot/Migrations/Mysql/20221003175743_gambling-stats.cs +++ b/src/EllieBot/Migrations/Mysql/20221003175743_gambling-stats.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Mysql/20240502233216_v5.cs b/src/EllieBot/Migrations/Mysql/20240502233216_v5.cs index 4ed5d52..24234b4 100644 --- a/src/EllieBot/Migrations/Mysql/20240502233216_v5.cs +++ b/src/EllieBot/Migrations/Mysql/20240502233216_v5.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Mysql/20240518221440_guidlconfig-cleanup.cs b/src/EllieBot/Migrations/Mysql/20240518221440_guidlconfig-cleanup.cs index 89c098d..b76512c 100644 --- a/src/EllieBot/Migrations/Mysql/20240518221440_guidlconfig-cleanup.cs +++ b/src/EllieBot/Migrations/Mysql/20240518221440_guidlconfig-cleanup.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/PostgreSql/20220409170719_mysql-init.cs b/src/EllieBot/Migrations/PostgreSql/20220409170719_mysql-init.cs index 47fedf6..3e0cbc0 100644 --- a/src/EllieBot/Migrations/PostgreSql/20220409170719_mysql-init.cs +++ b/src/EllieBot/Migrations/PostgreSql/20220409170719_mysql-init.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable diff --git a/src/EllieBot/Migrations/PostgreSql/20220429044808_bank.cs b/src/EllieBot/Migrations/PostgreSql/20220429044808_bank.cs index 6d5cc67..4f0a4a5 100644 --- a/src/EllieBot/Migrations/PostgreSql/20220429044808_bank.cs +++ b/src/EllieBot/Migrations/PostgreSql/20220429044808_bank.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable diff --git a/src/EllieBot/Migrations/PostgreSql/20220504162457_new-rero.cs b/src/EllieBot/Migrations/PostgreSql/20220504162457_new-rero.cs index 237a0d8..7185c09 100644 --- a/src/EllieBot/Migrations/PostgreSql/20220504162457_new-rero.cs +++ b/src/EllieBot/Migrations/PostgreSql/20220504162457_new-rero.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable diff --git a/src/EllieBot/Migrations/PostgreSql/20220614071421_patronage-system.cs b/src/EllieBot/Migrations/PostgreSql/20220614071421_patronage-system.cs index f8bb7b9..b8fcc2c 100644 --- a/src/EllieBot/Migrations/PostgreSql/20220614071421_patronage-system.cs +++ b/src/EllieBot/Migrations/PostgreSql/20220614071421_patronage-system.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/PostgreSql/20220623090729_stondel-db-cache.cs b/src/EllieBot/Migrations/PostgreSql/20220623090729_stondel-db-cache.cs index 9cb7187..eed96a7 100644 --- a/src/EllieBot/Migrations/PostgreSql/20220623090729_stondel-db-cache.cs +++ b/src/EllieBot/Migrations/PostgreSql/20220623090729_stondel-db-cache.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable diff --git a/src/EllieBot/Migrations/PostgreSql/20220725155941_xpitemshop.cs b/src/EllieBot/Migrations/PostgreSql/20220725155941_xpitemshop.cs index 073f682..258dc4c 100644 --- a/src/EllieBot/Migrations/PostgreSql/20220725155941_xpitemshop.cs +++ b/src/EllieBot/Migrations/PostgreSql/20220725155941_xpitemshop.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable diff --git a/src/EllieBot/Migrations/PostgreSql/20220808142559_remove-obsolete-xp-columns.cs b/src/EllieBot/Migrations/PostgreSql/20220808142559_remove-obsolete-xp-columns.cs index 4cd146c..64f3334 100644 --- a/src/EllieBot/Migrations/PostgreSql/20220808142559_remove-obsolete-xp-columns.cs +++ b/src/EllieBot/Migrations/PostgreSql/20220808142559_remove-obsolete-xp-columns.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/PostgreSql/20220916194523_autopub.cs b/src/EllieBot/Migrations/PostgreSql/20220916194523_autopub.cs index 9718e60..35ace3c 100644 --- a/src/EllieBot/Migrations/PostgreSql/20220916194523_autopub.cs +++ b/src/EllieBot/Migrations/PostgreSql/20220916194523_autopub.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable diff --git a/src/EllieBot/Migrations/PostgreSql/20221003175752_gambling-stats.cs b/src/EllieBot/Migrations/PostgreSql/20221003175752_gambling-stats.cs index 81dbd5b..88c4b12 100644 --- a/src/EllieBot/Migrations/PostgreSql/20221003175752_gambling-stats.cs +++ b/src/EllieBot/Migrations/PostgreSql/20221003175752_gambling-stats.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable diff --git a/src/EllieBot/Migrations/PostgreSql/20240502233202_v5.cs b/src/EllieBot/Migrations/PostgreSql/20240502233202_v5.cs index d3629d8..943e959 100644 --- a/src/EllieBot/Migrations/PostgreSql/20240502233202_v5.cs +++ b/src/EllieBot/Migrations/PostgreSql/20240502233202_v5.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable diff --git a/src/EllieBot/Migrations/PostgreSql/20240518221432_guidlconfig-cleanup.cs b/src/EllieBot/Migrations/PostgreSql/20240518221432_guidlconfig-cleanup.cs index b22df63..a6a4994 100644 --- a/src/EllieBot/Migrations/PostgreSql/20240518221432_guidlconfig-cleanup.cs +++ b/src/EllieBot/Migrations/PostgreSql/20240518221432_guidlconfig-cleanup.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20210621042359_squash.cs b/src/EllieBot/Migrations/Sqlite/20210621042359_squash.cs index c54a634..4273df4 100644 --- a/src/EllieBot/Migrations/Sqlite/20210621042359_squash.cs +++ b/src/EllieBot/Migrations/Sqlite/20210621042359_squash.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; namespace EllieBot.Migrations { diff --git a/src/EllieBot/Migrations/Sqlite/20210707002343_cleanup.cs b/src/EllieBot/Migrations/Sqlite/20210707002343_cleanup.cs index b9cea6d..1d2dc92 100644 --- a/src/EllieBot/Migrations/Sqlite/20210707002343_cleanup.cs +++ b/src/EllieBot/Migrations/Sqlite/20210707002343_cleanup.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; namespace EllieBot.Migrations { diff --git a/src/EllieBot/Migrations/Sqlite/20210914180026_image-only-channels.cs b/src/EllieBot/Migrations/Sqlite/20210914180026_image-only-channels.cs index 3e1ca4a..5dfbf73 100644 --- a/src/EllieBot/Migrations/Sqlite/20210914180026_image-only-channels.cs +++ b/src/EllieBot/Migrations/Sqlite/20210914180026_image-only-channels.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; namespace EllieBot.Migrations { diff --git a/src/EllieBot/Migrations/Sqlite/20211015232708_nsfw-blacklist-tags.cs b/src/EllieBot/Migrations/Sqlite/20211015232708_nsfw-blacklist-tags.cs index b1f5b4f..760e27f 100644 --- a/src/EllieBot/Migrations/Sqlite/20211015232708_nsfw-blacklist-tags.cs +++ b/src/EllieBot/Migrations/Sqlite/20211015232708_nsfw-blacklist-tags.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; namespace EllieBot.Migrations { diff --git a/src/EllieBot/Migrations/Sqlite/20211213145407_atl-rework.cs b/src/EllieBot/Migrations/Sqlite/20211213145407_atl-rework.cs index c602c24..bb7df2b 100644 --- a/src/EllieBot/Migrations/Sqlite/20211213145407_atl-rework.cs +++ b/src/EllieBot/Migrations/Sqlite/20211213145407_atl-rework.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; namespace EllieBot.Migrations { diff --git a/src/EllieBot/Migrations/Sqlite/20220110105942_filter-settings-cleanup.cs b/src/EllieBot/Migrations/Sqlite/20220110105942_filter-settings-cleanup.cs index f247be4..0920046 100644 --- a/src/EllieBot/Migrations/Sqlite/20220110105942_filter-settings-cleanup.cs +++ b/src/EllieBot/Migrations/Sqlite/20220110105942_filter-settings-cleanup.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20220409170828_clubs-refactor.cs b/src/EllieBot/Migrations/Sqlite/20220409170828_clubs-refactor.cs index 3c863ab..1dc81f7 100644 --- a/src/EllieBot/Migrations/Sqlite/20220409170828_clubs-refactor.cs +++ b/src/EllieBot/Migrations/Sqlite/20220409170828_clubs-refactor.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20220428051304_bank.cs b/src/EllieBot/Migrations/Sqlite/20220428051304_bank.cs index 3ac27ac..b3efa7e 100644 --- a/src/EllieBot/Migrations/Sqlite/20220428051304_bank.cs +++ b/src/EllieBot/Migrations/Sqlite/20220428051304_bank.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20220503234243_new-rero.cs b/src/EllieBot/Migrations/Sqlite/20220503234243_new-rero.cs index acb4e12..dce2e4b 100644 --- a/src/EllieBot/Migrations/Sqlite/20220503234243_new-rero.cs +++ b/src/EllieBot/Migrations/Sqlite/20220503234243_new-rero.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20220614071359_patronage-system.cs b/src/EllieBot/Migrations/Sqlite/20220614071359_patronage-system.cs index b752b3c..fd1100f 100644 --- a/src/EllieBot/Migrations/Sqlite/20220614071359_patronage-system.cs +++ b/src/EllieBot/Migrations/Sqlite/20220614071359_patronage-system.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20220623073903_stondel-db-cache.cs b/src/EllieBot/Migrations/Sqlite/20220623073903_stondel-db-cache.cs index 06eb71d..efce911 100644 --- a/src/EllieBot/Migrations/Sqlite/20220623073903_stondel-db-cache.cs +++ b/src/EllieBot/Migrations/Sqlite/20220623073903_stondel-db-cache.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20220725112348_xpitemshop.cs b/src/EllieBot/Migrations/Sqlite/20220725112348_xpitemshop.cs index 84d2b74..ef8d9c4 100644 --- a/src/EllieBot/Migrations/Sqlite/20220725112348_xpitemshop.cs +++ b/src/EllieBot/Migrations/Sqlite/20220725112348_xpitemshop.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20220808141842_remove-obsolete-xp-columns.cs b/src/EllieBot/Migrations/Sqlite/20220808141842_remove-obsolete-xp-columns.cs index c26f711..8ef5757 100644 --- a/src/EllieBot/Migrations/Sqlite/20220808141842_remove-obsolete-xp-columns.cs +++ b/src/EllieBot/Migrations/Sqlite/20220808141842_remove-obsolete-xp-columns.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20220916191702_autopub.cs b/src/EllieBot/Migrations/Sqlite/20220916191702_autopub.cs index d974254..f3d98db 100644 --- a/src/EllieBot/Migrations/Sqlite/20220916191702_autopub.cs +++ b/src/EllieBot/Migrations/Sqlite/20220916191702_autopub.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20221003111019_gambling-stats.cs b/src/EllieBot/Migrations/Sqlite/20221003111019_gambling-stats.cs index cdff8c1..6ebf812 100644 --- a/src/EllieBot/Migrations/Sqlite/20221003111019_gambling-stats.cs +++ b/src/EllieBot/Migrations/Sqlite/20221003111019_gambling-stats.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20240502233144_v5.cs b/src/EllieBot/Migrations/Sqlite/20240502233144_v5.cs index c6f46b5..da4fdd7 100644 --- a/src/EllieBot/Migrations/Sqlite/20240502233144_v5.cs +++ b/src/EllieBot/Migrations/Sqlite/20240502233144_v5.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Migrations/Sqlite/20240518221424_guidlconfig-cleanup.cs b/src/EllieBot/Migrations/Sqlite/20240518221424_guidlconfig-cleanup.cs index cc33c61..33418e2 100644 --- a/src/EllieBot/Migrations/Sqlite/20240518221424_guidlconfig-cleanup.cs +++ b/src/EllieBot/Migrations/Sqlite/20240518221424_guidlconfig-cleanup.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/src/EllieBot/Modules/Administration/AdministrationService.cs b/src/EllieBot/Modules/Administration/AdministrationService.cs index de037bd..b1bec59 100644 --- a/src/EllieBot/Modules/Administration/AdministrationService.cs +++ b/src/EllieBot/Modules/Administration/AdministrationService.cs @@ -1,6 +1,5 @@ #nullable disable using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Db.Models; using EllieBot.Modules.Administration._common.results; diff --git a/src/EllieBot/Modules/Administration/AutoAssignableRoles/AutoAssignRoleService.cs b/src/EllieBot/Modules/Administration/AutoAssignableRoles/AutoAssignRoleService.cs index f373d45..5e232f8 100644 --- a/src/EllieBot/Modules/Administration/AutoAssignableRoles/AutoAssignRoleService.cs +++ b/src/EllieBot/Modules/Administration/AutoAssignableRoles/AutoAssignRoleService.cs @@ -4,7 +4,6 @@ using System.Net; using System.Threading.Channels; using LinqToDB; using Microsoft.EntityFrameworkCore; -using EllieBot.Db; namespace EllieBot.Modules.Administration.Services; diff --git a/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs b/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs index 54f9870..e83e5a3 100644 --- a/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs +++ b/src/EllieBot/Modules/Administration/GameVoiceChannel/GameVoiceChannelService.cs @@ -1,6 +1,4 @@ #nullable disable -using EllieBot.Db; - namespace EllieBot.Modules.Administration.Services; public class GameVoiceChannelService : IEService diff --git a/src/EllieBot/Modules/Administration/GreetBye/GreetService.cs b/src/EllieBot/Modules/Administration/GreetBye/GreetService.cs index 1511913..277c242 100644 --- a/src/EllieBot/Modules/Administration/GreetBye/GreetService.cs +++ b/src/EllieBot/Modules/Administration/GreetBye/GreetService.cs @@ -1,5 +1,4 @@ using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Db.Models; using System.Threading.Channels; diff --git a/src/EllieBot/Modules/Administration/Mute/MuteService.cs b/src/EllieBot/Modules/Administration/Mute/MuteService.cs index a3fbea3..a67610d 100644 --- a/src/EllieBot/Modules/Administration/Mute/MuteService.cs +++ b/src/EllieBot/Modules/Administration/Mute/MuteService.cs @@ -1,6 +1,5 @@ #nullable disable using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Db.Models; namespace EllieBot.Modules.Administration.Services; diff --git a/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs b/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs index c28d3c4..c72a941 100644 --- a/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs +++ b/src/EllieBot/Modules/Administration/Protection/ProtectionService.cs @@ -1,6 +1,5 @@ #nullable disable using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Db.Models; using System.Threading.Channels; diff --git a/src/EllieBot/Modules/Administration/Role/IReactionRoleService.cs b/src/EllieBot/Modules/Administration/Role/IReactionRoleService.cs index 771ceb0..1f2911d 100644 --- a/src/EllieBot/Modules/Administration/Role/IReactionRoleService.cs +++ b/src/EllieBot/Modules/Administration/Role/IReactionRoleService.cs @@ -1,5 +1,4 @@ #nullable disable -using EllieBot.Modules.Patronage; using EllieBot.Db.Models; using OneOf; using OneOf.Types; diff --git a/src/EllieBot/Modules/Administration/Role/ReactionRolesService.cs b/src/EllieBot/Modules/Administration/Role/ReactionRolesService.cs index cf36457..caa3e19 100644 --- a/src/EllieBot/Modules/Administration/Role/ReactionRolesService.cs +++ b/src/EllieBot/Modules/Administration/Role/ReactionRolesService.cs @@ -2,7 +2,6 @@ using LinqToDB; using LinqToDB.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Modules.Patronage; using EllieBot.Db.Models; using OneOf.Types; diff --git a/src/EllieBot/Modules/Administration/Role/StickyRolesService.cs b/src/EllieBot/Modules/Administration/Role/StickyRolesService.cs index 1fcfc15..ede5b63 100644 --- a/src/EllieBot/Modules/Administration/Role/StickyRolesService.cs +++ b/src/EllieBot/Modules/Administration/Role/StickyRolesService.cs @@ -3,7 +3,6 @@ using LinqToDB; using LinqToDB.EntityFrameworkCore; using EllieBot.Db.Models; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; namespace EllieBot.Modules.Administration; diff --git a/src/EllieBot/Modules/Administration/Self/SelfCommands.cs b/src/EllieBot/Modules/Administration/Self/SelfCommands.cs index d67ac93..b8842cd 100644 --- a/src/EllieBot/Modules/Administration/Self/SelfCommands.cs +++ b/src/EllieBot/Modules/Administration/Self/SelfCommands.cs @@ -546,7 +546,7 @@ public partial class Administration text = await repSvc.ReplaceAsync(text, repCtx); await Response().Channel(ch).Text(text).SendAsync(); - await ctx.OkAsync();; + await ctx.OkAsync(); } [Cmd] diff --git a/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs b/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs index 1305835..505f56c 100644 --- a/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs +++ b/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs @@ -1,6 +1,5 @@ #nullable disable using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Db.Models; namespace EllieBot.Modules.Administration.Services; diff --git a/src/EllieBot/Modules/Administration/ServerLog/ServerLogCommandService.cs b/src/EllieBot/Modules/Administration/ServerLog/ServerLogCommandService.cs index 6ea5345..3b6cd3e 100644 --- a/src/EllieBot/Modules/Administration/ServerLog/ServerLogCommandService.cs +++ b/src/EllieBot/Modules/Administration/ServerLog/ServerLogCommandService.cs @@ -1,7 +1,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Modules.Administration.Services; using EllieBot.Db.Models; diff --git a/src/EllieBot/Modules/Administration/Timezone/GuildTimezoneService.cs b/src/EllieBot/Modules/Administration/Timezone/GuildTimezoneService.cs index e1f2fea..f36d7af 100644 --- a/src/EllieBot/Modules/Administration/Timezone/GuildTimezoneService.cs +++ b/src/EllieBot/Modules/Administration/Timezone/GuildTimezoneService.cs @@ -1,5 +1,4 @@ #nullable disable -using EllieBot.Db; using EllieBot.Db.Models; using EllieBot.Common.ModuleBehaviors; diff --git a/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs b/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs index 9ab0b73..a42a9f1 100644 --- a/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs +++ b/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs @@ -4,7 +4,6 @@ using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; using EllieBot.Common.TypeReaders.Models; -using EllieBot.Db; using EllieBot.Modules.Permissions.Services; using EllieBot.Db.Models; using Newtonsoft.Json; diff --git a/src/EllieBot/Modules/Administration/VcRole/VcRoleService.cs b/src/EllieBot/Modules/Administration/VcRole/VcRoleService.cs index c2dc60b..0ba9feb 100644 --- a/src/EllieBot/Modules/Administration/VcRole/VcRoleService.cs +++ b/src/EllieBot/Modules/Administration/VcRole/VcRoleService.cs @@ -1,6 +1,5 @@ #nullable disable using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Db.Models; namespace EllieBot.Modules.Administration.Services; diff --git a/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs b/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs index 250c517..a660b4d 100644 --- a/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs +++ b/src/EllieBot/Modules/Expressions/EllieExpressionsService.cs @@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; using EllieBot.Common.Yml; -using EllieBot.Db; using EllieBot.Db.Models; using System.Runtime.CompilerServices; using LinqToDB.EntityFrameworkCore; diff --git a/src/EllieBot/Modules/Gambling/BlackJack/BlackJackCommands.cs b/src/EllieBot/Modules/Gambling/BlackJack/BlackJackCommands.cs index ea9c8b8..772cb4f 100644 --- a/src/EllieBot/Modules/Gambling/BlackJack/BlackJackCommands.cs +++ b/src/EllieBot/Modules/Gambling/BlackJack/BlackJackCommands.cs @@ -3,7 +3,6 @@ using EllieBot.Common.TypeReaders; using EllieBot.Modules.Gambling.Common; using EllieBot.Modules.Gambling.Common.Blackjack; using EllieBot.Modules.Gambling.Services; -using EllieBot.Modules.Utility; namespace EllieBot.Modules.Gambling; diff --git a/src/EllieBot/Modules/Gambling/Connect4/Connect4.cs b/src/EllieBot/Modules/Gambling/Connect4/Connect4.cs index 45d2e89..02537fd 100644 --- a/src/EllieBot/Modules/Gambling/Connect4/Connect4.cs +++ b/src/EllieBot/Modules/Gambling/Connect4/Connect4.cs @@ -38,11 +38,11 @@ public sealed class Connect4Game : IDisposable public Phase CurrentPhase { get; private set; } = Phase.Joining; - public ImmutableArray GameState - => _gameState.ToImmutableArray(); + public IReadOnlyList GameState + => _gameState.AsReadOnly(); - public ImmutableArray<(ulong UserId, string Username)?> Players - => _players.ToImmutableArray(); + public IReadOnlyCollection<(ulong UserId, string Username)?> Players + => _players.AsReadOnly(); public (ulong UserId, string Username) CurrentPlayer => CurrentPhase == Phase.P1Move ? _players[0].Value : _players[1].Value; @@ -56,7 +56,6 @@ public sealed class Connect4Game : IDisposable private readonly SemaphoreSlim _locker = new(1, 1); private readonly Options _options; - private readonly ICurrencyService _cs; private readonly EllieRandom _rng; private Timer playerTimeoutTimer; @@ -73,12 +72,11 @@ public sealed class Connect4Game : IDisposable public Connect4Game( ulong userId, string userName, - Options options, - ICurrencyService cs) + Options options + ) { _players[0] = (userId, userName); _options = options; - _cs = cs; _rng = new(); for (var i = 0; i < NUMBER_OF_COLUMNS * NUMBER_OF_ROWS; i++) @@ -99,14 +97,13 @@ public sealed class Connect4Game : IDisposable { _ = OnGameFailedToStart?.Invoke(this); CurrentPhase = Phase.Ended; - await _cs.AddAsync(_players[0].Value.UserId, _options.Bet, new("connect4", "refund")); } } finally { _locker.Release(); } }); } - public async Task Join(ulong userId, string userName, int bet) + public async Task Join(ulong userId, string userName) { await _locker.WaitAsync(); try @@ -117,11 +114,6 @@ public sealed class Connect4Game : IDisposable if (_players[0].Value.UserId == userId) // same user can't join own game return false; - if (bet != _options.Bet) // can't join if bet amount is not the same - return false; - - if (!await _cs.RemoveAsync(userId, bet, new("connect4", "bet"))) // user doesn't have enough money to gamble - return false; if (_rng.Next(0, 2) == 0) //rolling from 0-1, if number is 0, join as first player { @@ -133,14 +125,14 @@ public sealed class Connect4Game : IDisposable CurrentPhase = Phase.P1Move; //start the game playerTimeoutTimer = new(async _ => + { + await _locker.WaitAsync(); + try { - await _locker.WaitAsync(); - try - { - EndGame(Result.OtherPlayerWon, OtherPlayer.UserId); - } - finally { _locker.Release(); } - }, + EndGame(Result.OtherPlayerWon, OtherPlayer.UserId); + } + finally { _locker.Release(); } + }, null, TimeSpan.FromSeconds(_options.TurnTimer), TimeSpan.FromSeconds(_options.TurnTimer)); @@ -351,13 +343,8 @@ public sealed class Connect4Game : IDisposable if (result == Result.Draw) { - _cs.AddAsync(CurrentPlayer.UserId, _options.Bet, new("connect4", "draw")); - _cs.AddAsync(OtherPlayer.UserId, _options.Bet, new("connect4", "draw")); return; } - - if (winId is not null) - _cs.AddAsync(winId.Value, (long)(_options.Bet * 1.98), new("connect4", "win")); } private Field GetPlayerPiece(ulong userId) @@ -394,16 +381,10 @@ public sealed class Connect4Game : IDisposable HelpText = "Turn time in seconds. It has to be between 5 and 60. Default 15.")] public int TurnTimer { get; set; } = 15; - [Option('b', "bet", Required = false, Default = 0, HelpText = "Amount you bet. Default 0.")] - public int Bet { get; set; } - public void NormalizeOptions() { if (TurnTimer is < 5 or > 60) TurnTimer = 15; - - if (Bet < 0) - Bet = 0; } } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Gambling/Connect4/Connect4Commands.cs b/src/EllieBot/Modules/Gambling/Connect4/Connect4Commands.cs index 8210ad4..3b3aad1 100644 --- a/src/EllieBot/Modules/Gambling/Connect4/Connect4Commands.cs +++ b/src/EllieBot/Modules/Gambling/Connect4/Connect4Commands.cs @@ -29,17 +29,15 @@ public partial class Gambling } private readonly DiscordSocketClient _client; - private readonly ICurrencyService _cs; private IUserMessage msg; private int repostCounter; - public Connect4Commands(DiscordSocketClient client, ICurrencyService cs, GamblingConfigService gamb) + public Connect4Commands(DiscordSocketClient client, GamblingConfigService gamb) : base(gamb) { _client = client; - _cs = cs; } [Cmd] @@ -48,10 +46,8 @@ public partial class Gambling public async Task Connect4(params string[] args) { var (options, _) = OptionsParser.ParseFrom(new Connect4Game.Options(), args); - if (!await CheckBetOptional(options.Bet)) - return; - var newGame = new Connect4Game(ctx.User.Id, ctx.User.ToString(), options, _cs); + var newGame = new Connect4Game(ctx.User.Id, ctx.User.ToString(), options); Connect4Game game; if ((game = _service.Connect4Games.GetOrAdd(ctx.Channel.Id, newGame)) != newGame) { @@ -60,31 +56,17 @@ public partial class Gambling newGame.Dispose(); //means game already exists, try to join - await game.Join(ctx.User.Id, ctx.User.ToString(), options.Bet); + await game.Join(ctx.User.Id, ctx.User.ToString()); return; } - if (options.Bet > 0) - { - if (!await _cs.RemoveAsync(ctx.User.Id, options.Bet, new("connect4", "bet"))) - { - await Response().Error(strs.not_enough(CurrencySign)).SendAsync(); - _service.Connect4Games.TryRemove(ctx.Channel.Id, out _); - game.Dispose(); - return; - } - } - game.OnGameStateUpdated += Game_OnGameStateUpdated; game.OnGameFailedToStart += GameOnGameFailedToStart; game.OnGameEnded += GameOnGameEnded; _client.MessageReceived += ClientMessageReceived; game.Initialize(); - if (options.Bet == 0) - await Response().Confirm(strs.connect4_created).SendAsync(); - else - await Response().Error(strs.connect4_created_bet(N(options.Bet))).SendAsync(); + await Response().Confirm(strs.connect4_created).SendAsync(); Task ClientMessageReceived(SocketMessage arg) { @@ -99,7 +81,8 @@ public partial class Gambling if (success) { - try { await arg.DeleteAsync(); } + try + { await arg.DeleteAsync(); } catch { } } else @@ -109,7 +92,8 @@ public partial class Gambling RepostCounter++; if (RepostCounter == 0) { - try { msg = await Response().Embed(msg.Embeds.First().ToEmbedBuilder()).SendAsync(); } + try + { msg = await Response().Embed(msg.Embeds.First().ToEmbedBuilder()).SendAsync(); } catch { } } } @@ -151,19 +135,19 @@ public partial class Gambling title = GetText(strs.connect4_draw); return msg.ModifyAsync(x => x.Embed = _sender.CreateEmbed() - .WithTitle(title) - .WithDescription(GetGameStateText(game)) - .WithOkColor() - .Build()); + .WithTitle(title) + .WithDescription(GetGameStateText(game)) + .WithOkColor() + .Build()); } } private async Task Game_OnGameStateUpdated(Connect4Game game) { var embed = _sender.CreateEmbed() - .WithTitle($"{game.CurrentPlayer.Username} vs {game.OtherPlayer.Username}") - .WithDescription(GetGameStateText(game)) - .WithOkColor(); + .WithTitle($"{game.CurrentPlayer.Username} vs {game.OtherPlayer.Username}") + .WithDescription(GetGameStateText(game)) + .WithOkColor(); if (msg is null) @@ -198,7 +182,7 @@ public partial class Gambling for (var i = 0; i < Connect4Game.NUMBER_OF_COLUMNS; i++) sb.Append(_numbers[i]); - + return sb.ToString(); } } diff --git a/src/EllieBot/Modules/Gambling/Gambling.cs b/src/EllieBot/Modules/Gambling/Gambling.cs index 52789d0..64fedf5 100644 --- a/src/EllieBot/Modules/Gambling/Gambling.cs +++ b/src/EllieBot/Modules/Gambling/Gambling.cs @@ -13,7 +13,6 @@ using System.Text; using EllieBot.Modules.Gambling.Rps; using EllieBot.Common.TypeReaders; using EllieBot.Modules.Patronage; -using EllieBot.Modules.Utility; namespace EllieBot.Modules.Gambling; @@ -31,8 +30,6 @@ public partial class Gambling : GamblingModule private readonly GamblingTxTracker _gamblingTxTracker; private readonly IPatronageService _ps; - private IUserMessage rdMsg; - public Gambling( IGamblingService gs, DbService db, @@ -105,34 +102,6 @@ public partial class Gambling : GamblingModule await Response().Embed(eb).SendAsync(); } - [Cmd] - public async Task Economy() - { - var ec = await _service.GetEconomyAsync(); - decimal onePercent = 0; - - // This stops the top 1% from owning more than 100% of the money - if (ec.Cash > 0) - { - onePercent = ec.OnePercent / (ec.Cash - ec.Bot); - } - - // [21:03] Bob Page: Kinda remids me of US economy - var embed = _sender.CreateEmbed() - .WithTitle(GetText(strs.economy_state)) - .AddField(GetText(strs.currency_owned), N(ec.Cash - ec.Bot)) - .AddField(GetText(strs.currency_one_percent), (onePercent * 100).ToString("F2") + "%") - .AddField(GetText(strs.currency_planted), N(ec.Planted)) - .AddField(GetText(strs.owned_waifus_total), N(ec.Waifus)) - .AddField(GetText(strs.bot_currency), N(ec.Bot)) - .AddField(GetText(strs.bank_accounts), N(ec.Bank)) - .AddField(GetText(strs.total), N(ec.Cash + ec.Planted + ec.Waifus + ec.Bank)) - .WithOkColor(); - - // ec.Cash already contains ec.Bot as it's the total of all values in the CurrencyAmount column of the DiscordUser table - await Response().Embed(embed).SendAsync(); - } - private async Task RemindTimelyAction(SocketMessageComponent smc, DateTime when) { var tt = TimestampTag.FromDateTime(when, TimestampTagStyles.Relative); @@ -602,117 +571,6 @@ public partial class Gambling : GamblingModule } } - [Cmd] - [RequireContext(ContextType.Guild)] - public async Task RollDuel(IUser u) - { - if (ctx.User.Id == u.Id) - { - return; - } - - //since the challenge is created by another user, we need to reverse the ids - //if it gets removed, means challenge is accepted - if (_service.Duels.TryRemove((ctx.User.Id, u.Id), out var game)) - { - await game.StartGame(); - } - } - - [Cmd] - [RequireContext(ContextType.Guild)] - public async Task RollDuel([OverrideTypeReader(typeof(BalanceTypeReader))] long amount, IUser u) - { - if (ctx.User.Id == u.Id) - { - return; - } - - if (amount <= 0) - { - return; - } - - var embed = _sender.CreateEmbed().WithOkColor().WithTitle(GetText(strs.roll_duel)); - - var description = string.Empty; - - var game = new RollDuelGame(_cs, _client.CurrentUser.Id, ctx.User.Id, u.Id, amount); - //means challenge is just created - if (_service.Duels.TryGetValue((ctx.User.Id, u.Id), out var other)) - { - if (other.Amount != amount) - { - await Response().Error(strs.roll_duel_already_challenged).SendAsync(); - } - else - { - await RollDuel(u); - } - - return; - } - - if (_service.Duels.TryAdd((u.Id, ctx.User.Id), game)) - { - game.OnGameTick += GameOnGameTick; - game.OnEnded += GameOnEnded; - - await Response() - .Confirm(strs.roll_duel_challenge(Format.Bold(ctx.User.ToString()), - Format.Bold(u.ToString()), - Format.Bold(N(amount)))) - .SendAsync(); - } - - async Task GameOnGameTick(RollDuelGame arg) - { - var rolls = arg.Rolls.Last(); - description += $@"{Format.Bold(ctx.User.ToString())} rolled **{rolls.Item1}** -{Format.Bold(u.ToString())} rolled **{rolls.Item2}** --- -"; - embed = embed.WithDescription(description); - - if (rdMsg is null) - { - rdMsg = await Response().Embed(embed).SendAsync(); - } - else - { - await rdMsg.ModifyAsync(x => { x.Embed = embed.Build(); }); - } - } - - async Task GameOnEnded(RollDuelGame rdGame, RollDuelGame.Reason reason) - { - try - { - if (reason == RollDuelGame.Reason.Normal) - { - var winner = rdGame.Winner == rdGame.P1 ? ctx.User : u; - description += $"\n**{winner}** Won {N((long)(rdGame.Amount * 2 * 0.98))}"; - - embed = embed.WithDescription(description); - - await rdMsg.ModifyAsync(x => x.Embed = embed.Build()); - } - else if (reason == RollDuelGame.Reason.Timeout) - { - await Response().Error(strs.roll_duel_timeout).SendAsync(); - } - else if (reason == RollDuelGame.Reason.NoFunds) - { - await Response().Error(strs.roll_duel_no_funds).SendAsync(); - } - } - finally - { - _service.Duels.TryRemove((u.Id, ctx.User.Id), out _); - } - } - } - [Cmd] public async Task BetRoll([OverrideTypeReader(typeof(BalanceTypeReader))] long amount) { diff --git a/src/EllieBot/Modules/Gambling/GamblingService.cs b/src/EllieBot/Modules/Gambling/GamblingService.cs index a324437..f9a55bc 100644 --- a/src/EllieBot/Modules/Gambling/GamblingService.cs +++ b/src/EllieBot/Modules/Gambling/GamblingService.cs @@ -2,7 +2,6 @@ using LinqToDB; using LinqToDB.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Db.Models; using EllieBot.Modules.Gambling.Common; using EllieBot.Modules.Gambling.Common.Connect4; @@ -129,38 +128,6 @@ public class GamblingService : IEService, IReadyExecutor private static readonly TypedKey _ecoKey = new("ellie:economy"); - public async Task GetEconomyAsync() - { - var data = await _cache.GetOrAddAsync(_ecoKey, - async () => - { - await using var uow = _db.GetDbContext(); - var cash = uow.Set().GetTotalCurrency(); - var onePercent = uow.Set().GetTopOnePercentCurrency(_client.CurrentUser.Id); - decimal planted = uow.Set().AsQueryable().Sum(x => x.Amount); - var waifus = uow.Set().GetTotalValue(); - var bot = await uow.Set().GetUserCurrencyAsync(_client.CurrentUser.Id); - decimal bank = await uow.GetTable() - .SumAsyncLinqToDB(x => x.Balance); - - var result = new EconomyResult - { - Cash = cash, - Planted = planted, - Bot = bot, - Waifus = waifus, - OnePercent = onePercent, - Bank = bank - }; - - return result; - }, - TimeSpan.FromMinutes(3)); - - return data; - } - - private static readonly SemaphoreSlim _timelyLock = new(1, 1); private static TypedKey> _timelyKey diff --git a/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs b/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs index 6b50a1e..bffd035 100644 --- a/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs +++ b/src/EllieBot/Modules/Gambling/PlantPick/PlantPickService.cs @@ -1,7 +1,6 @@ #nullable disable using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Db.Models; using SixLabors.Fonts; using SixLabors.ImageSharp; @@ -32,7 +31,6 @@ public class PlantPickService : IEService, IExecNoCommand public PlantPickService( DbService db, - CommandHandler cmd, IBotStrings strings, IImageCache images, FontProvider fonts, @@ -108,7 +106,6 @@ public class PlantPickService : IEService, IExecNoCommand /// Get a random currency image stream, with an optional password sticked onto it. /// /// Optional password to add to top left corner. - /// Extension of the file, defaults to png /// Stream of the currency image public async Task<(Stream, string)> GetRandomCurrencyImageAsync(string pass) { diff --git a/src/EllieBot/Modules/Gambling/Raffle/CurrencyRaffleCommands.cs b/src/EllieBot/Modules/Gambling/Raffle/CurrencyRaffleCommands.cs deleted file mode 100644 index 513aa59..0000000 --- a/src/EllieBot/Modules/Gambling/Raffle/CurrencyRaffleCommands.cs +++ /dev/null @@ -1,61 +0,0 @@ -#nullable disable -using EllieBot.Common.TypeReaders; -using EllieBot.Modules.Gambling.Common; -using EllieBot.Modules.Gambling.Services; - -namespace EllieBot.Modules.Gambling; - -public partial class Gambling -{ - public partial class CurrencyRaffleCommands : GamblingSubmodule - { - public enum Mixed { Mixed } - - public CurrencyRaffleCommands(GamblingConfigService gamblingConfService) - : base(gamblingConfService) - { - } - - [Cmd] - [RequireContext(ContextType.Guild)] - [Priority(0)] - public Task RaffleCur(Mixed _, [OverrideTypeReader(typeof(BalanceTypeReader))] long amount) - => RaffleCur(amount, true); - - [Cmd] - [RequireContext(ContextType.Guild)] - [Priority(1)] - public async Task RaffleCur([OverrideTypeReader(typeof(BalanceTypeReader))] long amount, bool mixed = false) - { - if (!await CheckBetMandatory(amount)) - return; - - async Task OnEnded(IUser arg, long won) - { - await Response() - .Confirm(GetText(strs.rafflecur_ended(CurrencyName, - Format.Bold(arg.ToString()), - won + CurrencySign))) - .SendAsync(); - } - - var res = await _service.JoinOrCreateGame(ctx.Channel.Id, ctx.User, amount, mixed, OnEnded); - - if (res.Item1 is not null) - { - await Response() - .Confirm(GetText(strs.rafflecur(res.Item1.GameType.ToString())), - string.Join("\n", res.Item1.Users.Select(x => $"{x.DiscordUser} ({N(x.Amount)})")), - footer: GetText(strs.rafflecur_joined(ctx.User.ToString()))) - .SendAsync(); - } - else - { - if (res.Item2 == CurrencyRaffleService.JoinErrorType.AlreadyJoinedOrInvalidAmount) - await Response().Error(strs.rafflecur_already_joined).SendAsync(); - else if (res.Item2 == CurrencyRaffleService.JoinErrorType.NotEnoughCurrency) - await Response().Error(strs.not_enough(CurrencySign)).SendAsync(); - } - } - } -} \ No newline at end of file diff --git a/src/EllieBot/Modules/Gambling/Raffle/CurrencyRaffleGame.cs b/src/EllieBot/Modules/Gambling/Raffle/CurrencyRaffleGame.cs deleted file mode 100644 index d6f5770..0000000 --- a/src/EllieBot/Modules/Gambling/Raffle/CurrencyRaffleGame.cs +++ /dev/null @@ -1,69 +0,0 @@ -#nullable disable -namespace EllieBot.Modules.Gambling.Common; - -public class CurrencyRaffleGame -{ - public enum Type - { - Mixed, - Normal - } - - public IEnumerable Users - => _users; - - public Type GameType { get; } - - private readonly HashSet _users = new(); - - public CurrencyRaffleGame(Type type) - => GameType = type; - - public bool AddUser(IUser usr, long amount) - { - // if game type is normal, and someone already joined the game - // (that's the user who created it) - if (GameType == Type.Normal && _users.Count > 0 && _users.First().Amount != amount) - return false; - - if (!_users.Add(new() - { - DiscordUser = usr, - Amount = amount - })) - return false; - - return true; - } - - public User GetWinner() - { - var rng = new EllieRandom(); - if (GameType == Type.Mixed) - { - var num = rng.NextLong(0L, Users.Sum(x => x.Amount)); - var sum = 0L; - foreach (var u in Users) - { - sum += u.Amount; - if (sum > num) - return u; - } - } - - var usrs = _users.ToArray(); - return usrs[rng.Next(0, usrs.Length)]; - } - - public class User - { - public IUser DiscordUser { get; set; } - public long Amount { get; set; } - - public override int GetHashCode() - => DiscordUser.GetHashCode(); - - public override bool Equals(object obj) - => obj is User u ? u.DiscordUser == DiscordUser : false; - } -} \ No newline at end of file diff --git a/src/EllieBot/Modules/Gambling/Raffle/CurrencyRaffleService.cs b/src/EllieBot/Modules/Gambling/Raffle/CurrencyRaffleService.cs deleted file mode 100644 index 743549e..0000000 --- a/src/EllieBot/Modules/Gambling/Raffle/CurrencyRaffleService.cs +++ /dev/null @@ -1,81 +0,0 @@ -#nullable disable -using EllieBot.Modules.Gambling.Common; - -namespace EllieBot.Modules.Gambling.Services; - -public class CurrencyRaffleService : IEService -{ - public enum JoinErrorType - { - NotEnoughCurrency, - AlreadyJoinedOrInvalidAmount - } - - public Dictionary Games { get; } = new(); - private readonly SemaphoreSlim _locker = new(1, 1); - private readonly ICurrencyService _cs; - - public CurrencyRaffleService(ICurrencyService cs) - => _cs = cs; - - public async Task<(CurrencyRaffleGame, JoinErrorType?)> JoinOrCreateGame( - ulong channelId, - IUser user, - long amount, - bool mixed, - Func onEnded) - { - await _locker.WaitAsync(); - try - { - var newGame = false; - if (!Games.TryGetValue(channelId, out var crg)) - { - newGame = true; - crg = new(mixed ? CurrencyRaffleGame.Type.Mixed : CurrencyRaffleGame.Type.Normal); - Games.Add(channelId, crg); - } - - //remove money, and stop the game if this - // user created it and doesn't have the money - if (!await _cs.RemoveAsync(user.Id, amount, new("raffle", "join"))) - { - if (newGame) - Games.Remove(channelId); - return (null, JoinErrorType.NotEnoughCurrency); - } - - if (!crg.AddUser(user, amount)) - { - await _cs.AddAsync(user.Id, amount, new("raffle", "refund")); - return (null, JoinErrorType.AlreadyJoinedOrInvalidAmount); - } - - if (newGame) - { - _ = Task.Run(async () => - { - await Task.Delay(60000); - await _locker.WaitAsync(); - try - { - var winner = crg.GetWinner(); - var won = crg.Users.Sum(x => x.Amount); - - await _cs.AddAsync(winner.DiscordUser.Id, won, new("raffle", "win")); - Games.Remove(channelId, out _); - _ = onEnded(winner.DiscordUser, won); - } - catch { } - finally { _locker.Release(); } - }); - } - - return (crg, null); - } - finally - { - _locker.Release(); - } - } -} \ No newline at end of file diff --git a/src/EllieBot/Modules/Gambling/Shop/ShopCommands.cs b/src/EllieBot/Modules/Gambling/Shop/ShopCommands.cs index a7910de..2d0749e 100644 --- a/src/EllieBot/Modules/Gambling/Shop/ShopCommands.cs +++ b/src/EllieBot/Modules/Gambling/Shop/ShopCommands.cs @@ -1,6 +1,5 @@ #nullable disable using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Modules.Gambling.Common; using EllieBot.Modules.Gambling.Services; using EllieBot.Db.Models; diff --git a/src/EllieBot/Modules/Gambling/Shop/ShopService.cs b/src/EllieBot/Modules/Gambling/Shop/ShopService.cs index dfe944a..9e46aa0 100644 --- a/src/EllieBot/Modules/Gambling/Shop/ShopService.cs +++ b/src/EllieBot/Modules/Gambling/Shop/ShopService.cs @@ -1,6 +1,5 @@ #nullable disable using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Db.Models; namespace EllieBot.Modules.Gambling.Services; diff --git a/src/EllieBot/Modules/Gambling/Slot/SlotCommands.cs b/src/EllieBot/Modules/Gambling/Slot/SlotCommands.cs index 979cbae..a5c7465 100644 --- a/src/EllieBot/Modules/Gambling/Slot/SlotCommands.cs +++ b/src/EllieBot/Modules/Gambling/Slot/SlotCommands.cs @@ -7,9 +7,7 @@ using SixLabors.ImageSharp; using SixLabors.ImageSharp.Drawing.Processing; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; -using EllieBot.Modules.Gambling; using EllieBot.Common.TypeReaders; -using EllieBot.Modules.Utility; using Color = SixLabors.ImageSharp.Color; using Image = SixLabors.ImageSharp.Image; @@ -25,9 +23,6 @@ public partial class Gambling [Group] public partial class SlotCommands : GamblingSubmodule { - private static decimal totalBet; - private static decimal totalPaidOut; - private readonly IImageCache _images; private readonly FontProvider _fonts; private readonly DbService _db; @@ -71,17 +66,19 @@ public partial class Gambling var eb = _sender.CreateEmbed() - .WithAuthor(ctx.User) - .WithDescription(Format.Bold(text)) - .WithImageUrl($"attachment://result.png") - .WithOkColor(); + .WithAuthor(ctx.User) + .WithDescription(Format.Bold(text)) + .WithImageUrl($"attachment://result.png") + .WithOkColor(); var bb = new ButtonBuilder(emote: Emoji.Parse("🔁"), customId: "slot:again", label: "Pull Again"); - var inter = _inter.Create(ctx.User.Id, bb, smc => - { - smc.DeferAsync(); - return Slot(amount); - }); + var inter = _inter.Create(ctx.User.Id, + bb, + smc => + { + smc.DeferAsync(); + return Slot(amount); + }); var msg = await ctx.Channel.SendFileAsync(imgStream, "result.png", @@ -161,12 +158,6 @@ public partial class Gambling { return null; } - - lock (_slotStatsLock) - { - totalBet += amount; - totalPaidOut += result.Won; - } return result; } @@ -213,7 +204,7 @@ public partial class Gambling { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, - Origin = new(393, 480) + Origin = new(393, 480) }, ownedAmount.ToString(), fontColor)); diff --git a/src/EllieBot/Modules/Gambling/Waifus/WaifuClaimCommands.cs b/src/EllieBot/Modules/Gambling/Waifus/WaifuClaimCommands.cs index 19b1dc5..d488e72 100644 --- a/src/EllieBot/Modules/Gambling/Waifus/WaifuClaimCommands.cs +++ b/src/EllieBot/Modules/Gambling/Waifus/WaifuClaimCommands.cs @@ -3,7 +3,7 @@ using EllieBot.Modules.Gambling.Common; using EllieBot.Modules.Gambling.Common.Waifu; using EllieBot.Modules.Gambling.Services; using EllieBot.Db.Models; -using TwitchLib.Api.Helix.Models.Teams; +using System.Globalization; namespace EllieBot.Modules.Gambling; @@ -153,12 +153,12 @@ public partial class Gambling await Response().Confirm(strs.waifu_divorced_notlike(N(amount))).SendAsync(); else if (result == DivorceResult.NotYourWife) await Response().Error(strs.waifu_not_yours).SendAsync(); - else + else if (remaining is { } rem) { await Response() .Error(strs.waifu_recent_divorce( - Format.Bold(((int)remaining?.TotalHours).ToString()), - Format.Bold(remaining?.Minutes.ToString()))) + Format.Bold(((int)rem.TotalHours).ToString()), + Format.Bold(rem.Minutes.ToString()))) .SendAsync(); } } @@ -238,7 +238,7 @@ public partial class Gambling private string GetLbString(WaifuLbResult w) { var claimer = "no one"; - var status = string.Empty; + string status; var waifuUsername = w.Username.TrimTo(20); var claimerUsername = w.Claimer?.TrimTo(20); @@ -377,7 +377,8 @@ public partial class Gambling if (sucess) { await Response() - .Confirm(strs.waifu_gift(Format.Bold($"{GetCountString(items)}{items.Item} {items.Item.ItemEmoji}"), + .Confirm(strs.waifu_gift( + Format.Bold($"{GetCountString(items)}{items.Item} {items.Item.ItemEmoji}"), Format.Bold(waifu.ToString()))) .SendAsync(); } diff --git a/src/EllieBot/Modules/Gambling/Waifus/WaifuService.cs b/src/EllieBot/Modules/Gambling/Waifus/WaifuService.cs index ab5e021..502a260 100644 --- a/src/EllieBot/Modules/Gambling/Waifus/WaifuService.cs +++ b/src/EllieBot/Modules/Gambling/Waifus/WaifuService.cs @@ -3,11 +3,9 @@ using LinqToDB; using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Db.Models; using EllieBot.Modules.Gambling.Common; using EllieBot.Modules.Gambling.Common.Waifu; -using SixLabors.ImageSharp; namespace EllieBot.Modules.Gambling.Services; diff --git a/src/EllieBot/Modules/Gambling/_common/IGamblingService.cs b/src/EllieBot/Modules/Gambling/_common/IGamblingService.cs index 4ed31c9..77cc2d7 100644 --- a/src/EllieBot/Modules/Gambling/_common/IGamblingService.cs +++ b/src/EllieBot/Modules/Gambling/_common/IGamblingService.cs @@ -1,5 +1,4 @@ #nullable disable -using EllieBot.Modules.Gambling; using EllieBot.Modules.Gambling.Betdraw; using EllieBot.Modules.Gambling.Rps; using OneOf; diff --git a/src/EllieBot/Modules/Gambling/_common/NewGamblingService.cs b/src/EllieBot/Modules/Gambling/_common/NewGamblingService.cs index 2412503..85fa703 100644 --- a/src/EllieBot/Modules/Gambling/_common/NewGamblingService.cs +++ b/src/EllieBot/Modules/Gambling/_common/NewGamblingService.cs @@ -1,5 +1,4 @@ #nullable disable -using EllieBot.Modules.Gambling; using EllieBot.Modules.Gambling.Betdraw; using EllieBot.Modules.Gambling.Rps; using EllieBot.Modules.Gambling.Services; diff --git a/src/EllieBot/Modules/Gambling/_common/TypeReaders/BaseShmartInputAmountReader.cs b/src/EllieBot/Modules/Gambling/_common/TypeReaders/BaseShmartInputAmountReader.cs index 42c6f09..6773b78 100644 --- a/src/EllieBot/Modules/Gambling/_common/TypeReaders/BaseShmartInputAmountReader.cs +++ b/src/EllieBot/Modules/Gambling/_common/TypeReaders/BaseShmartInputAmountReader.cs @@ -1,5 +1,4 @@ using System.Text.RegularExpressions; -using EllieBot.Db; using EllieBot.Db.Models; using EllieBot.Modules.Gambling.Services; using NCalc; diff --git a/src/EllieBot/Modules/Games/ChatterBot/ChatterBotCommands.cs b/src/EllieBot/Modules/Games/ChatterBot/ChatterBotCommands.cs index 7f7f2cb..ea902c2 100644 --- a/src/EllieBot/Modules/Games/ChatterBot/ChatterBotCommands.cs +++ b/src/EllieBot/Modules/Games/ChatterBot/ChatterBotCommands.cs @@ -1,7 +1,5 @@ #nullable disable -using EllieBot.Db; using EllieBot.Modules.Games.Services; -using EllieBot.Db.Models; namespace EllieBot.Modules.Games; diff --git a/src/EllieBot/Modules/Games/ChatterBot/_common/ThinkResponse.cs b/src/EllieBot/Modules/Games/ChatterBot/_common/ThinkResult.cs similarity index 90% rename from src/EllieBot/Modules/Games/ChatterBot/_common/ThinkResponse.cs rename to src/EllieBot/Modules/Games/ChatterBot/_common/ThinkResult.cs index a5b0b5f..d6aa75e 100644 --- a/src/EllieBot/Modules/Games/ChatterBot/_common/ThinkResponse.cs +++ b/src/EllieBot/Modules/Games/ChatterBot/_common/ThinkResult.cs @@ -1,6 +1,4 @@ #nullable disable -using System.CodeDom; - namespace EllieBot.Modules.Games.Common.ChatterBot; public sealed class ThinkResult diff --git a/src/EllieBot/Modules/Games/GamesService.cs b/src/EllieBot/Modules/Games/GamesService.cs index 9f4f61b..1436285 100644 --- a/src/EllieBot/Modules/Games/GamesService.cs +++ b/src/EllieBot/Modules/Games/GamesService.cs @@ -1,6 +1,5 @@ #nullable disable using Microsoft.Extensions.Caching.Memory; -using EllieBot.Common.ModuleBehaviors; using EllieBot.Modules.Games.Common; using EllieBot.Modules.Games.Common.Acrophobia; using EllieBot.Modules.Games.Common.Nunchi; @@ -8,11 +7,10 @@ using Newtonsoft.Json; namespace EllieBot.Modules.Games.Services; -public class GamesService : IEService, IReadyExecutor +public class GamesService : IEService { private const string TYPING_ARTICLES_PATH = "data/typing_articles3.json"; - public ConcurrentDictionary GirlRatings { get; } = new(); public IReadOnlyList EightBallResponses => _gamesConfig.Data.EightBallResponses; @@ -25,7 +23,6 @@ public class GamesService : IEService, IReadyExecutor public ConcurrentDictionary RunningContests { get; } = new(); public ConcurrentDictionary NunchiGames { get; } = new(); - public AsyncLazy Ratings { get; } private readonly GamesConfigService _gamesConfig; private readonly IHttpClientFactory _httpFactory; @@ -41,7 +38,6 @@ public class GamesService : IEService, IReadyExecutor SizeLimit = 500_000 }); - Ratings = new(GetRatingTexts); _rng = new EllieRandom(); try @@ -55,22 +51,6 @@ public class GamesService : IEService, IReadyExecutor } } - public async Task OnReadyAsync() - { - // reset rating once a day - using var timer = new PeriodicTimer(TimeSpan.FromDays(1)); - while (await timer.WaitForNextTickAsync()) - GirlRatings.Clear(); - } - - private async Task GetRatingTexts() - { - using var http = _httpFactory.CreateClient(); - var text = await http.GetStringAsync( - "https://nadeko-pictures.nyc3.digitaloceanspaces.com/other/rategirl/rates.json"); - return JsonConvert.DeserializeObject(text); - } - public void AddTypingArticle(IUser user, string text) { TypingArticles.Add(new() @@ -104,15 +84,4 @@ public class GamesService : IEService, IReadyExecutor File.WriteAllText(TYPING_ARTICLES_PATH, JsonConvert.SerializeObject(articles)); return removed; } - - public class RatingTexts - { - public string Nog { get; set; } - public string Tra { get; set; } - public string Fun { get; set; } - public string Uni { get; set; } - public string Wif { get; set; } - public string Dat { get; set; } - public string Dan { get; set; } - } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Games/GirlRating.cs b/src/EllieBot/Modules/Games/GirlRating.cs deleted file mode 100644 index 4576216..0000000 --- a/src/EllieBot/Modules/Games/GirlRating.cs +++ /dev/null @@ -1,61 +0,0 @@ -#nullable disable -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Processing; -using Image = SixLabors.ImageSharp.Image; - -namespace EllieBot.Modules.Games.Common; - -public class GirlRating -{ - public double Crazy { get; } - public double Hot { get; } - public int Roll { get; } - public string Advice { get; } - - public AsyncLazy Stream { get; } - private readonly IImageCache _images; - - public GirlRating( - IImageCache images, - double crazy, - double hot, - int roll, - string advice) - { - _images = images; - Crazy = crazy; - Hot = hot; - Roll = roll; - Advice = advice; // convenient to have it here, even though atm there are only few different ones. - - Stream = new(async () => - { - try - { - var bgBytes = await _images.GetRategirlBgAsync(); - using var img = Image.Load(bgBytes); - const int minx = 35; - const int miny = 385; - const int length = 345; - - var pointx = (int)(minx + (length * (Hot / 10))); - var pointy = (int)(miny - (length * ((Crazy - 4) / 6))); - - var dotBytes = await _images.GetRategirlDotAsync(); - using (var pointImg = Image.Load(dotBytes)) - { - img.Mutate(x => x.DrawImage(pointImg, new(pointx - 10, pointy - 10), new GraphicsOptions())); - } - - var imgStream = new MemoryStream(); - img.SaveAsPng(imgStream); - return imgStream; - } - catch (Exception ex) - { - Log.Warning(ex, "Error getting RateGirl image"); - return null; - } - }); - } -} \ No newline at end of file diff --git a/src/EllieBot/Modules/Games/Trivia/Games.cs b/src/EllieBot/Modules/Games/Trivia/TriviaCommands.cs similarity index 98% rename from src/EllieBot/Modules/Games/Trivia/Games.cs rename to src/EllieBot/Modules/Games/Trivia/TriviaCommands.cs index ff7ffbd..72b4eb4 100644 --- a/src/EllieBot/Modules/Games/Trivia/Games.cs +++ b/src/EllieBot/Modules/Games/Trivia/TriviaCommands.cs @@ -107,9 +107,9 @@ public partial class Games return sb.ToString(); } - private EmbedBuilder? questionEmbed = null; - private IUserMessage? questionMessage = null; - private bool showHowToQuit = false; + private EmbedBuilder? questionEmbed; + private IUserMessage? questionMessage; + private bool showHowToQuit; private void RegisterEvents(TriviaGame trivia) { diff --git a/src/EllieBot/Modules/Games/Trivia/TriviaGame.cs b/src/EllieBot/Modules/Games/Trivia/TriviaGame.cs index 4223104..07c4ab4 100644 --- a/src/EllieBot/Modules/Games/Trivia/TriviaGame.cs +++ b/src/EllieBot/Modules/Games/Trivia/TriviaGame.cs @@ -11,12 +11,19 @@ public sealed class TriviaGame private readonly IQuestionPool _questionPool; #region Events + public event Func OnQuestion = static delegate { return Task.CompletedTask; }; public event Func OnHint = static delegate { return Task.CompletedTask; }; public event Func OnStats = static delegate { return Task.CompletedTask; }; - public event Func OnGuess = static delegate { return Task.CompletedTask; }; + + public event Func OnGuess = static delegate + { + return Task.CompletedTask; + }; + public event Func OnTimeout = static delegate { return Task.CompletedTask; }; public event Func OnEnded = static delegate { return Task.CompletedTask; }; + #endregion private bool _isStopped; @@ -24,7 +31,7 @@ public sealed class TriviaGame public TriviaQuestion? CurrentQuestion { get; set; } - private readonly ConcurrentDictionary _users = new (); + private readonly ConcurrentDictionary _users = new(); private readonly Channel<(TriviaUser User, string Input)> _inputs = Channel.CreateUnbounded<(TriviaUser, string)>(new UnboundedChannelOptions @@ -41,8 +48,8 @@ public sealed class TriviaGame _questionPool = _opts.IsPokemon ? new PokemonQuestionPool(cache) : new DefaultQuestionPool(cache); - } + public async Task RunAsync() { await GameLoop(); @@ -50,7 +57,8 @@ public sealed class TriviaGame private async Task GameLoop() { - Task TimeOutFactory() => Task.Delay(_opts.QuestionTimer * 1000 / 2); + Task TimeOutFactory() + => Task.Delay(_opts.QuestionTimer * 1000 / 2); var errorCount = 0; var inactivity = 0; @@ -91,7 +99,8 @@ public sealed class TriviaGame { // clear out all of the past guesses while (_inputs.Reader.TryRead(out _)) - ; + { + } await OnQuestion(this, question); } @@ -121,7 +130,7 @@ public sealed class TriviaGame if (task == halfGuessTimerTask) { readCancel.Cancel(); - + // if hint is already sent, means time expired // break (end the round) if (hintSent) @@ -213,7 +222,7 @@ public sealed class TriviaGame public async Task TriggerQuestionAsync() { - if(CurrentQuestion is TriviaQuestion q) + if (CurrentQuestion is TriviaQuestion q) await OnQuestion(this, q); } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Help/Help.cs b/src/EllieBot/Modules/Help/Help.cs index f8fe29b..95fabd6 100644 --- a/src/EllieBot/Modules/Help/Help.cs +++ b/src/EllieBot/Modules/Help/Help.cs @@ -509,6 +509,7 @@ public sealed partial class Help : EllieModule // send the indented file to chat await using var rDataStream = new MemoryStream(Encoding.ASCII.GetBytes(readableData)); + await File.WriteAllTextAsync("data/commandlist.json", readableData); await ctx.Channel.SendFileAsync(rDataStream, "cmds.json", GetText(strs.commandlist_regen)); } diff --git a/src/EllieBot/Modules/Music/Music.cs b/src/EllieBot/Modules/Music/Music.cs index a36c440..3b1393c 100644 --- a/src/EllieBot/Modules/Music/Music.cs +++ b/src/EllieBot/Modules/Music/Music.cs @@ -1,7 +1,6 @@ #nullable disable using EllieBot.Modules.Music.Services; using EllieBot.Db.Models; -using EllieBot.Modules.Utility; namespace EllieBot.Modules.Music; diff --git a/src/EllieBot/Modules/Music/PlaylistCommands.cs b/src/EllieBot/Modules/Music/PlaylistCommands.cs index 259bb9e..0e4137b 100644 --- a/src/EllieBot/Modules/Music/PlaylistCommands.cs +++ b/src/EllieBot/Modules/Music/PlaylistCommands.cs @@ -1,6 +1,5 @@ #nullable disable using LinqToDB; -using EllieBot.Db; using EllieBot.Modules.Music.Services; using EllieBot.Db.Models; diff --git a/src/EllieBot/Modules/Music/Services/MusicService.cs b/src/EllieBot/Modules/Music/Services/MusicService.cs index c92d8de..8495211 100644 --- a/src/EllieBot/Modules/Music/Services/MusicService.cs +++ b/src/EllieBot/Modules/Music/Services/MusicService.cs @@ -1,5 +1,4 @@ -using EllieBot.Db; -using EllieBot.Db.Models; +using EllieBot.Db.Models; using System.Diagnostics.CodeAnalysis; namespace EllieBot.Modules.Music.Services; diff --git a/src/EllieBot/Modules/Music/_common/Resolvers/RadioResolveStrategy.cs b/src/EllieBot/Modules/Music/_common/Resolvers/RadioResolveStrategy.cs index c3733a4..475b026 100644 --- a/src/EllieBot/Modules/Music/_common/Resolvers/RadioResolveStrategy.cs +++ b/src/EllieBot/Modules/Music/_common/Resolvers/RadioResolveStrategy.cs @@ -61,8 +61,8 @@ public class RadioResolver : IRadioResolver try { var m = _m3URegex.Match(file); - var res = m.Groups["url"]?.ToString(); - return res?.Trim(); + var res = m.Groups["url"].ToString(); + return res.Trim(); } catch { @@ -76,8 +76,8 @@ public class RadioResolver : IRadioResolver try { var m = _asxRegex.Match(file); - var res = m.Groups["url"]?.ToString(); - return res?.Trim(); + var res = m.Groups["url"].ToString(); + return res.Trim(); } catch { @@ -91,8 +91,8 @@ public class RadioResolver : IRadioResolver try { var m = _xspfRegex.Match(file); - var res = m.Groups["url"]?.ToString(); - return res?.Trim(); + var res = m.Groups["url"].ToString(); + return res.Trim(); } catch { diff --git a/src/EllieBot/Modules/Patronage/PatronageService.cs b/src/EllieBot/Modules/Patronage/PatronageService.cs index e6d7899..0ea46e4 100644 --- a/src/EllieBot/Modules/Patronage/PatronageService.cs +++ b/src/EllieBot/Modules/Patronage/PatronageService.cs @@ -2,8 +2,6 @@ using LinqToDB.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; using EllieBot.Db.Models; -using StackExchange.Redis; -using System.Diagnostics; namespace EllieBot.Modules.Patronage; @@ -21,16 +19,11 @@ public sealed class PatronageService public int Priority => int.MinValue; - private static readonly PatronTier[] _tiers = Enum.GetValues(); - private readonly PatronageConfig _pConf; private readonly DbService _db; private readonly DiscordSocketClient _client; private readonly ISubscriptionHandler _subsHandler; - private static readonly TypedKey _quotaKey - = new($"quota:last_hourly_reset"); - private readonly IBotCache _cache; private readonly IBotCredsProvider _creds; private readonly IMessageSenderService _sender; @@ -135,19 +128,19 @@ public sealed class PatronageService // user is charged again for this month // if his sub would end in teh future, extend it by one month. // if it's not, just add 1 month to the last charge date - var count = await ctx.GetTable() - .Where(x => x.UniquePlatformUserId - == subscriber.UniquePlatformUserId) - .UpdateAsync(old => new() - { - UserId = subscriber.UserId, - AmountCents = subscriber.Cents, - LastCharge = lastChargeUtc, - ValidThru = old.ValidThru >= todayDate - // ? Sql.DateAdd(Sql.DateParts.Month, 1, old.ValidThru).Value - ? old.ValidThru.AddMonths(1) - : dateInOneMonth, - }); + await ctx.GetTable() + .Where(x => x.UniquePlatformUserId + == subscriber.UniquePlatformUserId) + .UpdateAsync(old => new() + { + UserId = subscriber.UserId, + AmountCents = subscriber.Cents, + LastCharge = lastChargeUtc, + ValidThru = old.ValidThru >= todayDate + // ? Sql.DateAdd(Sql.DateParts.Month, 1, old.ValidThru).Value + ? old.ValidThru.AddMonths(1) + : dateInOneMonth, + }); dbPatron.UserId = subscriber.UserId; @@ -332,7 +325,7 @@ public sealed class PatronageService { if (!_pConf.Data.IsEnabled) return _infiniteQuota; - + var maybePatron = await GetPatronAsync(userId); if (maybePatron is not { } patron) diff --git a/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdService.cs b/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdService.cs index 9f5c6e2..55eb64d 100644 --- a/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdService.cs +++ b/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdService.cs @@ -1,6 +1,5 @@ using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; namespace EllieBot.Modules.Permissions.Services; diff --git a/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdsCommands.cs b/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdsCommands.cs index e2c1427..a9b7a13 100644 --- a/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdsCommands.cs +++ b/src/EllieBot/Modules/Permissions/CommandCooldown/CmdCdsCommands.cs @@ -1,7 +1,6 @@ #nullable disable using Microsoft.EntityFrameworkCore; using EllieBot.Common.TypeReaders; -using EllieBot.Db; using EllieBot.Modules.Permissions.Services; using EllieBot.Db.Models; diff --git a/src/EllieBot/Modules/Permissions/Filter/FilterCommands.cs b/src/EllieBot/Modules/Permissions/Filter/FilterCommands.cs index cdd3cad..fab1a11 100644 --- a/src/EllieBot/Modules/Permissions/Filter/FilterCommands.cs +++ b/src/EllieBot/Modules/Permissions/Filter/FilterCommands.cs @@ -1,6 +1,5 @@ #nullable disable using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Modules.Permissions.Services; using EllieBot.Db.Models; diff --git a/src/EllieBot/Modules/Permissions/Filter/FilterService.cs b/src/EllieBot/Modules/Permissions/Filter/FilterService.cs index 139d0d5..dd5fbc0 100644 --- a/src/EllieBot/Modules/Permissions/Filter/FilterService.cs +++ b/src/EllieBot/Modules/Permissions/Filter/FilterService.cs @@ -1,7 +1,6 @@ #nullable disable using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Db.Models; namespace EllieBot.Modules.Permissions.Services; diff --git a/src/EllieBot/Modules/Permissions/Permissions.cs b/src/EllieBot/Modules/Permissions/Permissions.cs index 447dd19..5fb6fb2 100644 --- a/src/EllieBot/Modules/Permissions/Permissions.cs +++ b/src/EllieBot/Modules/Permissions/Permissions.cs @@ -1,7 +1,6 @@ #nullable disable using EllieBot.Common.TypeReaders; using EllieBot.Common.TypeReaders.Models; -using EllieBot.Db; using EllieBot.Modules.Permissions.Common; using EllieBot.Modules.Permissions.Services; using EllieBot.Db.Models; diff --git a/src/EllieBot/Modules/Permissions/PermissionsService.cs b/src/EllieBot/Modules/Permissions/PermissionsService.cs index 95b6388..e0ac658 100644 --- a/src/EllieBot/Modules/Permissions/PermissionsService.cs +++ b/src/EllieBot/Modules/Permissions/PermissionsService.cs @@ -1,7 +1,6 @@ #nullable disable using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Modules.Permissions.Common; using EllieBot.Db.Models; diff --git a/src/EllieBot/Modules/Searches/Anime/AnimeSearchCommands.cs b/src/EllieBot/Modules/Searches/Anime/AnimeSearchCommands.cs index 8acae72..d86cd14 100644 --- a/src/EllieBot/Modules/Searches/Anime/AnimeSearchCommands.cs +++ b/src/EllieBot/Modules/Searches/Anime/AnimeSearchCommands.cs @@ -10,133 +10,6 @@ public partial class Searches [Group] public partial class AnimeSearchCommands : EllieModule { - // [EllieCommand, Aliases] - // public async Task Novel([Leftover] string query) - // { - // if (string.IsNullOrWhiteSpace(query)) - // return; - // - // var novelData = await _service.GetNovelData(query); - // - // if (novelData is null) - // { - // await Response().Error(strs.failed_finding_novel).SendAsync(); - // return; - // } - // - // var embed = _sender.CreateEmbed() - // .WithOkColor() - // .WithDescription(novelData.Description.Replace("
", Environment.NewLine, StringComparison.InvariantCulture)) - // .WithTitle(novelData.Title) - // .WithUrl(novelData.Link) - // .WithImageUrl(novelData.ImageUrl) - // .AddField(GetText(strs.authors), string.Join("\n", novelData.Authors), true) - // .AddField(GetText(strs.status), novelData.Status, true) - // .AddField(GetText(strs.genres), string.Join(" ", novelData.Genres.Any() ? novelData.Genres : new[] { "none" }), true) - // .WithFooter($"{GetText(strs.score)} {novelData.Score}"); - // - // await Response().Embed(embed).SendAsync(); - // } - - [Cmd] - [Priority(0)] - public async Task Mal([Leftover] string name) - { - if (string.IsNullOrWhiteSpace(name)) - return; - - var fullQueryLink = "https://myanimelist.net/profile/" + name; - - var config = Configuration.Default.WithDefaultLoader(); - using var document = await BrowsingContext.New(config).OpenAsync(fullQueryLink); - var imageElem = - document.QuerySelector( - "body > div#myanimelist > div.wrapper > div#contentWrapper > div#content > div.content-container > div.container-left > div.user-profile > div.user-image > img"); - var imageUrl = ((IHtmlImageElement)imageElem)?.Source - ?? "http://icecream.me/uploads/870b03f36b59cc16ebfe314ef2dde781.png"; - - var stats = document - .QuerySelectorAll( - "body > div#myanimelist > div.wrapper > div#contentWrapper > div#content > div.content-container > div.container-right > div#statistics > div.user-statistics-stats > div.stats > div.clearfix > ul.stats-status > li > span") - .Select(x => x.InnerHtml) - .ToList(); - - var favorites = document.QuerySelectorAll("div.user-favorites > div.di-tc"); - - var favAnime = GetText(strs.anime_no_fav); - if (favorites.Length > 0 && favorites[0].QuerySelector("p") is null) - { - favAnime = string.Join("\n", - favorites[0] - .QuerySelectorAll("ul > li > div.di-tc.va-t > a") - .Shuffle() - .Take(3) - .Select(x => - { - var elem = (IHtmlAnchorElement)x; - return $"[{elem.InnerHtml}]({elem.Href})"; - })); - } - - var info = document.QuerySelectorAll("ul.user-status:nth-child(3) > li.clearfix") - .Select(x => Tuple.Create(x.Children[0].InnerHtml, x.Children[1].InnerHtml)) - .ToList(); - - var daysAndMean = document.QuerySelectorAll("div.anime:nth-child(1) > div:nth-child(2) > div") - .Select(x => x.TextContent.Split(':').Select(y => y.Trim()).ToArray()) - .ToArray(); - - var embed = _sender.CreateEmbed() - .WithOkColor() - .WithTitle(GetText(strs.mal_profile(name))) - .AddField("💚 " + GetText(strs.watching), stats[0], true) - .AddField("💙 " + GetText(strs.completed), stats[1], true); - if (info.Count < 3) - embed.AddField("💛 " + GetText(strs.on_hold), stats[2], true); - embed.AddField("💔 " + GetText(strs.dropped), stats[3], true) - .AddField("⚪ " + GetText(strs.plan_to_watch), stats[4], true) - .AddField("🕐 " + daysAndMean[0][0], daysAndMean[0][1], true) - .AddField("📊 " + daysAndMean[1][0], daysAndMean[1][1], true) - .AddField(MalInfoToEmoji(info[0].Item1) + " " + info[0].Item1, info[0].Item2.TrimTo(20), true) - .AddField(MalInfoToEmoji(info[1].Item1) + " " + info[1].Item1, info[1].Item2.TrimTo(20), true); - if (info.Count > 2) - embed.AddField(MalInfoToEmoji(info[2].Item1) + " " + info[2].Item1, info[2].Item2.TrimTo(20), true); - - embed.WithDescription($@" -** https://myanimelist.net/animelist/{name} ** - -**{GetText(strs.top_3_fav_anime)}** -{favAnime}") - .WithUrl(fullQueryLink) - .WithImageUrl(imageUrl); - - await Response().Embed(embed).SendAsync(); - } - - private static string MalInfoToEmoji(string info) - { - info = info.Trim().ToLowerInvariant(); - switch (info) - { - case "gender": - return "🚁"; - case "location": - return "🗺"; - case "last online": - return "👥"; - case "birthday": - return "📆"; - default: - return "❔"; - } - } - - [Cmd] - [RequireContext(ContextType.Guild)] - [Priority(1)] - public Task Mal(IGuildUser usr) - => Mal(usr.Username); - [Cmd] public async Task Anime([Leftover] string query) { @@ -152,19 +25,19 @@ public partial class Searches } var embed = _sender.CreateEmbed() - .WithOkColor() - .WithDescription(animeData.Synopsis.Replace("
", - Environment.NewLine, - StringComparison.InvariantCulture)) - .WithTitle(animeData.TitleEnglish) - .WithUrl(animeData.Link) - .WithImageUrl(animeData.ImageUrlLarge) - .AddField(GetText(strs.episodes), animeData.TotalEpisodes.ToString(), true) - .AddField(GetText(strs.status), animeData.AiringStatus, true) - .AddField(GetText(strs.genres), - string.Join(",\n", animeData.Genres.Any() ? animeData.Genres : ["none"]), - true) - .WithFooter($"{GetText(strs.score)} {animeData.AverageScore} / 100"); + .WithOkColor() + .WithDescription(animeData.Synopsis.Replace("
", + Environment.NewLine, + StringComparison.InvariantCulture)) + .WithTitle(animeData.TitleEnglish) + .WithUrl(animeData.Link) + .WithImageUrl(animeData.ImageUrlLarge) + .AddField(GetText(strs.episodes), animeData.TotalEpisodes.ToString(), true) + .AddField(GetText(strs.status), animeData.AiringStatus, true) + .AddField(GetText(strs.genres), + string.Join(",\n", animeData.Genres.Any() ? animeData.Genres : ["none"]), + true) + .WithFooter($"{GetText(strs.score)} {animeData.AverageScore} / 100"); await Response().Embed(embed).SendAsync(); } @@ -184,19 +57,19 @@ public partial class Searches } var embed = _sender.CreateEmbed() - .WithOkColor() - .WithDescription(mangaData.Synopsis.Replace("
", - Environment.NewLine, - StringComparison.InvariantCulture)) - .WithTitle(mangaData.TitleEnglish) - .WithUrl(mangaData.Link) - .WithImageUrl(mangaData.ImageUrlLge) - .AddField(GetText(strs.chapters), mangaData.TotalChapters.ToString(), true) - .AddField(GetText(strs.status), mangaData.PublishingStatus, true) - .AddField(GetText(strs.genres), - string.Join(",\n", mangaData.Genres.Any() ? mangaData.Genres : ["none"]), - true) - .WithFooter($"{GetText(strs.score)} {mangaData.AverageScore} / 100"); + .WithOkColor() + .WithDescription(mangaData.Synopsis.Replace("
", + Environment.NewLine, + StringComparison.InvariantCulture)) + .WithTitle(mangaData.TitleEnglish) + .WithUrl(mangaData.Link) + .WithImageUrl(mangaData.ImageUrlLge) + .AddField(GetText(strs.chapters), mangaData.TotalChapters.ToString(), true) + .AddField(GetText(strs.status), mangaData.PublishingStatus, true) + .AddField(GetText(strs.genres), + string.Join(",\n", mangaData.Genres.Any() ? mangaData.Genres : ["none"]), + true) + .WithFooter($"{GetText(strs.score)} {mangaData.AverageScore} / 100"); await Response().Embed(embed).SendAsync(); } diff --git a/src/EllieBot/Modules/Searches/Crypto/CryptoCommands.cs b/src/EllieBot/Modules/Searches/Crypto/CryptoCommands.cs index 1bb8910..290685d 100644 --- a/src/EllieBot/Modules/Searches/Crypto/CryptoCommands.cs +++ b/src/EllieBot/Modules/Searches/Crypto/CryptoCommands.cs @@ -65,18 +65,6 @@ public partial class Searches var change = (stock.Price - stock.Close).ToString("N2", Culture); var changePercent = (1 - (stock.Close / stock.Price)).ToString("P1", Culture); - var sign50 = stock.Change50d >= 0 - ? "\\🔼" - : "\\🔻"; - - var change50 = (stock.Change50d).ToString("P1", Culture); - - var sign200 = stock.Change200d >= 0 - ? "\\🔼" - : "\\🔻"; - - var change200 = (stock.Change200d).ToString("P1", Culture); - var price = stock.Price.ToString("C2", localCulture); var eb = _sender.CreateEmbed() diff --git a/src/EllieBot/Modules/Searches/Crypto/CryptoService.cs b/src/EllieBot/Modules/Searches/Crypto/CryptoService.cs index 59463fa..f5271d6 100644 --- a/src/EllieBot/Modules/Searches/Crypto/CryptoService.cs +++ b/src/EllieBot/Modules/Searches/Crypto/CryptoService.cs @@ -4,13 +4,11 @@ using SixLabors.ImageSharp; using SixLabors.ImageSharp.Drawing.Processing; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; -using System.Collections.ObjectModel; using System.Globalization; using System.Net.Http.Json; using System.Text.Json.Serialization; using System.Xml; using Color = SixLabors.ImageSharp.Color; -using StringExtensions = EllieBot.Extensions.StringExtensions; namespace EllieBot.Modules.Searches.Services; diff --git a/src/EllieBot/Modules/Searches/Crypto/DefaultStockDataService.cs b/src/EllieBot/Modules/Searches/Crypto/DefaultStockDataService.cs index feb0548..9b000bd 100644 --- a/src/EllieBot/Modules/Searches/Crypto/DefaultStockDataService.cs +++ b/src/EllieBot/Modules/Searches/Crypto/DefaultStockDataService.cs @@ -1,7 +1,6 @@ using AngleSharp; using CsvHelper; using CsvHelper.Configuration; -using System.Diagnostics; using System.Globalization; using System.Text.Json; diff --git a/src/EllieBot/Modules/Searches/Feeds/FeedsService.cs b/src/EllieBot/Modules/Searches/Feeds/FeedsService.cs index 43ad71f..d08ec0a 100644 --- a/src/EllieBot/Modules/Searches/Feeds/FeedsService.cs +++ b/src/EllieBot/Modules/Searches/Feeds/FeedsService.cs @@ -4,7 +4,6 @@ using CodeHollow.FeedReader.Feeds; using LinqToDB; using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Db.Models; namespace EllieBot.Modules.Searches.Services; diff --git a/src/EllieBot/Modules/Searches/MemegenCommands.cs b/src/EllieBot/Modules/Searches/MemegenCommands.cs deleted file mode 100644 index dbe2679..0000000 --- a/src/EllieBot/Modules/Searches/MemegenCommands.cs +++ /dev/null @@ -1,99 +0,0 @@ -#nullable disable -using Newtonsoft.Json; -using System.Collections.Immutable; -using System.Text; - -namespace EllieBot.Modules.Searches; - -public partial class Searches -{ - [Group] - public partial class MemegenCommands : EllieModule - { - private static readonly ImmutableDictionary _map = new Dictionary - { - { '?', "~q" }, - { '%', "~p" }, - { '#', "~h" }, - { '/', "~s" }, - { ' ', "-" }, - { '-', "--" }, - { '_', "__" }, - { '"', "''" } - }.ToImmutableDictionary(); - - private readonly IHttpClientFactory _httpFactory; - - public MemegenCommands(IHttpClientFactory factory) - => _httpFactory = factory; - - [Cmd] - public async Task Memelist(int page = 1) - { - if (--page < 0) - return; - - using var http = _httpFactory.CreateClient("memelist"); - using var res = await http.GetAsync("https://api.memegen.link/templates/"); - - var rawJson = await res.Content.ReadAsStringAsync(); - - var data = JsonConvert.DeserializeObject>(rawJson)!; - - await Response() - .Paginated() - .Items(data) - .PageSize(15) - .CurrentPage(page) - .Page((items, curPage) => - { - var templates = string.Empty; - foreach (var template in items) - templates += $"**{template.Name}:**\n key: `{template.Id}`\n"; - var embed = _sender.CreateEmbed().WithOkColor().WithDescription(templates); - - return embed; - }) - .SendAsync(); - } - - [Cmd] - public async Task Memegen(string meme, [Leftover] string memeText = null) - { - var memeUrl = $"http://api.memegen.link/{meme}"; - if (!string.IsNullOrWhiteSpace(memeText)) - { - var memeTextArray = memeText.Split(';'); - foreach (var text in memeTextArray) - { - var newText = Replace(text); - memeUrl += $"/{newText}"; - } - } - - memeUrl += ".png"; - await Response().Text(memeUrl).SendAsync(); - } - - private static string Replace(string input) - { - var sb = new StringBuilder(); - - foreach (var c in input) - { - if (_map.TryGetValue(c, out var tmp)) - sb.Append(tmp); - else - sb.Append(c); - } - - return sb.ToString(); - } - - private class MemegenTemplate - { - public string Name { get; set; } - public string Id { get; set; } - } - } -} \ No newline at end of file diff --git a/src/EllieBot/Modules/Searches/Religious/ReligiousApiService.cs b/src/EllieBot/Modules/Searches/Religious/ReligiousApiService.cs index 07fbfa3..ccef2b8 100644 --- a/src/EllieBot/Modules/Searches/Religious/ReligiousApiService.cs +++ b/src/EllieBot/Modules/Searches/Religious/ReligiousApiService.cs @@ -1,5 +1,4 @@ -using EllieBot.Modules.Searches.Common; -using OneOf; +using OneOf; using OneOf.Types; using System.Net; using System.Net.Http.Json; diff --git a/src/EllieBot/Modules/Searches/Searches.cs b/src/EllieBot/Modules/Searches/Searches.cs index 845e2ad..70e2556 100644 --- a/src/EllieBot/Modules/Searches/Searches.cs +++ b/src/EllieBot/Modules/Searches/Searches.cs @@ -1,4 +1,3 @@ -#nullable disable using Microsoft.Extensions.Caching.Memory; using EllieBot.Modules.Searches.Common; using EllieBot.Modules.Searches.Services; @@ -14,7 +13,6 @@ namespace EllieBot.Modules.Searches; public partial class Searches : EllieModule { - private static readonly ConcurrentDictionary _cachedShortenedLinks = new(); private readonly IBotCredentials _creds; private readonly IGoogleApiService _google; private readonly IHttpClientFactory _httpFactory; @@ -115,7 +113,7 @@ public partial class Searches : EllieModule } [Cmd] - public async Task Movie([Leftover] string query = null) + public async Task Movie([Leftover] string query) { if (!await ValidateQuery(query)) return; @@ -167,12 +165,13 @@ public partial class Searches : EllieModule } [Cmd] - public async Task Lmgtfy([Leftover] string smh = null) + public async Task Lmgtfy([Leftover] string smh) { if (!await ValidateQuery(smh)) return; - var shortenedUrl = await _google.ShortenUrl($"https://letmegooglethat.com/?q={Uri.EscapeDataString(smh)}"); + var link = $"https://letmegooglethat.com/?q={Uri.EscapeDataString(smh)}"; + var shortenedUrl = await _service.ShortenLink(link) ?? link; await Response().Confirm($"<{shortenedUrl}>").SendAsync(); } @@ -182,35 +181,12 @@ public partial class Searches : EllieModule if (!await ValidateQuery(query)) return; - query = query.Trim(); - if (!_cachedShortenedLinks.TryGetValue(query, out var shortLink)) + var shortLink = await _service.ShortenLink(query); + + if (shortLink is null) { - try - { - using var http = _httpFactory.CreateClient(); - using var req = new HttpRequestMessage(HttpMethod.Post, "https://goolnk.com/api/v1/shorten"); - var formData = new MultipartFormDataContent - { - { new StringContent(query), "url" } - }; - req.Content = formData; - - using var res = await http.SendAsync(req); - var content = await res.Content.ReadAsStringAsync(); - var data = JsonConvert.DeserializeObject(content); - - if (!string.IsNullOrWhiteSpace(data?.ResultUrl)) - _cachedShortenedLinks.TryAdd(query, data.ResultUrl); - else - return; - - shortLink = data.ResultUrl; - } - catch (Exception ex) - { - Log.Error(ex, "Error shortening a link: {Message}", ex.Message); - return; - } + await Response().Error(strs.error_occured).SendAsync(); + return; } await Response() @@ -221,6 +197,7 @@ public partial class Searches : EllieModule .SendAsync(); } + [Cmd] public async Task MagicTheGathering([Leftover] string search) { @@ -278,45 +255,38 @@ public partial class Searches : EllieModule } [Cmd] - public async Task UrbanDict([Leftover] string query = null) + public async Task UrbanDict([Leftover] string query) { if (!await ValidateQuery(query)) return; await ctx.Channel.TriggerTypingAsync(); - using (var http = _httpFactory.CreateClient()) + using var http = _httpFactory.CreateClient(); + var res = await http.GetStringAsync($"https://api.urbandictionary.com/v0/define?" + + $"term={Uri.EscapeDataString(query)}"); + var allItems = JsonConvert.DeserializeObject(res)?.List; + + if (allItems is null or { Length: 0 }) { - var res = await http.GetStringAsync( - $"https://api.urbandictionary.com/v0/define?term={Uri.EscapeDataString(query)}"); - try - { - var allItems = JsonConvert.DeserializeObject(res).List; - if (allItems.Any()) - { - await Response() - .Paginated() - .Items(allItems) - .PageSize(1) - .CurrentPage(0) - .Page((items, _) => - { - var item = items[0]; - return _sender.CreateEmbed() - .WithOkColor() - .WithUrl(item.Permalink) - .WithTitle(item.Word) - .WithDescription(item.Definition); - }) - .SendAsync(); - return; - } - } - catch - { - } + await Response().Error(strs.ud_error).SendAsync(); + return; } - await Response().Error(strs.ud_error).SendAsync(); + await Response() + .Paginated() + .Items(allItems) + .PageSize(1) + .CurrentPage(0) + .Page((items, _) => + { + var item = items[0]; + return _sender.CreateEmbed() + .WithOkColor() + .WithUrl(item.Permalink) + .WithTitle(item.Word) + .WithDescription(item.Definition); + }) + .SendAsync(); } [Cmd] @@ -373,7 +343,7 @@ public partial class Searches : EllieModule [Cmd] public async Task Wiki([Leftover] string query) { - query = query?.Trim(); + query = query.Trim(); if (!await ValidateQuery(query)) return; @@ -415,16 +385,17 @@ public partial class Searches : EllieModule for (var i = 0; i < colorObjects.Length; i++) { var x = i * 50; - img.Mutate(m => m.FillPolygon(colorObjects[i], new(x, 0), new(x + 50, 0), new(x + 50, 50), new(x, 50))); + var j = i; + img.Mutate(m => m.FillPolygon(colorObjects[j], new(x, 0), new(x + 50, 0), new(x + 50, 50), new(x, 50))); } - await using var ms = img.ToStream(); + await using var ms = await img.ToStreamAsync(); await ctx.Channel.SendFileAsync(ms, "colors.png"); } [Cmd] [RequireContext(ContextType.Guild)] - public async Task Avatar([Leftover] IGuildUser usr = null) + public async Task Avatar([Leftover] IGuildUser? usr = null) { usr ??= (IGuildUser)ctx.User; @@ -487,10 +458,4 @@ public partial class Searches : EllieModule await Response().Error(strs.specify_search_params).SendAsync(); return false; } - - public class ShortenData - { - [JsonProperty("result_url")] - public string ResultUrl { get; set; } - } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Searches/SearchesService.cs b/src/EllieBot/Modules/Searches/SearchesService.cs index 3f01fc1..b8dd2e5 100644 --- a/src/EllieBot/Modules/Searches/SearchesService.cs +++ b/src/EllieBot/Modules/Searches/SearchesService.cs @@ -2,8 +2,8 @@ using EllieBot.Modules.Searches.Common; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using System.Text.Json; using OneOf; +using System.Text.Json; namespace EllieBot.Modules.Searches.Services; @@ -30,6 +30,7 @@ public class SearchesService : IEService private readonly object _yomamaLock = new(); private int yomamaJokeIndex; + private readonly ConcurrentDictionary _cachedShortenedLinks = new(); public SearchesService( IGoogleApiService google, @@ -578,4 +579,42 @@ public class SearchesService : IEService return ErrorType.Unknown; } } + + public async Task ShortenLink(string query) + { + query = query.Trim(); + + if (_cachedShortenedLinks.TryGetValue(query, out var shortLink)) + return shortLink; + + try + { + using var http = _httpFactory.CreateClient(); + using var req = new HttpRequestMessage(HttpMethod.Post, "https://goolnk.com/api/v1/shorten"); + var formData = new MultipartFormDataContent + { + { new StringContent(query), "url" } + }; + req.Content = formData; + + using var res = await http.SendAsync(req); + var content = await res.Content.ReadAsStringAsync(); + var data = JsonConvert.DeserializeObject(content); + + if (!string.IsNullOrWhiteSpace(data?.ResultUrl)) + _cachedShortenedLinks.TryAdd(query, data.ResultUrl); + else + return query; + + shortLink = data.ResultUrl; + } + catch (Exception ex) + { + Log.Error(ex, "Error shortening a link: {Message}", ex.Message); + return null; + } + + return shortLink; + throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs b/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs index 46f9ed6..0710956 100644 --- a/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs +++ b/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationCommands.cs @@ -1,6 +1,5 @@ #nullable disable using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Db.Models; using EllieBot.Modules.Searches.Services; diff --git a/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationService.cs b/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationService.cs index c003366..5d40000 100644 --- a/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationService.cs +++ b/src/EllieBot/Modules/Searches/StreamNotification/StreamNotificationService.cs @@ -1,7 +1,6 @@ #nullable disable using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Db.Models; using EllieBot.Modules.Searches.Common; using EllieBot.Modules.Searches.Common.StreamNotifications; diff --git a/src/EllieBot/Modules/Searches/_common/ShortenData.cs b/src/EllieBot/Modules/Searches/_common/ShortenData.cs new file mode 100644 index 0000000..b08435c --- /dev/null +++ b/src/EllieBot/Modules/Searches/_common/ShortenData.cs @@ -0,0 +1,10 @@ +#nullable disable +using Newtonsoft.Json; + +namespace EllieBot.Modules.Searches.Services; + +public class ShortenData +{ + [JsonProperty("result_url")] + public string ResultUrl { get; set; } +} \ No newline at end of file diff --git a/src/EllieBot/Modules/Utility/AfkService.cs b/src/EllieBot/Modules/Utility/AfkService.cs index d41169b..18c5f2c 100644 --- a/src/EllieBot/Modules/Utility/AfkService.cs +++ b/src/EllieBot/Modules/Utility/AfkService.cs @@ -74,7 +74,7 @@ public sealed class AfkService : IEService, IReadyExecutor private Task TryTriggerAfkMessage(SocketMessage arg) { - if (arg.Author.IsBot) + if (arg.Author.IsBot || arg.Author.IsWebhook) return Task.CompletedTask; if (arg is not IUserMessage uMsg || uMsg.Channel is not ITextChannel tc) @@ -126,12 +126,12 @@ public sealed class AfkService : IEService, IReadyExecutor { var st = SmartText.CreateFrom(msg); - st = "The user is AFK: " + st; + st = $"The user you've pinged (<#{mentionedUserId}>) is AFK: " + st; var toDelete = await _mss.Response(arg.Channel) + .User(arg.Author) .Message(uMsg) .Text(st) - .Sanitize(false) .SendAsync(); toDelete.DeleteAfter(30); diff --git a/src/EllieBot/Modules/Utility/Ai/UtilityCommands.cs b/src/EllieBot/Modules/Utility/Ai/UtilityCommands.cs index 52fe4d5..e4f3f04 100644 --- a/src/EllieBot/Modules/Utility/Ai/UtilityCommands.cs +++ b/src/EllieBot/Modules/Utility/Ai/UtilityCommands.cs @@ -1,6 +1,4 @@ -using EllieBot.Modules.Administration; - -namespace EllieBot.Modules.Utility; +namespace EllieBot.Modules.Utility; public partial class UtilityCommands { diff --git a/src/EllieBot/Modules/Utility/Alias/AliasCommands.cs b/src/EllieBot/Modules/Utility/Alias/AliasCommands.cs index 8fd9563..fd2e52f 100644 --- a/src/EllieBot/Modules/Utility/Alias/AliasCommands.cs +++ b/src/EllieBot/Modules/Utility/Alias/AliasCommands.cs @@ -1,6 +1,5 @@ #nullable disable using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Modules.Utility.Services; using EllieBot.Db.Models; diff --git a/src/EllieBot/Modules/Utility/Alias/AliasService.cs b/src/EllieBot/Modules/Utility/Alias/AliasService.cs index 6d47a23..876f155 100644 --- a/src/EllieBot/Modules/Utility/Alias/AliasService.cs +++ b/src/EllieBot/Modules/Utility/Alias/AliasService.cs @@ -1,7 +1,6 @@ #nullable disable using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Db.Models; namespace EllieBot.Modules.Utility.Services; diff --git a/src/EllieBot/Modules/Utility/Giveaway/GiveawayService.cs b/src/EllieBot/Modules/Utility/Giveaway/GiveawayService.cs index f43e7bb..200c88a 100644 --- a/src/EllieBot/Modules/Utility/Giveaway/GiveawayService.cs +++ b/src/EllieBot/Modules/Utility/Giveaway/GiveawayService.cs @@ -19,7 +19,6 @@ public sealed class GiveawayService : IEService, IReadyExecutor private readonly IMemoryCache _cache; private SortedSet _giveawayCache = new SortedSet(); private readonly EllieRandom _rng; - private readonly ConcurrentDictionary _rerolls = new(); public GiveawayService(DbService db, IBotCredentials creds, DiscordSocketClient client, IMessageSenderService sender, IBotStrings strings, ILocalization localization, IMemoryCache cache) diff --git a/src/EllieBot/Modules/Utility/Info/InfoCommands.cs b/src/EllieBot/Modules/Utility/Info/InfoCommands.cs index e2533e0..c9ae861 100644 --- a/src/EllieBot/Modules/Utility/Info/InfoCommands.cs +++ b/src/EllieBot/Modules/Utility/Info/InfoCommands.cs @@ -176,39 +176,5 @@ public partial class Utility return joinedAt; } - - [Cmd] - [RequireContext(ContextType.Guild)] - [OwnerOnly] - public async Task Activity(int page = 1) - { - const int activityPerPage = 10; - page -= 1; - - if (page < 0) - return; - - var startCount = page * activityPerPage; - - var str = new StringBuilder(); - foreach (var kvp in _cmdHandler.UserMessagesSent.OrderByDescending(kvp => kvp.Value) - .Skip(page * activityPerPage) - .Take(activityPerPage)) - { - str.AppendLine(GetText(strs.activity_line(++startCount, - Format.Bold(kvp.Key.ToString()), - kvp.Value / _stats.GetUptime().TotalSeconds, - kvp.Value))); - } - - await Response() - .Embed(_sender.CreateEmbed() - .WithTitle(GetText(strs.activity_page(page + 1))) - .WithOkColor() - .WithFooter(GetText( - strs.activity_users_total(_cmdHandler.UserMessagesSent.Count))) - .WithDescription(str.ToString())) - .SendAsync(); - } } } \ No newline at end of file diff --git a/src/EllieBot/Modules/Utility/Quote/QuoteCommands.cs b/src/EllieBot/Modules/Utility/Quote/QuoteCommands.cs index 913781b..d0ff339 100644 --- a/src/EllieBot/Modules/Utility/Quote/QuoteCommands.cs +++ b/src/EllieBot/Modules/Utility/Quote/QuoteCommands.cs @@ -2,7 +2,6 @@ using LinqToDB; using LinqToDB.EntityFrameworkCore; using EllieBot.Common.Yml; -using EllieBot.Db; using EllieBot.Db.Models; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; diff --git a/src/EllieBot/Modules/Utility/Remind/RemindCommands.cs b/src/EllieBot/Modules/Utility/Remind/RemindCommands.cs index 67b87af..9667384 100644 --- a/src/EllieBot/Modules/Utility/Remind/RemindCommands.cs +++ b/src/EllieBot/Modules/Utility/Remind/RemindCommands.cs @@ -1,5 +1,4 @@ #nullable disable -using EllieBot.Db; using EllieBot.Modules.Utility.Services; using EllieBot.Db.Models; @@ -95,8 +94,8 @@ public partial class Utility return; var embed = _sender.CreateEmbed() - .WithOkColor() - .WithTitle(GetText(isServer ? strs.reminder_server_list : strs.reminder_list)); + .WithOkColor() + .WithTitle(GetText(isServer ? strs.reminder_server_list : strs.reminder_list)); List rems; await using (var uow = _db.GetDbContext()) @@ -114,10 +113,9 @@ public partial class Utility { var when = rem.When; embed.AddField( - $"#{++i + (page * 10)} {rem.When:HH:mm yyyy-MM-dd} UTC " - + $"{TimestampTag.FromDateTime(when)}", - $@"`Target:` {(rem.IsPrivate ? "DM" : "Channel")} -`TargetId:` {rem.ChannelId} + $"#{++i + (page * 10)}", + $@"`When:` {TimestampTag.FromDateTime(when, TimestampTagStyles.ShortDateTime)} +`Target:` {(rem.IsPrivate ? "DM" : "Channel")} [`{rem.ChannelId}`] `Message:` {rem.Message?.TrimTo(50)}"); } } diff --git a/src/EllieBot/Modules/Utility/StreamRole/StreamRoleService.cs b/src/EllieBot/Modules/Utility/StreamRole/StreamRoleService.cs index 4ded9d0..eee20a1 100644 --- a/src/EllieBot/Modules/Utility/StreamRole/StreamRoleService.cs +++ b/src/EllieBot/Modules/Utility/StreamRole/StreamRoleService.cs @@ -1,5 +1,4 @@ using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Modules.Utility.Common; using EllieBot.Modules.Utility.Common.Exceptions; using EllieBot.Db.Models; diff --git a/src/EllieBot/Modules/Utility/Utility.cs b/src/EllieBot/Modules/Utility/Utility.cs index 7afa03e..ac76f93 100644 --- a/src/EllieBot/Modules/Utility/Utility.cs +++ b/src/EllieBot/Modules/Utility/Utility.cs @@ -1,4 +1,3 @@ -using LinqToDB.Reflection; using EllieBot.Modules.Utility.Services; using Newtonsoft.Json; using System.Diagnostics; @@ -7,7 +6,6 @@ using System.Text.Json; using System.Text.Json.Serialization; using Microsoft.CodeAnalysis.CSharp.Scripting; using Microsoft.CodeAnalysis.Scripting; -using EllieBot.Modules.Games.Hangman; using EllieBot.Modules.Searches.Common; namespace EllieBot.Modules.Utility; @@ -559,29 +557,38 @@ public partial class Utility : EllieModule [Cmd] [OwnerOnly] - public async Task ListServers(int page = 1) + public async Task ServerList(int page = 1) { page -= 1; if (page < 0) return; - var guilds = _client.Guilds.OrderBy(g => g.Name) - .Skip(page * 15) - .Take(15) + var allGuilds = _client.Guilds + .OrderBy(g => g.Name) .ToList(); - if (!guilds.Any()) - { - await Response().Error(strs.listservers_none).SendAsync(); - return; - } + await Response() + .Paginated() + .Items(allGuilds) + .PageSize(9) + .Page((guilds, _) => + { + if (!guilds.Any()) + { + return _sender.CreateEmbed() + .WithDescription(GetText(strs.listservers_none)) + .WithErrorColor(); + } - var embed = _sender.CreateEmbed().WithOkColor(); - foreach (var guild in guilds) - embed.AddField(guild.Name, GetText(strs.listservers(guild.Id, guild.MemberCount, guild.OwnerId))); + var embed = _sender.CreateEmbed() + .WithOkColor(); + foreach (var guild in guilds) + embed.AddField(guild.Name, GetText(strs.listservers(guild.Id, guild.MemberCount, guild.OwnerId))); - await Response().Embed(embed).SendAsync(); + return embed; + }) + .SendAsync(); } [Cmd] diff --git a/src/EllieBot/Modules/Utility/VerboseErrorsService.cs b/src/EllieBot/Modules/Utility/VerboseErrorsService.cs index c5cf886..e8e8c43 100644 --- a/src/EllieBot/Modules/Utility/VerboseErrorsService.cs +++ b/src/EllieBot/Modules/Utility/VerboseErrorsService.cs @@ -1,6 +1,4 @@ #nullable disable -using EllieBot.Db; - namespace EllieBot.Modules.Utility.Services; public class VerboseErrorsService : IEService diff --git a/src/EllieBot/Modules/Xp/Club/Club.cs b/src/EllieBot/Modules/Xp/Club/Club.cs index 9a84dc9..aff45be 100644 --- a/src/EllieBot/Modules/Xp/Club/Club.cs +++ b/src/EllieBot/Modules/Xp/Club/Club.cs @@ -1,5 +1,4 @@ #nullable disable -using EllieBot.Db; using EllieBot.Db.Models; using EllieBot.Modules.Xp.Services; diff --git a/src/EllieBot/Modules/Xp/Club/ClubService.cs b/src/EllieBot/Modules/Xp/Club/ClubService.cs index d35a05d..0c63913 100644 --- a/src/EllieBot/Modules/Xp/Club/ClubService.cs +++ b/src/EllieBot/Modules/Xp/Club/ClubService.cs @@ -1,8 +1,6 @@ -#nullable disable using LinqToDB; using LinqToDB.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Db.Models; using OneOf; @@ -100,9 +98,9 @@ public class ClubService : IEService, IClubService return member; } - public async Task SetClubIconAsync(ulong ownerUserId, string url) + public async Task SetClubIconAsync(ulong ownerUserId, string? url) { - if (url is not null) + if (!string.IsNullOrWhiteSpace(url)) { using var http = _httpFactory.CreateClient(); using var temp = await http.GetAsync(url, HttpCompletionOption.ResponseHeadersRead); @@ -175,7 +173,7 @@ public class ClubService : IEService, IClubService } - public ClubAcceptResult AcceptApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser) + public ClubAcceptResult AcceptApplication(ulong clubOwnerUserId, string userName, out DiscordUser? discordUser) { discordUser = null; using var uow = _db.GetDbContext(); @@ -201,7 +199,7 @@ public class ClubService : IEService, IClubService return ClubAcceptResult.Accepted; } - public ClubDenyResult RejectApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser) + public ClubDenyResult RejectApplication(ulong clubOwnerUserId, string userName, out DiscordUser? discordUser) { discordUser = null; using var uow = _db.GetDbContext(); @@ -242,7 +240,7 @@ public class ClubService : IEService, IClubService return ClubLeaveResult.Success; } - public bool SetDescription(ulong userId, string desc) + public bool SetDescription(ulong userId, string? desc) { using var uow = _db.GetDbContext(); var club = uow.Set().GetByOwner(userId); diff --git a/src/EllieBot/Modules/Xp/Club/IClubService.cs b/src/EllieBot/Modules/Xp/Club/IClubService.cs index 8a45e8d..d838e91 100644 --- a/src/EllieBot/Modules/Xp/Club/IClubService.cs +++ b/src/EllieBot/Modules/Xp/Club/IClubService.cs @@ -12,8 +12,8 @@ public interface IClubService Task SetClubIconAsync(ulong ownerUserId, string? url); bool GetClubByName(string clubName, out ClubInfo club); ClubApplyResult ApplyToClub(IUser user, ClubInfo club); - ClubAcceptResult AcceptApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser); - ClubDenyResult RejectApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser); + ClubAcceptResult AcceptApplication(ulong clubOwnerUserId, string userName, out DiscordUser? discordUser); + ClubDenyResult RejectApplication(ulong clubOwnerUserId, string userName, out DiscordUser? discordUser); ClubInfo? GetClubWithBansAndApplications(ulong ownerUserId); ClubLeaveResult LeaveClub(IUser user); bool SetDescription(ulong userId, string? desc); diff --git a/src/EllieBot/Modules/Xp/Xp.cs b/src/EllieBot/Modules/Xp/Xp.cs index 3892f65..63e59e3 100644 --- a/src/EllieBot/Modules/Xp/Xp.cs +++ b/src/EllieBot/Modules/Xp/Xp.cs @@ -2,7 +2,6 @@ using EllieBot.Modules.Xp.Services; using EllieBot.Db.Models; using EllieBot.Modules.Patronage; -using EllieBot.Modules.Utility; namespace EllieBot.Modules.Xp; diff --git a/src/EllieBot/Modules/Xp/XpService.cs b/src/EllieBot/Modules/Xp/XpService.cs index 6df1151..ea034a7 100644 --- a/src/EllieBot/Modules/Xp/XpService.cs +++ b/src/EllieBot/Modules/Xp/XpService.cs @@ -2,7 +2,6 @@ using LinqToDB; using Microsoft.EntityFrameworkCore; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using EllieBot.Db.Models; using Newtonsoft.Json; using SixLabors.Fonts; @@ -191,9 +190,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand var items = await ctx.Set() .Where(x => group.Contains(x.UserId)) .UpdateWithOutputAsync(old => new() - { - TotalXp = old.TotalXp + group.Key - }, + { + TotalXp = old.TotalXp + group.Key + }, (_, n) => n); await ctx.Set() @@ -216,9 +215,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand .Where(x => x.GuildId == guildId) .Where(x => group.Contains(x.UserId)) .UpdateWithOutputAsync(old => new() - { - Xp = old.Xp + group.Key - }, + { + Xp = old.Xp + group.Key + }, (_, n) => n); gxps.AddRange(items); @@ -230,14 +229,14 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand .Set() .ToLinqToDBTable() .InsertOrUpdateAsync(() => new UserXpStats() - { - UserId = userId, - GuildId = guildId, - Xp = group.Key, - DateAdded = DateTime.UtcNow, - AwardedXp = 0, - NotifyOnLevelUp = XpNotificationLocation.None - }, + { + UserId = userId, + GuildId = guildId, + Xp = group.Key, + DateAdded = DateTime.UtcNow, + AwardedXp = 0, + NotifyOnLevelUp = XpNotificationLocation.None + }, _ => new() { }, @@ -770,8 +769,8 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand private bool ShouldTrackXp(SocketGuildUser user, IMessageChannel channel) { var channelId = channel.Id; - - if (_excludedChannels.TryGetValue(user.Guild.Id, out var chans) && (chans.Contains(channelId) + + if (_excludedChannels.TryGetValue(user.Guild.Id, out var chans) && (chans.Contains(channelId) || (channel is SocketThreadChannel tc && chans.Contains(tc.ParentChannel.Id)))) return false; @@ -1010,12 +1009,12 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand img.Mutate(x => { x.DrawText(new TextOptions(usernameFont) - { - HorizontalAlignment = HorizontalAlignment.Left, - VerticalAlignment = VerticalAlignment.Center, - FallbackFontFamilies = _fonts.FallBackFonts, - Origin = new(template.User.Name.Pos.X, template.User.Name.Pos.Y + 8) - }, + { + HorizontalAlignment = HorizontalAlignment.Left, + VerticalAlignment = VerticalAlignment.Center, + FallbackFontFamilies = _fonts.FallBackFonts, + Origin = new(template.User.Name.Pos.X, template.User.Name.Pos.Y + 8) + }, "@" + username, Brushes.Solid(template.User.Name.Color), outlinePen); @@ -1031,12 +1030,12 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand var clubFont = _fonts.NotoSans.CreateFont(template.Club.Name.FontSize, FontStyle.Regular); img.Mutate(x => x.DrawText(new TextOptions(clubFont) - { - HorizontalAlignment = HorizontalAlignment.Right, - VerticalAlignment = VerticalAlignment.Top, - FallbackFontFamilies = _fonts.FallBackFonts, - Origin = new(template.Club.Name.Pos.X + 50, template.Club.Name.Pos.Y - 8) - }, + { + HorizontalAlignment = HorizontalAlignment.Right, + VerticalAlignment = VerticalAlignment.Top, + FallbackFontFamilies = _fonts.FallBackFonts, + Origin = new(template.Club.Name.Pos.X + 50, template.Club.Name.Pos.Y - 8) + }, clubName, Brushes.Solid(template.Club.Name.Color), outlinePen)); @@ -1248,9 +1247,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand if (template.Club.Icon.Show) await DrawClubImage(img, stats); -// #if GLOBAL_ELLIE + // #if GLOBAL_ELLIE await DrawFrame(img, stats.User.UserId); -// #endif + // #endif var outputSize = template.OutputSize; if (outputSize.X != img.Width || outputSize.Y != img.Height) @@ -1307,7 +1306,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand if (frame is not null) img.Mutate(x => x.DrawImage(frame, new Point(0, 0), new GraphicsOptions())); } -// #endif + // #endif private void DrawXpBar(float percent, XpBar info, Image img) { diff --git a/src/EllieBot/Modules/Xp/_common/FullUserStats.cs b/src/EllieBot/Modules/Xp/_common/FullUserStats.cs index de8b8da..d56a62e 100644 --- a/src/EllieBot/Modules/Xp/_common/FullUserStats.cs +++ b/src/EllieBot/Modules/Xp/_common/FullUserStats.cs @@ -1,5 +1,4 @@ #nullable disable -using EllieBot.Db; using EllieBot.Db.Models; namespace EllieBot.Modules.Xp; diff --git a/src/EllieBot/Services/Impl/BotCredsProvider.cs b/src/EllieBot/Services/Impl/BotCredsProvider.cs index 5c156db..81c5a25 100644 --- a/src/EllieBot/Services/Impl/BotCredsProvider.cs +++ b/src/EllieBot/Services/Impl/BotCredsProvider.cs @@ -2,7 +2,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Primitives; using EllieBot.Common.Yml; -using Newtonsoft.Json; namespace EllieBot.Services; diff --git a/src/EllieBot/Services/Impl/ImageCache.cs b/src/EllieBot/Services/Impl/ImageCache.cs index 4fc4e72..cf18590 100644 --- a/src/EllieBot/Services/Impl/ImageCache.cs +++ b/src/EllieBot/Services/Impl/ImageCache.cs @@ -60,12 +60,6 @@ public sealed class ImageCache : IImageCache, IEService public Task GetXpBackgroundImageAsync() => GetImageDataAsync(_ic.Data.Xp.Bg); - public Task GetRategirlBgAsync() - => GetImageDataAsync(_ic.Data.Rategirl.Matrix); - - public Task GetRategirlDotAsync() - => GetImageDataAsync(_ic.Data.Rategirl.Dot); - public Task GetDiceAsync(int num) => GetImageDataAsync(_ic.Data.Dice[num]); diff --git a/src/EllieBot/Services/Impl/Localization.cs b/src/EllieBot/Services/Impl/Localization.cs index 3c2cb5b..a1ff55d 100644 --- a/src/EllieBot/Services/Impl/Localization.cs +++ b/src/EllieBot/Services/Impl/Localization.cs @@ -1,5 +1,4 @@ #nullable disable -using EllieBot.Db; using Newtonsoft.Json; using System.Globalization; diff --git a/src/EllieBot/_common/Attributes/NoPublicBotAttribute.cs b/src/EllieBot/_common/Attributes/NoPublicBotAttribute.cs index 2ce8ccc..358265e 100644 --- a/src/EllieBot/_common/Attributes/NoPublicBotAttribute.cs +++ b/src/EllieBot/_common/Attributes/NoPublicBotAttribute.cs @@ -1,6 +1,4 @@ #nullable disable -using System.Diagnostics.CodeAnalysis; - namespace EllieBot.Common; [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] diff --git a/src/EllieBot/_common/NinjectIKernelExtensions.cs b/src/EllieBot/_common/DryIocExtensions.cs similarity index 80% rename from src/EllieBot/_common/NinjectIKernelExtensions.cs rename to src/EllieBot/_common/DryIocExtensions.cs index 5b5b909..c7d8c2a 100644 --- a/src/EllieBot/_common/NinjectIKernelExtensions.cs +++ b/src/EllieBot/_common/DryIocExtensions.cs @@ -20,14 +20,6 @@ public static class DryIocExtensions return container; } - public static IContainer AddSingleton(this IContainer container, Func factory) - where TImpl : TSvc - { - container.RegisterDelegate(factory, Reuse.Singleton); - - return container; - } - public static IContainer AddSingleton(this IContainer container) { container.Register(Reuse.Singleton); diff --git a/src/EllieBot/_common/ImageUrls.cs b/src/EllieBot/_common/ImageUrls.cs index 5dc9557..fa253a7 100644 --- a/src/EllieBot/_common/ImageUrls.cs +++ b/src/EllieBot/_common/ImageUrls.cs @@ -8,12 +8,11 @@ namespace EllieBot.Common; public partial class ImageUrls : ICloneable { [Comment("DO NOT CHANGE")] - public int Version { get; set; } = 4; + public int Version { get; set; } = 5; public CoinData Coins { get; set; } public Uri[] Currency { get; set; } public Uri[] Dice { get; set; } - public RategirlData Rategirl { get; set; } public XpData Xp { get; set; } public SlotData Slots { get; set; } @@ -30,12 +29,6 @@ public partial class ImageUrls : ICloneable public Uri[] Tails { get; set; } } - public class RategirlData - { - public Uri Matrix { get; set; } - public Uri Dot { get; set; } - } - public class XpData { public Uri Bg { get; set; } diff --git a/src/EllieBot/_common/Marmalade/Common/MarmaladeIoCKernelModule.cs b/src/EllieBot/_common/Marmalade/Common/MarmaladeIoCKernelModule.cs index e55ddff..3b9c450 100644 --- a/src/EllieBot/_common/Marmalade/Common/MarmaladeIoCKernelModule.cs +++ b/src/EllieBot/_common/Marmalade/Common/MarmaladeIoCKernelModule.cs @@ -34,7 +34,7 @@ public sealed class MarmaladeNinjectIocModule : IIocModule, IDisposable if (isLoaded) return; - foreach (var (type, data) in _types) + foreach (var (type, _) in _types) { var attribute = type.GetCustomAttribute()!; diff --git a/src/EllieBot/_common/Marmalade/Common/Models/CanaryCommandData.cs b/src/EllieBot/_common/Marmalade/Common/Models/CanaryCommandData.cs index 8244576..cc5ab35 100644 --- a/src/EllieBot/_common/Marmalade/Common/Models/CanaryCommandData.cs +++ b/src/EllieBot/_common/Marmalade/Common/Models/CanaryCommandData.cs @@ -1,5 +1,4 @@ -using EllieBot.Marmalade; -using System.Reflection; +using System.Reflection; namespace EllieBot.Marmalade; diff --git a/src/EllieBot/_common/Patronage/IPatronageService.cs b/src/EllieBot/_common/Patronage/IPatronageService.cs index 650bf06..379de6b 100644 --- a/src/EllieBot/_common/Patronage/IPatronageService.cs +++ b/src/EllieBot/_common/Patronage/IPatronageService.cs @@ -1,7 +1,4 @@ -using EllieBot.Db.Models; -using OneOf; - -namespace EllieBot.Modules.Patronage; +namespace EllieBot.Modules.Patronage; /// /// Manages patrons and provides access to their data diff --git a/src/EllieBot/_common/Patronage/QuotaLimit.cs b/src/EllieBot/_common/Patronage/QuotaLimit.cs index ed2cae9..5669c0c 100644 --- a/src/EllieBot/_common/Patronage/QuotaLimit.cs +++ b/src/EllieBot/_common/Patronage/QuotaLimit.cs @@ -1,6 +1,4 @@ -using EllieBot.Db.Models; - -namespace EllieBot.Modules.Patronage; +namespace EllieBot.Modules.Patronage; /// /// Represents information about why the user has triggered a quota limit diff --git a/src/EllieBot/_common/Sender/MessageSenderService.cs b/src/EllieBot/_common/Sender/MessageSenderService.cs index f91f1ab..88f1c40 100644 --- a/src/EllieBot/_common/Sender/MessageSenderService.cs +++ b/src/EllieBot/_common/Sender/MessageSenderService.cs @@ -1,5 +1,4 @@ using EllieBot.Common.Configs; -using System.Diagnostics.CodeAnalysis; namespace EllieBot.Extensions; diff --git a/src/EllieBot/_common/Sender/ResponseBuilder.cs b/src/EllieBot/_common/Sender/ResponseBuilder.cs index 60783de..08d1ad3 100644 --- a/src/EllieBot/_common/Sender/ResponseBuilder.cs +++ b/src/EllieBot/_common/Sender/ResponseBuilder.cs @@ -1,6 +1,4 @@ -using EllieBot.Common.Configs; -using EllieBot.Db.Models; -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; namespace EllieBot.Extensions; diff --git a/src/EllieBot/_common/Services/CommandHandler.cs b/src/EllieBot/_common/Services/CommandHandler.cs index 2061b29..b9b0721 100644 --- a/src/EllieBot/_common/Services/CommandHandler.cs +++ b/src/EllieBot/_common/Services/CommandHandler.cs @@ -1,7 +1,6 @@ #nullable disable using EllieBot.Common.Configs; using EllieBot.Common.ModuleBehaviors; -using EllieBot.Db; using ExecuteResult = Discord.Commands.ExecuteResult; using PreconditionResult = Discord.Commands.PreconditionResult; diff --git a/src/EllieBot/_common/Services/Currency/CurrencyService.cs b/src/EllieBot/_common/Services/Currency/CurrencyService.cs index 9cb4037..66029ff 100644 --- a/src/EllieBot/_common/Services/Currency/CurrencyService.cs +++ b/src/EllieBot/_common/Services/Currency/CurrencyService.cs @@ -1,7 +1,6 @@ #nullable disable using LinqToDB; using LinqToDB.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Db.Models; using EllieBot.Services.Currency; diff --git a/src/EllieBot/_common/Services/Impl/IImageCache.cs b/src/EllieBot/_common/Services/Impl/IImageCache.cs index 890eeea..5a7e01c 100644 --- a/src/EllieBot/_common/Services/Impl/IImageCache.cs +++ b/src/EllieBot/_common/Services/Impl/IImageCache.cs @@ -6,8 +6,6 @@ public interface IImageCache Task GetTailsImageAsync(); Task GetCurrencyImageAsync(); Task GetXpBackgroundImageAsync(); - Task GetRategirlBgAsync(); - Task GetRategirlDotAsync(); Task GetDiceAsync(int num); Task GetSlotEmojiAsync(int number); Task GetSlotBgAsync(); diff --git a/src/EllieBot/_common/Services/Impl/ImagesConfig.cs b/src/EllieBot/_common/Services/Impl/ImagesConfig.cs index 821d717..a730a94 100644 --- a/src/EllieBot/_common/Services/Impl/ImagesConfig.cs +++ b/src/EllieBot/_common/Services/Impl/ImagesConfig.cs @@ -15,5 +15,17 @@ public sealed class ImagesConfig : ConfigServiceBase public ImagesConfig(IConfigSeria serializer, IPubSub pubSub) : base(PATH, serializer, pubSub, _changeKey) { + Migrate(); + } + + private void Migrate() + { + if (data.Version < 5) + { + ModifyConfig(c => + { + c.Version = 5; + }); + } } } \ No newline at end of file diff --git a/src/EllieBot/_common/_Extensions/DbExtensions.cs b/src/EllieBot/_common/_Extensions/DbExtensions.cs index 58a9abd..0975a1f 100644 --- a/src/EllieBot/_common/_Extensions/DbExtensions.cs +++ b/src/EllieBot/_common/_Extensions/DbExtensions.cs @@ -1,5 +1,4 @@ using Microsoft.EntityFrameworkCore; -using EllieBot.Db; using EllieBot.Db.Models; namespace EllieBot.Extensions; diff --git a/src/EllieBot/_common/_Extensions/Extensions.cs b/src/EllieBot/_common/_Extensions/Extensions.cs index 33aa564..dca195d 100644 --- a/src/EllieBot/_common/_Extensions/Extensions.cs +++ b/src/EllieBot/_common/_Extensions/Extensions.cs @@ -1,4 +1,3 @@ -using System.Diagnostics; using System.Globalization; using System.Text.Json; using System.Text.RegularExpressions; diff --git a/src/EllieBot/data/aliases.yml b/src/EllieBot/data/aliases.yml index d8c13df..ff53850 100644 --- a/src/EllieBot/data/aliases.yml +++ b/src/EllieBot/data/aliases.yml @@ -587,10 +587,6 @@ pokemon: pokemonability: - pokemonability - pokeab -memelist: - - memelist -memegen: - - memegen weather: - weather - we @@ -771,7 +767,7 @@ typedel: - typedel typelist: - typelist -listservers: +serverlist: - listservers cleverbot: - cleverbot @@ -804,8 +800,6 @@ autodisconnect: define: - define - def -activity: - - activity setstatus: - setstatus invitecreate: @@ -855,8 +849,6 @@ divorce: waifuinfo: - waifuinfo - waifustats -mal: - - mal setmusicchannel: - setmusicchannel - smch @@ -1148,8 +1140,6 @@ discordpermoverridelist: - dpoli discordpermoverridereset: - dpor -rafflecur: - - rafflecur timelyset: - timelyset timely: @@ -1166,8 +1156,6 @@ massban: - massban masskill: - masskill -rollduel: - - rollduel reroadd: - reroadd - reroa @@ -1209,8 +1197,6 @@ roleid: agerestricttoggle: - nsfwtoggle - artoggle -economy: - - economy purgeuser: - purgeuser imageonlychannel: diff --git a/src/EllieBot/data/images.yml b/src/EllieBot/data/images.yml index 73ea5e6..76d8da6 100644 --- a/src/EllieBot/data/images.yml +++ b/src/EllieBot/data/images.yml @@ -1,5 +1,5 @@ # DO NOT CHANGE -version: 4 +version: 5 coins: heads: - https://cdn.nadeko.bot/coins/heads3.png @@ -20,9 +20,6 @@ dice: - https://cdn.nadeko.bot/other/dice/7.png - https://cdn.nadeko.bot/other/dice/8.png - https://cdn.nadeko.bot/other/dice/9.png -rategirl: - matrix: https://cdn.nadeko.bot/other/rategirl/matrix.png - dot: https://cdn.nadeko.bot/other/rategirl/dot.png xp: bg: https://cdn.nadeko.bot/other/xp/bg_k.png rip: diff --git a/src/EllieBot/data/strings/commands/commands.en-US.yml b/src/EllieBot/data/strings/commands/commands.en-US.yml index 8e5ff9d..51dba44 100644 --- a/src/EllieBot/data/strings/commands/commands.en-US.yml +++ b/src/EllieBot/data/strings/commands/commands.en-US.yml @@ -63,10 +63,8 @@ greet: greetmsg: desc: |- Sets a new join announcement message which will be shown in the current channel. - Write `%user.mention%` if you want to mention the new member. - Full list of placeholders can be found here Using this command with no message will show the current greet message. - You can use embed json from instead of regular text, if you want the message to be embedded. + Supports [placeholders](https://docs.elliebot.net/ellie/features/placeholders/) and [embeds](https://eb.elliebot.net/) ex: - Welcome, %user.mention%. params: @@ -80,11 +78,9 @@ bye: - {} byemsg: desc: |- - Sets a new leave announcement message which will be shown in the current channel. - Type `%user.name%` to show the name of the user who left. - Full list of placeholders can be found here + Sets a new leave announcement message which will be shown in the current channel. Using this command with no message will show the current bye message. - You can use embed json from instead of regular text, if you want the message to be embedded. + Supports [placeholders](https://docs.elliebot.net/ellie/features/placeholders/) and [embeds](https://eb.elliebot.net/) ex: - '%user.name% has left.' params: @@ -113,7 +109,9 @@ greettest: - user: desc: "The user to impersonate when sending the greeting, defaulting to yourself if not specified." boosttest: - desc: Sends the boost message in the current channel as if you just boosted the server. You can optionally specify a different user. + desc: |- + Sends the boost message in the current channel as if you just boosted the server. + You can optionally specify a different user. ex: - '' - '@SomeoneElse' @@ -145,10 +143,8 @@ boost: boostmsg: desc: |- Sets a new boost announcement message which will be shown in the current channel. - Type `%user.mention%` if you want to mention the booster. - Full list of placeholders can be found here Using this command with no message will show the current boost message. - You can use embed json from instead of regular text, if you want the message to be embedded. + Supports [placeholders](https://docs.elliebot.net/ellie/features/placeholders/) and [embeds](https://eb.elliebot.net/) ex: - '%user.mention% has boosted the server!!!' params: @@ -1987,23 +1983,6 @@ pokemonability: params: - ability: desc: "The type of the Pokémon's special power or trait that can be used in battle." -memelist: - desc: Shows a list of template keys (and their respective names) used for `{0}memegen`. - ex: - - '' - params: - - page: - desc: "The number of pages in the list to be displayed." -memegen: - desc: Generates a meme from memelist with specified text. Separate multiple text values with semicolons. Provide no meme text to see an example meme with that template. - ex: - - biw gets iced coffee;in the winter - - ntot - params: - - meme: - desc: "The caption or punchline of the meme, which can be a single sentence or multiple sentences separated by semicolons." - memeText: - desc: "The user-provided text to be displayed on the generated meme." weather: desc: Shows current weather data for the specified city. ex: @@ -2550,7 +2529,7 @@ typelist: params: - page: desc: "The current page number for the list of typing articles." -listservers: +serverlist: desc: Lists servers the bot is on with some basic info. 15 per page. ex: - 3 @@ -2645,13 +2624,6 @@ define: params: - word: desc: "The word being searched for." -activity: - desc: Checks for spammers. - ex: - - '' - params: - - page: - desc: "The number of pages to scan for spam." setstatus: desc: Sets the bot's status. (Online/Idle/Dnd/Invisible) ex: @@ -2808,15 +2780,6 @@ waifuinfo: desc: "The user being targeted, whose waifu information will be displayed." - targetId: desc: "The ID of the person whose waifu stats are being displayed." -mal: - desc: Shows basic info from a MyAnimeList profile. - ex: - - straysocks - params: - - name: - desc: "The username or identifier for the MyAnimeList account being queried." - - usr: - desc: "The user's guild membership information is used to fetch their anime list and other relevant data." setmusicchannel: desc: Sets the current channel as the default music output channel. This will output playing, finished, paused and removed songs to that channel instead of the channel where the first song was queued in. Persistent server setting. ex: @@ -3116,7 +3079,7 @@ banmessage: - '{{ "description": "%ban.user% you have been banned from %server.name% by %ban.mod%" }}' params: - message: - desc: "The custom message to be displayed when a user is banned from the server, allowing for placeholders to be replaced with relevant information." + desc: "The custom message to be displayed when a user is banned from the server." banmessagetest: desc: If ban message is not disabled, bot will send you the message as if you were banned by yourself. Used for testing the ban message. ex: @@ -3871,20 +3834,6 @@ discordpermoverridereset: - '' params: - {} -rafflecur: - desc: Starts or joins a currency raffle with a specified amount. Users who join the raffle will lose the amount of currency specified and add it to the pot. After 30 seconds, random winner will be selected who will receive the whole pot. There is also a `mixed` mode in which the users will be able to join the game with any amount of currency, and have their chances be proportional to the amount they've bet. - ex: - - 20 - - mixed 15 - params: - - _: - desc: "The type of game mode to use, either \"fixed\" or \"mixed\"." - amount: - desc: "The minimum or maximum amount of currency that can be used for betting." - - amount: - desc: "The minimum or maximum amount of currency that can be used for betting." - mixed: - desc: "The parameter determines whether the raffle operates in \"fixed\" or \"proportional\" mode." autodisconnect: desc: Toggles whether the bot should disconnect from the voice channel once it's done playing all of the songs and queue repeat option is set to `none`. ex: @@ -3956,18 +3905,6 @@ masskill: params: - people: desc: "The list of user IDs or usernames to ban from the server and blacklist from the bot." -rollduel: - desc: Challenge someone to a roll duel by specifying the amount and the user you wish to challenge as the parameters. To accept the challenge, just specify the name of the user who challenged you, without the amount. - ex: - - 50 @Someone - - '@Challenger' - params: - - u: - desc: "The user being challenged or accepting the challenge." - - amount: - desc: "The stakes for the roll duel." - u: - desc: "The user being challenged or accepting the challenge." reroadd: desc: |- Specify a message id, emote and a role name to have the bot assign the specified role to the user who reacts to the specified message (in this channel) with the specified emoji. @@ -4158,12 +4095,6 @@ agerestricttoggle: - '' params: - {} -economy: - desc: Breakdown of the current state of the bot's economy. Updates every 3 minutes. - ex: - - '' - params: - - {} purgeuser: desc: Purge user from the database completely. This includes currency, xp, clubs that user owns, waifu info ex: diff --git a/src/EllieBot/data/strings/responses/responses.en-US.json b/src/EllieBot/data/strings/responses/responses.en-US.json index b55d8ad..fe495bb 100644 --- a/src/EllieBot/data/strings/responses/responses.en-US.json +++ b/src/EllieBot/data/strings/responses/responses.en-US.json @@ -977,14 +977,7 @@ "reset_user_confirm": "Are you sure that you want to reset specified user's XP on this server?", "reset_user": "User with id {0} has had their XP reset on this server.", "reset_server": "XP of all users on the server has been reset.", - "economy_state": "State of the economy", - "currency_owned": "Total currency owned by users", - "currency_one_percent": "% of currency owned by top 1%", - "currency_planted": "Currency currently planted", - "owned_waifus_total": "Total value of owned waifus", - "bot_currency": "Currency owned by the bot", "total": "Total", - "bank_accounts": "Bank Accounts", "no_invites": "No invites on this page.", "invite_deleted": "Invite {0} has been deleted.", "group_name_added": "Group #{0} now has a name: {1}",