Move bots into single process

This commit is contained in:
Joseph Ferano 2022-01-19 20:15:07 +07:00
parent bcb99d9a78
commit fd9a6a25f3
17 changed files with 196 additions and 218 deletions

View File

@ -1,7 +1,7 @@
module DegenzGame.DbService module Degenz.DbService
open System open System
open DegenzGame.Shared open Degenz.Shared
open MongoDB.Bson open MongoDB.Bson
open MongoDB.Driver open MongoDB.Driver

View File

@ -3,19 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105 VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "HackerBattle", "HackerBattle\HackerBattle.fsproj", "{2A437756-3D5D-467D-9497-DF9789DB99CC}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Shared", "Shared\Shared.fsproj", "{5F34C24E-BA4E-4E57-9141-812775687360}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Store", "Store\Store.fsproj", "{CD88B0A6-DE42-4087-9B33-48FF84201633}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "PlayerInteractions", "PlayerInteractions\PlayerInteractions.fsproj", "{FF9E58A6-1A1D-4DEC-B52D-265F215BF315}" Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "PlayerInteractions", "PlayerInteractions\PlayerInteractions.fsproj", "{FF9E58A6-1A1D-4DEC-B52D-265F215BF315}"
EndProject EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "DbService", "DbService\DbService.fsproj", "{B1D3E1CC-451C-42D4-B054-D64E75E1A3B9}" Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "DbService", "DbService\DbService.fsproj", "{B1D3E1CC-451C-42D4-B054-D64E75E1A3B9}"
EndProject EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SlotMachine", "SlotMachine\SlotMachine.fsproj", "{3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}" Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Shared", "Shared\Shared.fsproj", "{BD80E85E-87C8-4F5F-941E-7DCAF9D69838}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Trainer", "Trainer\Trainer.fsproj", "{2511151A-EC5A-4BF9-A3EA-EF996AC2A4F1}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -26,18 +18,6 @@ Global
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A437756-3D5D-467D-9497-DF9789DB99CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A437756-3D5D-467D-9497-DF9789DB99CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A437756-3D5D-467D-9497-DF9789DB99CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A437756-3D5D-467D-9497-DF9789DB99CC}.Release|Any CPU.Build.0 = Release|Any CPU
{5F34C24E-BA4E-4E57-9141-812775687360}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F34C24E-BA4E-4E57-9141-812775687360}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F34C24E-BA4E-4E57-9141-812775687360}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F34C24E-BA4E-4E57-9141-812775687360}.Release|Any CPU.Build.0 = Release|Any CPU
{CD88B0A6-DE42-4087-9B33-48FF84201633}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD88B0A6-DE42-4087-9B33-48FF84201633}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD88B0A6-DE42-4087-9B33-48FF84201633}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD88B0A6-DE42-4087-9B33-48FF84201633}.Release|Any CPU.Build.0 = Release|Any CPU
{FF9E58A6-1A1D-4DEC-B52D-265F215BF315}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FF9E58A6-1A1D-4DEC-B52D-265F215BF315}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF9E58A6-1A1D-4DEC-B52D-265F215BF315}.Debug|Any CPU.Build.0 = Debug|Any CPU {FF9E58A6-1A1D-4DEC-B52D-265F215BF315}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF9E58A6-1A1D-4DEC-B52D-265F215BF315}.Release|Any CPU.ActiveCfg = Release|Any CPU {FF9E58A6-1A1D-4DEC-B52D-265F215BF315}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -46,13 +26,9 @@ Global
{B1D3E1CC-451C-42D4-B054-D64E75E1A3B9}.Debug|Any CPU.Build.0 = Debug|Any CPU {B1D3E1CC-451C-42D4-B054-D64E75E1A3B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1D3E1CC-451C-42D4-B054-D64E75E1A3B9}.Release|Any CPU.ActiveCfg = Release|Any CPU {B1D3E1CC-451C-42D4-B054-D64E75E1A3B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1D3E1CC-451C-42D4-B054-D64E75E1A3B9}.Release|Any CPU.Build.0 = Release|Any CPU {B1D3E1CC-451C-42D4-B054-D64E75E1A3B9}.Release|Any CPU.Build.0 = Release|Any CPU
{3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BD80E85E-87C8-4F5F-941E-7DCAF9D69838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}.Debug|Any CPU.Build.0 = Debug|Any CPU {BD80E85E-87C8-4F5F-941E-7DCAF9D69838}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}.Release|Any CPU.ActiveCfg = Release|Any CPU {BD80E85E-87C8-4F5F-941E-7DCAF9D69838}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3183BE8D-1CA6-4768-8606-BEF6F4EC8DE1}.Release|Any CPU.Build.0 = Release|Any CPU {BD80E85E-87C8-4F5F-941E-7DCAF9D69838}.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

