Trainer project
This commit is contained in:
parent
3d214d69a1
commit
42f5ea21fb
@ -15,6 +15,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "DbService", "DbService\DbSe
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SlotMachine", "SlotMachine\SlotMachine.fsproj", "{3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}"
|
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SlotMachine", "SlotMachine\SlotMachine.fsproj", "{3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Trainer", "Trainer\Trainer.fsproj", "{2511151A-EC5A-4BF9-A3EA-EF996AC2A4F1}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@ -80,6 +80,7 @@ module Commands =
|
|||||||
|
|
||||||
let! leaders = DbService.getTopPlayers 10
|
let! leaders = DbService.getTopPlayers 10
|
||||||
let content =
|
let content =
|
||||||
|
// TODO: There's a bug, it's not in the right order
|
||||||
leaders
|
leaders
|
||||||
|> Seq.toArray
|
|> Seq.toArray
|
||||||
|> Array.mapi (fun i p -> $"{i + 1}. {p.Bank} {p.Name}")
|
|> Array.mapi (fun i p -> $"{i + 1}. {p.Bank} {p.Name}")
|
||||||
@ -95,6 +96,7 @@ module Commands =
|
|||||||
let! player = DbService.tryFindPlayer ctx.Member.Id
|
let! player = DbService.tryFindPlayer ctx.Member.Id
|
||||||
match player with
|
match player with
|
||||||
| Some p ->
|
| Some p ->
|
||||||
|
// TODO: Is this working?
|
||||||
let updatedAttacks = p.Attacks |> removeExpiredActions (TimeSpan.FromMinutes(15)) (fun (atk : Attack) -> atk.Timestamp)
|
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)
|
let updatedDefenses = p.Defenses |> removeExpiredActions (TimeSpan.FromHours(24)) (fun (p : Defense) -> p.Timestamp)
|
||||||
do! DbService.updatePlayer <| { p with Attacks = updatedAttacks ; Defenses = updatedDefenses }
|
do! DbService.updatePlayer <| { p with Attacks = updatedAttacks ; Defenses = updatedDefenses }
|
||||||
@ -107,7 +109,6 @@ module Commands =
|
|||||||
} |> Async.StartAsTask
|
} |> Async.StartAsTask
|
||||||
:> Task
|
:> Task
|
||||||
|
|
||||||
|
|
||||||
type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule ()
|
type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule ()
|
||||||
|
|
||||||
type PlayerRegistration() =
|
type PlayerRegistration() =
|
||||||
|
25
Trainer/.dockerignore
Normal file
25
Trainer/.dockerignore
Normal file
@ -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
|
18
Trainer/Dockerfile
Normal file
18
Trainer/Dockerfile
Normal file
@ -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"]
|
56
Trainer/Trainer.fs
Normal file
56
Trainer/Trainer.fs
Normal file
@ -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 ()
|
||||||
|
|
||||||
|
[<SlashCommand("hack", "Send a hack attack to another player")>]
|
||||||
|
member this.Attack (ctx : InteractionContext) =
|
||||||
|
async {
|
||||||
|
let! playerResult = DbService.tryFindPlayer ctx.Member.Id
|
||||||
|
return ()
|
||||||
|
} |> Async.StartAsTask
|
||||||
|
:> Task
|
||||||
|
|
||||||
|
[<SlashCommand("defend", "Create a passive defense that will last 24 hours")>]
|
||||||
|
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<Trainer>(922419263275425832uL);
|
||||||
|
// Degenz
|
||||||
|
//slash.RegisterCommands<HackerGame>(922414052708327494uL);
|
||||||
|
|
||||||
|
client.ConnectAsync ()
|
||||||
|
|> Async.AwaitTask
|
||||||
|
|> Async.RunSynchronously
|
||||||
|
|
||||||
|
Task.Delay(-1)
|
||||||
|
|> Async.AwaitTask
|
||||||
|
|> Async.RunSynchronously
|
||||||
|
|
||||||
|
client.DisconnectAsync ()
|
||||||
|
|> Async.AwaitTask
|
||||||
|
|> Async.RunSynchronously
|
||||||
|
|
20
Trainer/Trainer.fsproj
Normal file
20
Trainer/Trainer.fsproj
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Trainer.fs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include=".dockerignore" />
|
||||||
|
<Content Include="Dockerfile" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\DbService\DbService.fsproj" />
|
||||||
|
<ProjectReference Include="..\Shared\Shared.fsproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="..\.paket\Paket.Restore.targets" />
|
||||||
|
</Project>
|
7
Trainer/paket.references
Normal file
7
Trainer/paket.references
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
FSharp.Core
|
||||||
|
DSharpPlus
|
||||||
|
// DSharpPlus.CommandsNext
|
||||||
|
// DSharpPlus.Interactivity
|
||||||
|
DSharpPlus.SlashCommands
|
||||||
|
|
||||||
|
// MongoDB.Driver
|
Loading…
x
Reference in New Issue
Block a user