diff --git a/Bot/Games/Store.fs b/Bot/Games/Store.fs index ad7c872..a53f58e 100644 --- a/Bot/Games/Store.fs +++ b/Bot/Games/Store.fs @@ -2,6 +2,7 @@ module Degenz.Store open System open System.Data +open System.Threading.Tasks open DSharpPlus.Entities open DSharpPlus open DSharpPlus.EventArgs @@ -233,7 +234,7 @@ let sell itemType getItems (ctx : IDiscordContext) = }) // TODO: When you buy a shield, prompt the user to activate it -let handleBuyItem (ctx : IDiscordContext) itemId = +let handleBuyItem (dispatch : IDiscordContext -> Task) (ctx : IDiscordContext) itemId = executePlayerAction ctx (fun player -> async { let storeId = ctx.GetInteractionId().Split("-").[2] let! storeInventory = DbService.getStoreItems storeId @@ -262,6 +263,8 @@ let handleBuyItem (ctx : IDiscordContext) itemId = builder.AddEmbed(embed) |> ignore do! ctx.FollowUp builder |> Async.AwaitTask + do! dispatch ctx |> Async.AwaitTask + let builder = DiscordMessageBuilder() builder.WithContent($"{player.Name} just purchased {item.Name}!") |> ignore let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelEventsHackerBattle) @@ -322,7 +325,7 @@ let handleJpegEvents _ (event : ComponentInteractionCreateEventArgs) = let itemId = id.Split("-").[1] let storeId = id.Split("-").[2] match id with - | id when id.StartsWith("Buy") -> handleBuyItem ctx itemId + | id when id.StartsWith("Buy") -> handleBuyItem (fun _ -> Task.CompletedTask) ctx itemId | id when id.StartsWith("ShowStore") -> buy storeId None ctx | id when id.StartsWith("ShowJpegInventory") -> showJpegsEmbed ctx | _ -> @@ -339,7 +342,7 @@ let handleStoreEvents _ (event : ComponentInteractionCreateEventArgs) = let itemId = id.Split("-").[1] let storeId = id.Split("-").[2] match id with - | id when id.StartsWith("Buy") -> handleBuyItem ctx itemId + | id when id.StartsWith("Buy") -> handleBuyItem (fun _ -> Task.CompletedTask) ctx itemId | id when id.StartsWith("Sell") -> handleSell ctx itemId | id when id.StartsWith("ShowHacks") -> buy storeId (Some ItemType.Hack) ctx | id when id.StartsWith("ShowShields") -> buy storeId (Some ItemType.Shield) ctx diff --git a/Bot/Whitelist.fs b/Bot/Whitelist.fs index 3e240c5..1066996 100644 --- a/Bot/Whitelist.fs +++ b/Bot/Whitelist.fs @@ -57,8 +57,9 @@ let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) = task { let id = ctx.GetInteractionId() let itemId = id.Split("-").[1] - do! Store.handleBuyItem ctx itemId - do! grantWhitelistRole (itemId = "WHITEOG") ctx + let dispatch ctx = grantWhitelistRole (itemId = "WHITEOG") ctx + + do! Store.handleBuyItem dispatch ctx itemId } :> Task | id when id.StartsWith("CreateGuildInvite") -> InviteTracker.handleCreateInvite ctx | id when id.StartsWith("ShowRecruited") -> InviteTracker.getInvitedUsersForId (ctx.GetDiscordMember()) ctx