View File

@ -1,49 +0,0 @@
open System.Threading.Tasks
open DSharpPlus
open DSharpPlus.Entities
open DSharpPlus.SlashCommands
open Emzi0767.Utilities
open DegenzGame
open DegenzGame.Commands
type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule ()
type HackerGame() =
inherit ApplicationCommandModule ()
[<SlashCommand("hack", "Send a hack attack to another player")>]
member this.AttackCommand (ctx : InteractionContext, [<Option("target", "The player you want to hack")>] target : DiscordUser) =
Commands.attack ctx target
[<SlashCommand("defend", "Create a passive defense that will last 24 hours")>]
member this.DefendCommand (ctx : InteractionContext) = Commands.defend ctx
let config = DiscordConfiguration()
config.Token <- "OTMyMzI5NDAzNjYzNDEzMjQ4.YeRZaw.ZyCo5L8HFsCvx8JuhdAwqrH3hZI"
config.TokenType <- TokenType.Bot
config.Intents <- DiscordIntents.All
//config.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace
let client = new DiscordClient(config)
client.add_ComponentInteractionCreated(AsyncEventHandler(handleButtonEvent))
let slash = client.UseSlashCommands()
// My server
slash.RegisterCommands<HackerGame>(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

View File

@ -14,8 +14,6 @@
<ReferencePathWithRefAssemblies Update="\home\joe\.nuget\packages\dsharpplus.slashcommands\4.2.0-nightly-01054\lib\netstandard2.0\DSharpPlus.SlashCommands.dll" /> <ReferencePathWithRefAssemblies Update="\home\joe\.nuget\packages\dsharpplus.slashcommands\4.2.0-nightly-01054\lib\netstandard2.0\DSharpPlus.SlashCommands.dll" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Commands.fs" />
<Compile Include="HackerBattle.fs" />
<Content Include="paket.references" /> <Content Include="paket.references" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

74
PlayerInteractions/Bot.fs Normal file
View File

@ -0,0 +1,74 @@
module Degenz.Bot
open System.Threading.Tasks
open DSharpPlus
open DSharpPlus.SlashCommands
open Degenz.Shared
open Emzi0767.Utilities
open Degenz.PlayerInteractions
open Degenz.SlotMachine
open Degenz.Trainer
open Degenz.HackerBattle
open Degenz.Store
type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule ()
let playerInteractionsConfig = DiscordConfiguration()
let trainerConfig = DiscordConfiguration()
let hackerBattleConfig = DiscordConfiguration()
let storeConfig = DiscordConfiguration()
let slotMachineConfig = DiscordConfiguration()
let configs = [| playerInteractionsConfig ; trainerConfig ; hackerBattleConfig ; storeConfig ; slotMachineConfig ; |]
for conf in configs do
conf.TokenType <- TokenType.Bot
conf.Intents <- DiscordIntents.All
playerInteractionsConfig.Token <- "OTIyNDIyMDIyMTI1MDEwOTU1.YcBOcw.JxfW1CSIwEO7j6RbRFCnPZ-HoTk"
trainerConfig.Token <- "OTMzMDg4MTQyNDM5ODk5MTg4.YeccDQ.AbysjlHICgbNQVyduG6aGIHNpdE"
hackerBattleConfig.Token <- "OTMyMzI5NDAzNjYzNDEzMjQ4.YeRZaw.ZyCo5L8HFsCvx8JuhdAwqrH3hZI"
storeConfig.Token <- "OTMyMzA3NTE0ODc4NDg4NjY2.YeRFCA.3NXX4tLObXU3rVgPt8D1fE58FnY"
slotMachineConfig.Token <- "OTMyMzQ3NzQ1NDE3NzE1ODE0.YeRqgA.PHandjk0jQGIxlM8NlqKc7cJD3s"
//config.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace
let playerInteractionsBot = new DiscordClient(playerInteractionsConfig)
let trainerBot = new DiscordClient(trainerConfig)
let hackerBattleBot = new DiscordClient(hackerBattleConfig)
let storeBot = new DiscordClient(storeConfig)
let slotMachineBot = new DiscordClient(slotMachineConfig)
let clients = [| playerInteractionsBot ; trainerBot ; hackerBattleBot ; storeBot ; slotMachineBot |]
let slashCommands =
clients
|> Array.map (fun c -> c.UseSlashCommands())
// My server
let joeServer = 922419263275425832uL
slashCommands.[0].RegisterCommands<PlayerInteractions>(joeServer);
slashCommands.[1].RegisterCommands<Trainer>(joeServer);
slashCommands.[2].RegisterCommands<HackerGame>(joeServer);
slashCommands.[3].RegisterCommands<Store>(joeServer);
slashCommands.[4].RegisterCommands<SlotMachine>(joeServer);
// Degenz
//slash.RegisterCommands<HackerGame>(922414052708327494uL);
let run (client : DiscordClient) =
async {
do! client.ConnectAsync () |> Async.AwaitTask
}
clients
|> Array.map run
|> Array.toSeq
|> Async.Parallel
|> Async.RunSynchronously
|> ignore
Task.Delay(-1)
|> Async.AwaitTask
|> Async.RunSynchronously

View File

@ -1,4 +1,4 @@
module DegenzGame.Commands module Degenz.HackerBattle
open System open System
open System.Threading.Tasks open System.Threading.Tasks
@ -6,7 +6,9 @@ open DSharpPlus
open DSharpPlus.Entities open DSharpPlus.Entities
open DSharpPlus.EventArgs open DSharpPlus.EventArgs
open DSharpPlus.SlashCommands open DSharpPlus.SlashCommands
open DegenzGame.Shared open Degenz
open Emzi0767.Utilities
open Degenz.Shared
[<Literal>] [<Literal>]
// Degenz Server // Degenz Server
@ -201,3 +203,15 @@ let handleButtonEvent (_ : DiscordClient) (event : ComponentInteractionCreateEve
} }
} |> Async.StartAsTask } |> Async.StartAsTask
:> Task :> Task
type HackerGame() =
inherit ApplicationCommandModule ()
[<SlashCommand("hack", "Send a hack attack to another player")>]
member this.AttackCommand (ctx : InteractionContext, [<Option("target", "The player you want to hack")>] target : DiscordUser) =
attack ctx target
[<SlashCommand("defend", "Create a passive defense that will last 24 hours")>]
member this.DefendCommand (ctx : InteractionContext) = defend ctx

