Don't block

This commit is contained in:
Joseph Ferano 2022-06-22 00:22:26 +07:00
parent 518c33d721
commit 793b61267d
2 changed files with 16 additions and 8 deletions

View File

@ -66,7 +66,8 @@ let handleTrainerStep1 (ctx : IDiscordContext) =
do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask
do! Analytics.trainingDojoStep "LFG" (ctx.GetDiscordMember().Id) (ctx.GetDiscordMember().Username) do! Analytics.trainingDojoStep "LFG" (ctx.GetDiscordMember().Id) (ctx.GetDiscordMember().Username)
} |> Async.StartAsTask :> Task } |> Async.Start
Task.CompletedTask
let defend (ctx : IDiscordContext) = let defend (ctx : IDiscordContext) =
async { async {
@ -76,7 +77,8 @@ let defend (ctx : IDiscordContext) =
let embed = Embeds.pickDefense "Trainer-2" { PlayerData.empty with Inventory = [ shieldItem ] ; Name = name } true let embed = Embeds.pickDefense "Trainer-2" { PlayerData.empty with Inventory = [ shieldItem ] ; Name = name } true
do! ctx.FollowUp(embed) |> Async.AwaitTask do! ctx.FollowUp(embed) |> Async.AwaitTask
do! Analytics.trainingDojoStep "DefendCommand" (ctx.GetDiscordMember().Id) (ctx.GetDiscordMember().Username) do! Analytics.trainingDojoStep "DefendCommand" (ctx.GetDiscordMember().Id) (ctx.GetDiscordMember().Username)
} |> Async.StartAsTask :> Task } |> Async.Start
Task.CompletedTask
let handleDefenseMsg hackId = { let handleDefenseMsg hackId = {
ButtonId = "Trainer-3" ButtonId = "Trainer-3"
@ -101,7 +103,8 @@ let handleDefense (ctx : IDiscordContext) =
do! Async.Sleep 1500 do! Async.Sleep 1500
do! sendFollowUpMessageWithButton ctx (handleDefenseMsg defaultHack.Name) do! sendFollowUpMessageWithButton ctx (handleDefenseMsg defaultHack.Name)
do! Analytics.trainingDojoStep "ShieldActivated" (ctx.GetDiscordMember().Id) (ctx.GetDiscordMember().Username) do! Analytics.trainingDojoStep "ShieldActivated" (ctx.GetDiscordMember().Id) (ctx.GetDiscordMember().Username)
} |> Async.StartAsTask :> Task } |> Async.Start
Task.CompletedTask
let handleTrainerStep3 (ctx : IDiscordContext) = let handleTrainerStep3 (ctx : IDiscordContext) =
async { async {
@ -115,7 +118,8 @@ let handleTrainerStep3 (ctx : IDiscordContext) =
do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask
do! Analytics.trainingDojoStep "LetsHack" (ctx.GetDiscordMember().Id) (ctx.GetDiscordMember().Username) do! Analytics.trainingDojoStep "LetsHack" (ctx.GetDiscordMember().Id) (ctx.GetDiscordMember().Username)
} |> Async.StartAsTask :> Task } |> Async.Start
Task.CompletedTask
let hack (target : DiscordUser) (ctx : IDiscordContext) = let hack (target : DiscordUser) (ctx : IDiscordContext) =
async { async {
@ -137,7 +141,8 @@ let hack (target : DiscordUser) (ctx : IDiscordContext) =
do! ctx.FollowUp(builder) |> Async.AwaitTask do! ctx.FollowUp(builder) |> Async.AwaitTask
do! Analytics.trainingDojoStep "HackCommand" (ctx.GetDiscordMember().Id) (ctx.GetDiscordMember().Username) do! Analytics.trainingDojoStep "HackCommand" (ctx.GetDiscordMember().Id) (ctx.GetDiscordMember().Username)
} |> Async.StartAsTask :> Task } |> Async.Start
Task.CompletedTask
let handleHack (ctx : IDiscordContext) = let handleHack (ctx : IDiscordContext) =
PlayerInteractions.executePlayerAction ctx (fun player -> async { PlayerInteractions.executePlayerAction ctx (fun player -> async {

View File

@ -14,7 +14,8 @@ let executePlayerAction (ctx : IDiscordContext) (dispatch : PlayerData -> Async<
match playerResult with match playerResult with
| Some player -> do! dispatch player | Some player -> do! dispatch player
| None -> do! Messaging.sendFollowUpMessage ctx "You are currently not a hacker, first use the /redpill command to become one" | None -> do! Messaging.sendFollowUpMessage ctx "You are currently not a hacker, first use the /redpill command to become one"
} |> Async.StartAsTask :> Task } |> Async.Start
Task.CompletedTask
let executePlayerActionNoMsg (ctx : IDiscordContext) (dispatch : PlayerData -> Async<unit>) = let executePlayerActionNoMsg (ctx : IDiscordContext) (dispatch : PlayerData -> Async<unit>) =
async { async {
@ -24,7 +25,8 @@ let executePlayerActionNoMsg (ctx : IDiscordContext) (dispatch : PlayerData -> A
match playerResult with match playerResult with
| Some player -> do! dispatch player | Some player -> do! dispatch player
| None -> do! Messaging.sendFollowUpMessage ctx "You are currently not a hacker, first use the /redpill command to become one" | None -> do! Messaging.sendFollowUpMessage ctx "You are currently not a hacker, first use the /redpill command to become one"
} |> Async.StartAsTask :> Task } |> Async.Start
Task.CompletedTask
let executePlayerActionWithTarget (targetPlayer : DiscordUser) (ctx : IDiscordContext) (dispatch : PlayerData -> PlayerData -> Async<unit>) = let executePlayerActionWithTarget (targetPlayer : DiscordUser) (ctx : IDiscordContext) (dispatch : PlayerData -> PlayerData -> Async<unit>) =
async { async {
@ -43,7 +45,8 @@ let executePlayerActionWithTarget (targetPlayer : DiscordUser) (ctx : IDiscordCo
if targetPlayer.IsBot if targetPlayer.IsBot
then do! Messaging.sendFollowUpMessage ctx $"{targetPlayer.Username} is a bot, pick a real human to hack" then do! Messaging.sendFollowUpMessage ctx $"{targetPlayer.Username} is a bot, pick a real human to hack"
else do! Messaging.sendFollowUpMessage ctx "Your target is not connected to the network, they must join first by using the /redpill command" else do! Messaging.sendFollowUpMessage ctx "Your target is not connected to the network, they must join first by using the /redpill command"
} |> Async.StartAsTask :> Task } |> Async.Start
Task.CompletedTask
let executePlayerActionWithTargetId defer (targetId : uint64) (ctx : IDiscordContext) (dispatch : PlayerData -> PlayerData -> Async<unit>) = let executePlayerActionWithTargetId defer (targetId : uint64) (ctx : IDiscordContext) (dispatch : PlayerData -> PlayerData -> Async<unit>) =
async { async {