diff --git a/DegenzGame.sln b/DegenzGame.sln index 706df5e..69585bb 100644 --- a/DegenzGame.sln +++ b/DegenzGame.sln @@ -15,6 +15,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "DbService", "DbService\DbSe EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SlotMachine", "SlotMachine\SlotMachine.fsproj", "{3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Trainer", "Trainer\Trainer.fsproj", "{2511151A-EC5A-4BF9-A3EA-EF996AC2A4F1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -48,5 +50,9 @@ Global {3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}.Debug|Any CPU.Build.0 = Debug|Any CPU {3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}.Release|Any CPU.ActiveCfg = Release|Any CPU {3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}.Release|Any CPU.Build.0 = Release|Any CPU + {2511151A-EC5A-4BF9-A3EA-EF996AC2A4F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2511151A-EC5A-4BF9-A3EA-EF996AC2A4F1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2511151A-EC5A-4BF9-A3EA-EF996AC2A4F1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2511151A-EC5A-4BF9-A3EA-EF996AC2A4F1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/PlayerInteractions/PlayerInteractions.fs b/PlayerInteractions/PlayerInteractions.fs index c35413c..38701e4 100644 --- a/PlayerInteractions/PlayerInteractions.fs +++ b/PlayerInteractions/PlayerInteractions.fs @@ -80,6 +80,7 @@ module Commands = let! leaders = DbService.getTopPlayers 10 let content = + // TODO: There's a bug, it's not in the right order leaders |> Seq.toArray |> Array.mapi (fun i p -> $"{i + 1}. {p.Bank} {p.Name}") @@ -95,6 +96,7 @@ module Commands = let! player = DbService.tryFindPlayer ctx.Member.Id match player with | Some p -> + // TODO: Is this working? let updatedAttacks = p.Attacks |> removeExpiredActions (TimeSpan.FromMinutes(15)) (fun (atk : Attack) -> atk.Timestamp) let updatedDefenses = p.Defenses |> removeExpiredActions (TimeSpan.FromHours(24)) (fun (p : Defense) -> p.Timestamp) do! DbService.updatePlayer <| { p with Attacks = updatedAttacks ; Defenses = updatedDefenses } @@ -107,7 +109,6 @@ module Commands = } |> Async.StartAsTask :> Task - type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule () type PlayerRegistration() = diff --git a/Trainer/.dockerignore b/Trainer/.dockerignore new file mode 100644 index 0000000..38bece4 --- /dev/null +++ b/Trainer/.dockerignore @@ -0,0 +1,25 @@ +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/.idea +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/Trainer/Dockerfile b/Trainer/Dockerfile new file mode 100644 index 0000000..1d4a75e --- /dev/null +++ b/Trainer/Dockerfile @@ -0,0 +1,18 @@ +FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base +WORKDIR /app + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /src +COPY ["Trainer/Trainer.fsproj", "Trainer/"] +RUN dotnet restore "Trainer/Trainer.fsproj" +COPY . . +WORKDIR "/src/Trainer" +RUN dotnet build "Trainer.fsproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Trainer.fsproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Trainer.dll"] diff --git a/Trainer/Trainer.fs b/Trainer/Trainer.fs new file mode 100644 index 0000000..b934bf6 --- /dev/null +++ b/Trainer/Trainer.fs @@ -0,0 +1,56 @@ +open System +open System.Threading.Tasks +open DSharpPlus +open DSharpPlus.Entities +open DSharpPlus.SlashCommands +open DegenzGame +open DegenzGame.Shared + +type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule () + +type Trainer() = + inherit ApplicationCommandModule () + + [] + member this.Attack (ctx : InteractionContext) = + async { + let! playerResult = DbService.tryFindPlayer ctx.Member.Id + return () + } |> Async.StartAsTask + :> Task + + [] + member this.DefendCommand (ctx : InteractionContext) = + async { + let! playerResult = DbService.tryFindPlayer ctx.Member.Id + return () + } |> Async.StartAsTask + :> Task + +let config = DiscordConfiguration() +config.Token <- "OTMzMDg4MTQyNDM5ODk5MTg4.YeccDQ.AbysjlHICgbNQVyduG6aGIHNpdE" +config.TokenType <- TokenType.Bot +config.Intents <- DiscordIntents.All +//config.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace + +let client = new DiscordClient(config) + +let slash = client.UseSlashCommands() + +// My server +slash.RegisterCommands(922419263275425832uL); +// Degenz +//slash.RegisterCommands(922414052708327494uL); + +client.ConnectAsync () +|> Async.AwaitTask +|> Async.RunSynchronously + +Task.Delay(-1) +|> Async.AwaitTask +|> Async.RunSynchronously + +client.DisconnectAsync () +|> Async.AwaitTask +|> Async.RunSynchronously + diff --git a/Trainer/Trainer.fsproj b/Trainer/Trainer.fsproj new file mode 100644 index 0000000..b728b5a --- /dev/null +++ b/Trainer/Trainer.fsproj @@ -0,0 +1,20 @@ + + + + Exe + net6.0 + Linux + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trainer/paket.references b/Trainer/paket.references new file mode 100644 index 0000000..a5fcca2 --- /dev/null +++ b/Trainer/paket.references @@ -0,0 +1,7 @@ +FSharp.Core +DSharpPlus +// DSharpPlus.CommandsNext +// DSharpPlus.Interactivity +DSharpPlus.SlashCommands + +// MongoDB.Driver