module Joebot.Functions open System open System.Threading.Tasks open DSharpPlus open DSharpPlus.Entities open DSharpPlus.SlashCommands open Joebot.Types let hackDescription = "" let statusFormat player = $"Hack Inventory: {player.Weapons} Shield Inventory: {player.Shields} Active Hacks: {player.Attacks} Active Defenses: {player.Defenses} Bank: {player.Bank}" let newPlayer nickname (membr : uint64) = let h1 = [| Virus ; Ransom |] let h2 = [| DDos ; Worm |] let h3 = [| Crack ; Injection |] let d1 = [| Firewall ; PortScan |] let d2 = [| Encryption ; Cypher |] let d3 = [| Hardening ; Sanitation |] let rand = System.Random(System.Guid.NewGuid().GetHashCode()) let getRandom (actions : 'a array) = actions.[rand.Next(0,2)] let weapons = [ getRandom h1 ; getRandom h2 ; getRandom h3 ] let shields = [ getRandom d1 ; getRandom d2 ; getRandom d3 ] { DiscordId = membr Name = nickname Weapons = weapons Shields = shields Attacks = [] Defenses = [] Bank = 0f } let constructButtons (actionType : string) (playerInfo : string) (weapons : 'a list) = weapons |> Seq.map (fun hack -> DiscordButtonComponent( ButtonStyle.Primary, $"{actionType}-{hack}-{playerInfo}", $"{hack}")) let createSimpleResponseAsync msg (ctx : InteractionContext) = async { let builder = DiscordInteractionResponseBuilder() builder.Content <- msg builder.AsEphemeral true |> ignore do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask } |> Async.StartAsTask :> Task let notYetAHackerMsg = createSimpleResponseAsync "You are not currently a hacker, first use the /redpill command to become one" let removeExpiredActions timespan (timestamp : 'a -> DateTime) actions = actions |> List.filter (fun act -> if DateTime.UtcNow - (timestamp act) < timespan then true else false) let constructEmbed message = let builder = DiscordEmbedBuilder() builder.Color <- Optional(DiscordColor.PhthaloGreen) builder.Description <- message let author = DiscordEmbedBuilder.EmbedAuthor() author.Name <- "Joebot Pro" author.Url <- "https://twitter.com/degenzgame" author.IconUrl <- "https://pbs.twimg.com/profile_images/1473192843359309825/cqjm0VQ4_400x400.jpg" builder.Author <- author builder.Build() let calculateDamage (hack : IClass) (protection : IClass) = let hackClass = hack.GetClass() let protectionClass = protection.GetClass() match hackClass , protectionClass with | h , p when h = p -> Weak | _ -> Strong