View File

@ -0,0 +1,62 @@
[
{
"Name" : "Virus",
"ItemType" : { "Case" : "Weapon" },
"Cost" : 5.0
},
{
"Name" : "Ransom",
"ItemType" : { "Case" : "Weapon" },
"Cost" : 10.0
},
{
"Name" : "Worm",
"ItemType" : { "Case" : "Weapon" },
"Cost" : 5.0
},
{
"Name" : "DDos",
"ItemType" : { "Case" : "Weapon" },
"Cost" : 10.0
},
{
"Name" : "Crack",
"ItemType" : { "Case" : "Weapon" },
"Cost" : 5.0
},
{
"Name" : "Injection",
"ItemType" : { "Case" : "Weapon" },
"Cost" : 10.0
},
{
"Name" : "Firewall",
"ItemType" : { "Case" : "Shield" },
"Cost" : 5.0
},
{
"Name" : "PortScan",
"ItemType" : { "Case" : "Shield" },
"Cost" : 10.0
},
{
"Name" : "Encryption",
"ItemType" : { "Case" : "Shield" },
"Cost" : 5.0
},
{
"Name" : "Hardening",
"ItemType" : { "Case" : "Shield" },
"Cost" : 10.0
},
{
"Name" : "Cypher",
"ItemType" : { "Case" : "Shield" },
"Cost" : 5.0
},
{
"Name" : "Sanitation",
"ItemType" : { "Case" : "Shield" },
"Cost" : 10.0
}
]

