From eeedf9eccd6de413f374d8c5fe9c04d4116b6f2a Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sat, 5 Mar 2022 22:35:41 +0700 Subject: [PATCH] Fix a few bugs --- Bot/Bot.fs | 4 ++-- Bot/Games/Store.fs | 2 +- Bot/Games/Trainer.fs | 14 +++++++++----- Bot/GuildEnvironment.fs | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Bot/Bot.fs b/Bot/Bot.fs index b951662..b8e4ba1 100644 --- a/Bot/Bot.fs +++ b/Bot/Bot.fs @@ -81,8 +81,8 @@ let asdf (_ : DiscordClient) (event : DSharpPlus.EventArgs.InteractionCreateEven :> Task //hackerBattleBot.add_InteractionCreated(AsyncEventHandler(asdf)) -if guild <> 922419263275425832uL then - Trainer.sendInitialEmbed hackerBattleBot +//if guild <> 922419263275425832uL then +// Trainer.sendInitialEmbed hackerBattleBot hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser diff --git a/Bot/Games/Store.fs b/Bot/Games/Store.fs index bc2e1c2..eac30da 100644 --- a/Bot/Games/Store.fs +++ b/Bot/Games/Store.fs @@ -62,7 +62,7 @@ let getSellEmbed (items : ItemDetails list) = .WithTitle($"{item.Name}") .WithColor(WeaponClass.getClassEmbedColor item) .Build() - , DiscordButtonComponent(WeaponClass.getClassButtonColor item, $"Sell-{id}", $"Sell {item.Name}") :> DiscordComponent) + , DiscordButtonComponent(WeaponClass.getClassButtonColor item, $"Sell-{item.Id}", $"Sell {item.Name}") :> DiscordComponent) |> List.unzip DiscordFollowupMessageBuilder() diff --git a/Bot/Games/Trainer.fs b/Bot/Games/Trainer.fs index dbebebd..2459bdd 100644 --- a/Bot/Games/Trainer.fs +++ b/Bot/Games/Trainer.fs @@ -12,7 +12,7 @@ let Sensei = { Id = GuildEnvironment.botIdHackerBattle ; Name = "Sensei" } let defaultHack = Armory.weapons |> Inventory.findHackById (int ItemId.Virus) let defaultShield = Armory.weapons |> Inventory.findShieldById (int ItemId.Firewall) -let HackEvent = { +let HackEvent () = { Timestamp = System.DateTime.UtcNow Cooldown = 1 Type = Hacking { @@ -22,7 +22,7 @@ let HackEvent = { HackId = defaultHack.Item.Id } } -let ShieldEvent = { +let ShieldEvent () = { Timestamp = System.DateTime.UtcNow Cooldown = defaultShield.Cooldown Type = Shielding defaultShield.Item.Id @@ -185,7 +185,7 @@ let handleArsenal (ctx : IDiscordContext) = |> List.exists (fun e -> match e.Type with Shielding shieldId -> shieldId = defaultShield.Item.Id | _ -> false) if hasShield then [] - else [ ShieldEvent ] + else [ ShieldEvent() ] let updatedPlayer = { Player.removeExpiredActions player with Events = shieldEvent @ player.Events @@ -194,11 +194,15 @@ let handleArsenal (ctx : IDiscordContext) = if not (List.isEmpty hack) || not (List.isEmpty shield) then do! DbService.updatePlayer updatedPlayer |> Async.Ignore if not (List.isEmpty shieldEvent) then - do! DbService.addPlayerEvent player.DiscordId (List.head shieldEvent) |> Async.Ignore + try + do! DbService.addPlayerEvent player.DiscordId (List.head shieldEvent) |> Async.Ignore + with ex -> + printfn "%s" ex.Message + () let playerForEmbed = { player with - Events = [ HackEvent ; ShieldEvent ] + Events = [ HackEvent() ; ShieldEvent() ] Inventory = hack @ shield @ player.Inventory } let embed = Embeds.getArsenalEmbed playerForEmbed diff --git a/Bot/GuildEnvironment.fs b/Bot/GuildEnvironment.fs index 140057d..c6047d5 100644 --- a/Bot/GuildEnvironment.fs +++ b/Bot/GuildEnvironment.fs @@ -4,8 +4,8 @@ module Degenz.GuildEnvironment open System open DSharpPlus.Entities open dotenv.net -DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../.dev.env" ], overwriteExistingVars = false)) -//DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../.stag.env" ], overwriteExistingVars = false)) +//DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../.dev.env" ], overwriteExistingVars = false)) +DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../.stag.env" ], overwriteExistingVars = false)) //DotEnv.Load(DotEnvOptions(envFilePaths = [ "../../../../.prod.env" ], overwriteExistingVars = false)) let getVar str = Environment.GetEnvironmentVariable(str)