Various improvements for item embeds
This commit is contained in:
parent
ecebe43d99
commit
6106ff81c2
@ -111,6 +111,11 @@ let getItemEmbeds owned (items : StoreItem list) =
|
||||
let arr : obj array = values |> Seq.map snd |> Seq.cast<obj> |> Seq.toArray
|
||||
table.Rows.Add(arr) |> ignore
|
||||
|
||||
// TODO: This isn't working, try something else
|
||||
// if not (String.IsNullOrEmpty item.Item.Description) then
|
||||
// embed.Url <- item.Item.Description
|
||||
// embed.Footer <- DiscordEmbedBuilder.EmbedFooter()
|
||||
// embed.Footer.Text <- item.Item.Description
|
||||
embed
|
||||
.WithColor(WeaponClass.getClassEmbedColor item.Item)
|
||||
.WithTitle(titleText)
|
||||
@ -150,14 +155,16 @@ let getBuyItemsEmbed storeId player (storeInventory : StoreItem list) =
|
||||
|> List.iter (fun btns -> builder.AddComponents(btns) |> ignore)
|
||||
builder
|
||||
|
||||
let purchaseItemEmbed (item : Item) =
|
||||
let purchaseItemEmbed quantity (item : Item) =
|
||||
let embed = DiscordEmbedBuilder()
|
||||
embed.ImageUrl <- item.ImageUrl
|
||||
embed.Title <- $"Purchased {item.Name}"
|
||||
embed.Title <- $"Purchased {quantity}x {item.Name}"
|
||||
match item.Type with
|
||||
| ItemType.Jpeg ->
|
||||
embed.Description <- $"Congratulations! You are in the draw for the {item.Name}. The winner will be announced soon in the <#{GuildEnvironment.channelGiveaway}>"
|
||||
embed.ImageUrl <- item.ImageUrl
|
||||
embed.Thumbnail <- DiscordEmbedBuilder.EmbedThumbnail()
|
||||
embed.Thumbnail.Url <- item.IconUrl
|
||||
| _ -> embed.Description <- $"Purchased {item.Name}"
|
||||
embed
|
||||
|
||||
@ -242,7 +249,17 @@ let handleBuyItem (ctx : IDiscordContext) itemId =
|
||||
if storeItem.LimitStock = true && storeItem.Stock > 0 then
|
||||
do! DbService.decrementItemStock item |> Async.Ignore
|
||||
let builder = DiscordFollowupMessageBuilder().AsEphemeral(true)
|
||||
builder.AddEmbed(purchaseItemEmbed (item)) |> ignore
|
||||
let embed = purchaseItemEmbed 1 item
|
||||
match item.Attributes , getTotalOwnedOfItem item player.Inventory |> Option.defaultValue 0 with
|
||||
| CanStack max , amount ->
|
||||
// TODO: Maybe find a way to show current amount owned
|
||||
embed.AddField("Owned", $"{amount + 1}", true) |> ignore
|
||||
embed.AddField("New $GBT Balance", $"`💰` {player.Bank} ⋙ `💰` {player.Bank - price} `({price} $GBT)`", true) |> ignore
|
||||
if amount + 1 < max then
|
||||
let btn = DiscordButtonComponent(WeaponClass.getClassButtonColor item, $"Buy-{item.Id}-{storeId}", $"Buy Another")
|
||||
builder.AddComponents(btn) |> ignore
|
||||
| _ -> ()
|
||||
builder.AddEmbed(embed) |> ignore
|
||||
do! ctx.FollowUp builder |> Async.AwaitTask
|
||||
do! Analytics.buyWeaponButton (ctx.GetDiscordMember()) item.Name price
|
||||
})
|
||||
@ -320,7 +337,8 @@ let handleJpegEvents _ (event : ComponentInteractionCreateEventArgs) =
|
||||
let storeId = id.Split("-").[2]
|
||||
match id with
|
||||
| id when id.StartsWith("Buy") -> handleBuyItem ctx itemId
|
||||
| id when id.StartsWith("ShowJpegInventory") -> buy storeId None ctx
|
||||
| id when id.StartsWith("ShowJpegStore") -> buy storeId None ctx
|
||||
| id when id.StartsWith("ShowJpegInventory") -> showJpegsEmbed ctx
|
||||
| _ ->
|
||||
task {
|
||||
let builder = DiscordInteractionResponseBuilder()
|
||||
@ -338,7 +356,6 @@ let handleStoreEvents _ (event : ComponentInteractionCreateEventArgs) =
|
||||
| id when id.StartsWith("Buy") -> handleBuyItem ctx itemId
|
||||
| id when id.StartsWith("Sell") -> handleSell ctx itemId
|
||||
| id when id.StartsWith("Consume") -> handleConsume ctx itemId
|
||||
| id when id.StartsWith("ShowJpegInventory") -> buy storeId None ctx
|
||||
| id when id.StartsWith("ShowHacks") -> buy storeId (Some ItemType.Hack) ctx
|
||||
| id when id.StartsWith("ShowShields") -> buy storeId (Some ItemType.Shield) ctx
|
||||
| _ ->
|
||||
@ -360,8 +377,9 @@ let sendBackalleyEmbed (ctx : IDiscordContext) =
|
||||
embed.Color <- DiscordColor.Black
|
||||
embed.Description <- "Hey, what do you want kid?"
|
||||
builder.AddEmbed embed |> ignore
|
||||
let button = DiscordButtonComponent(ButtonStyle.Success, $"ShowJpegInventory-0-BACKALLEY", $"NFT Raffles") :> DiscordComponent
|
||||
builder.AddComponents [| button |] |> ignore
|
||||
let button1 = DiscordButtonComponent(ButtonStyle.Success, $"ShowJpegStore-0-BACKALLEY", $"NFT Raffles") :> DiscordComponent
|
||||
let button2 = DiscordButtonComponent(ButtonStyle.Primary, $"ShowJpegInventory-0-BACKALLEY", $"View My Stash") :> DiscordComponent
|
||||
builder.AddComponents [| button1 ; button2 |] |> ignore
|
||||
|
||||
do! GuildEnvironment.botClientJpeg.Value.SendMessageAsync(channel, builder)
|
||||
|> Async.AwaitTask
|
||||
@ -395,6 +413,6 @@ let sendArmoryEmbed (ctx : IDiscordContext) =
|
||||
type JpegStore() =
|
||||
inherit ApplicationCommandModule ()
|
||||
|
||||
[<SlashCommand("jpegs", "Check jpegs or raffle tickets you own")>]
|
||||
member this.Inventory (ctx : InteractionContext) =
|
||||
showJpegsEmbed (DiscordInteractionContext ctx)
|
||||
// [<SlashCommand("jpegs", "Check jpegs or raffle tickets you own")>]
|
||||
// member this.Inventory (ctx : InteractionContext) =
|
||||
// showJpegsEmbed (DiscordInteractionContext ctx)
|
Loading…
x
Reference in New Issue
Block a user