View File

@ -1,10 +1,13 @@
module Degenz.PlayerInteractions
open System open System
open System.Threading.Tasks open System.Threading.Tasks
open DSharpPlus.Entities open DSharpPlus.Entities
open DSharpPlus open DSharpPlus
open DSharpPlus.EventArgs
open DSharpPlus.SlashCommands open DSharpPlus.SlashCommands
open DegenzGame open Degenz
open DegenzGame.Shared open Degenz.Shared
module Commands = module Commands =
let newPlayer nickname (membr : uint64) = let newPlayer nickname (membr : uint64) =
@ -109,9 +112,7 @@ module Commands =
} |> Async.StartAsTask } |> Async.StartAsTask
:> Task :> Task
type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule () type PlayerInteractions() =
type PlayerRegistration() =
inherit ApplicationCommandModule () inherit ApplicationCommandModule ()
[<SlashCommand("redpill", "Take the redpill and become a hacker")>] [<SlashCommand("redpill", "Take the redpill and become a hacker")>]
@ -127,30 +128,3 @@ type PlayerRegistration() =
member this.Leaderboard (ctx : InteractionContext) = Commands.leaderboard ctx member this.Leaderboard (ctx : InteractionContext) = Commands.leaderboard ctx
let config = DiscordConfiguration()
config.Token <- "OTIyNDIyMDIyMTI1MDEwOTU1.YcBOcw.JxfW1CSIwEO7j6RbRFCnPZ-HoTk"
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<PlayerRegistration>(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

View File

@ -6,17 +6,22 @@
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<RootNamespace>PlayerRegistration</RootNamespace> <RootNamespace>PlayerRegistration</RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Include="PlayerInteractions.fs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include=".dockerignore" /> <Content Include=".dockerignore" />
<Content Include="Dockerfile" />
<Content Include="paket.references" /> <Content Include="paket.references" />
<Content Include="Dockerfile" />
<Compile Include="Store.fs" />
<Compile Include="HackerBattle.fs" />
<Compile Include="SlotMachine.fs" />
<Compile Include="Trainer.fs" />
<Compile Include="PlayerInteractions.fs" />
<Compile Include="Bot.fs" />
<Content Include="Items.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\DbService\DbService.fsproj" /> <ProjectReference Include="..\DbService\DbService.fsproj" />
<ProjectReference Include="..\Shared\Shared.fsproj" />
</ItemGroup> </ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" /> <Import Project="..\.paket\Paket.Restore.targets" />
</Project> </Project>

View File

@ -1,15 +1,14 @@
module Degenz.SlotMachine
open System open System
open System.Threading.Tasks open System.Threading.Tasks
open DSharpPlus open DSharpPlus
open DSharpPlus.Entities open DSharpPlus.Entities
open DSharpPlus.SlashCommands open DSharpPlus.SlashCommands
open DegenzGame open Degenz.Shared
open DegenzGame.Shared
let slots = [| "https://i.ibb.co/pKqZdr7/cherry.png" ; "https://i.ibb.co/JnghQsL/lemon.jpg" ; "https://i.ibb.co/1JTFPSs/seven.png" |] let slots = [| "https://i.ibb.co/pKqZdr7/cherry.png" ; "https://i.ibb.co/JnghQsL/lemon.jpg" ; "https://i.ibb.co/1JTFPSs/seven.png" |]
type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule ()
type SlotMachine() = type SlotMachine() =
inherit ApplicationCommandModule () inherit ApplicationCommandModule ()
@ -79,31 +78,3 @@ type SlotMachine() =
} |> Async.StartAsTask } |> Async.StartAsTask
:> Task :> Task
let config = DiscordConfiguration()
config.Token <- "OTMyMzQ3NzQ1NDE3NzE1ODE0.YeRqgA.PHandjk0jQGIxlM8NlqKc7cJD3s"
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<SlotMachine>(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

View File

@ -1,11 +1,12 @@
open System module Degenz.Store
open System.Threading.Tasks open System.Threading.Tasks
open DSharpPlus.Entities open DSharpPlus.Entities
open DSharpPlus open DSharpPlus
open DSharpPlus.EventArgs open DSharpPlus.EventArgs
open DSharpPlus.SlashCommands open DSharpPlus.SlashCommands
open DegenzGame open Degenz
open DegenzGame.Shared open Degenz.Shared
open Emzi0767.Utilities open Emzi0767.Utilities
open Newtonsoft.Json open Newtonsoft.Json
@ -175,8 +176,6 @@ module Commands =
} |> Async.StartAsTask } |> Async.StartAsTask
:> Task :> Task
type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule ()
type Store() = type Store() =
inherit ApplicationCommandModule () inherit ApplicationCommandModule ()
@ -195,32 +194,3 @@ type Store() =
member this.SellItem (ctx : InteractionContext) = member this.SellItem (ctx : InteractionContext) =
Commands.sellItem ctx Commands.sellItem ctx
let config = DiscordConfiguration()
config.Token <- "OTMyMzA3NTE0ODc4NDg4NjY2.YeRFCA.3NXX4tLObXU3rVgPt8D1fE58FnY"
config.TokenType <- TokenType.Bot
config.Intents <- DiscordIntents.All
//config.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace
let client = new DiscordClient(config)
client.add_ComponentInteractionCreated(AsyncEventHandler(Commands.handleSellButtonEvents))
let slash = client.UseSlashCommands()
// My server
slash.RegisterCommands<Store>(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

View File

@ -1,15 +1,13 @@
open System module Degenz.Trainer
open System.Threading.Tasks open System.Threading.Tasks
open DSharpPlus open DSharpPlus
open DSharpPlus.Entities open DSharpPlus.Entities
open DSharpPlus.EventArgs open DSharpPlus.EventArgs
open DSharpPlus.SlashCommands open DSharpPlus.SlashCommands
open DegenzGame open Degenz.Shared
open DegenzGame.Shared
open Emzi0767.Utilities open Emzi0767.Utilities
type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule ()
type Trainer() = type Trainer() =
inherit ApplicationCommandModule () inherit ApplicationCommandModule ()
@ -71,16 +69,6 @@ type Trainer() =
} |> Async.StartAsTask } |> Async.StartAsTask
:> Task :> 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()
let sendMessage (event : ComponentInteractionCreateEventArgs) msg = let sendMessage (event : ComponentInteractionCreateEventArgs) msg =
async { async {
let builder = DiscordFollowupMessageBuilder() let builder = DiscordFollowupMessageBuilder()
@ -158,6 +146,15 @@ let handleButtonEvent (_ : DiscordClient) (event : ComponentInteractionCreateEve
|> Async.StartAsTask |> Async.StartAsTask
:> Task :> 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()
client.add_ComponentInteractionCreated(AsyncEventHandler(handleButtonEvent)) client.add_ComponentInteractionCreated(AsyncEventHandler(handleButtonEvent))

View File

@ -1,4 +1,4 @@
module DegenzGame.Shared module Degenz.Shared
open System open System
open DSharpPlus open DSharpPlus

View File

@ -5,8 +5,8 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Shared.fs" />
<Content Include="paket.references" /> <Content Include="paket.references" />
<Compile Include="Shared.fs" />
</ItemGroup> </ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" /> <Import Project="..\.paket\Paket.Restore.targets" />
</Project> </Project>

View File

@ -5,9 +5,6 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Include="SlotMachine.fs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include=".dockerignore" /> <Content Include=".dockerignore" />
<Content Include="Dockerfile" /> <Content Include="Dockerfile" />

View File

@ -5,17 +5,10 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Include="Store.fs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include=".dockerignore" /> <Content Include=".dockerignore" />
<Content Include="Dockerfile" /> <Content Include="Dockerfile" />
<Content Include="paket.references" /> <Content Include="paket.references" />
<Content Include="..\GameConfig\Items.json">
<Link>Items.json</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\DbService\DbService.fsproj" /> <ProjectReference Include="..\DbService\DbService.fsproj" />

View File

@ -3,11 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<OutputType>Exe</OutputType>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Include="Trainer.fs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include=".dockerignore" /> <Content Include=".dockerignore" />
<Content Include="Dockerfile" /> <Content Include="Dockerfile" />