Only assign role if there weren't any errors
This commit is contained in:
parent
5fb7d83ac0
commit
43f947145f
@ -2,6 +2,7 @@ module Degenz.Store
|
|||||||
|
|
||||||
open System
|
open System
|
||||||
open System.Data
|
open System.Data
|
||||||
|
open System.Threading.Tasks
|
||||||
open DSharpPlus.Entities
|
open DSharpPlus.Entities
|
||||||
open DSharpPlus
|
open DSharpPlus
|
||||||
open DSharpPlus.EventArgs
|
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
|
// 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 {
|
executePlayerAction ctx (fun player -> async {
|
||||||
let storeId = ctx.GetInteractionId().Split("-").[2]
|
let storeId = ctx.GetInteractionId().Split("-").[2]
|
||||||
let! storeInventory = DbService.getStoreItems storeId
|
let! storeInventory = DbService.getStoreItems storeId
|
||||||
@ -262,6 +263,8 @@ let handleBuyItem (ctx : IDiscordContext) itemId =
|
|||||||
builder.AddEmbed(embed) |> ignore
|
builder.AddEmbed(embed) |> ignore
|
||||||
do! ctx.FollowUp builder |> Async.AwaitTask
|
do! ctx.FollowUp builder |> Async.AwaitTask
|
||||||
|
|
||||||
|
do! dispatch ctx |> Async.AwaitTask
|
||||||
|
|
||||||
let builder = DiscordMessageBuilder()
|
let builder = DiscordMessageBuilder()
|
||||||
builder.WithContent($"{player.Name} just purchased {item.Name}!") |> ignore
|
builder.WithContent($"{player.Name} just purchased {item.Name}!") |> ignore
|
||||||
let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelEventsHackerBattle)
|
let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelEventsHackerBattle)
|
||||||
@ -322,7 +325,7 @@ let handleJpegEvents _ (event : ComponentInteractionCreateEventArgs) =
|
|||||||
let itemId = id.Split("-").[1]
|
let itemId = id.Split("-").[1]
|
||||||
let storeId = id.Split("-").[2]
|
let storeId = id.Split("-").[2]
|
||||||
match id with
|
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("ShowStore") -> buy storeId None ctx
|
||||||
| id when id.StartsWith("ShowJpegInventory") -> showJpegsEmbed ctx
|
| id when id.StartsWith("ShowJpegInventory") -> showJpegsEmbed ctx
|
||||||
| _ ->
|
| _ ->
|
||||||
@ -339,7 +342,7 @@ let handleStoreEvents _ (event : ComponentInteractionCreateEventArgs) =
|
|||||||
let itemId = id.Split("-").[1]
|
let itemId = id.Split("-").[1]
|
||||||
let storeId = id.Split("-").[2]
|
let storeId = id.Split("-").[2]
|
||||||
match id with
|
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("Sell") -> handleSell ctx itemId
|
||||||
| id when id.StartsWith("ShowHacks") -> buy storeId (Some ItemType.Hack) ctx
|
| id when id.StartsWith("ShowHacks") -> buy storeId (Some ItemType.Hack) ctx
|
||||||
| id when id.StartsWith("ShowShields") -> buy storeId (Some ItemType.Shield) ctx
|
| id when id.StartsWith("ShowShields") -> buy storeId (Some ItemType.Shield) ctx
|
||||||
|
@ -57,8 +57,9 @@ let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) =
|
|||||||
task {
|
task {
|
||||||
let id = ctx.GetInteractionId()
|
let id = ctx.GetInteractionId()
|
||||||
let itemId = id.Split("-").[1]
|
let itemId = id.Split("-").[1]
|
||||||
do! Store.handleBuyItem ctx itemId
|
let dispatch ctx = grantWhitelistRole (itemId = "WHITEOG") ctx
|
||||||
do! grantWhitelistRole (itemId = "WHITEOG") ctx
|
|
||||||
|
do! Store.handleBuyItem dispatch ctx itemId
|
||||||
} :> Task
|
} :> Task
|
||||||
| id when id.StartsWith("CreateGuildInvite") -> InviteTracker.handleCreateInvite ctx
|
| id when id.StartsWith("CreateGuildInvite") -> InviteTracker.handleCreateInvite ctx
|
||||||
| id when id.StartsWith("ShowRecruited") -> InviteTracker.getInvitedUsersForId (ctx.GetDiscordMember()) ctx
|
| id when id.StartsWith("ShowRecruited") -> InviteTracker.getInvitedUsersForId (ctx.GetDiscordMember()) ctx
|
||||||
|
Loading…
x
Reference in New Issue
Block a user