102 lines
3.5 KiB
Forth
102 lines
3.5 KiB
Forth
module Degenz.Embeds
|
|
|
|
open DSharpPlus.EventArgs
|
|
open Degenz.Shared
|
|
open DSharpPlus.Entities
|
|
open AsciiTableFormatter
|
|
|
|
let constructEmbed message =
|
|
let builder = DiscordEmbedBuilder()
|
|
builder.Color <- Optional(DiscordColor.Blurple)
|
|
builder.Description <- message
|
|
let author = DiscordEmbedBuilder.EmbedAuthor()
|
|
author.Name <- "Degenz Hacker Game"
|
|
author.Url <- "https://twitter.com/degenzgame"
|
|
author.IconUrl <- "https://pbs.twimg.com/profile_images/1473192843359309825/cqjm0VQ4_400x400.jpg"
|
|
builder.Author <- author
|
|
builder.Build()
|
|
|
|
let pickDefense actionId player =
|
|
let buttons =
|
|
constructButtons actionId (string player.DiscordId) player.Shields
|
|
|> Seq.cast<DiscordComponent>
|
|
|
|
let embed =
|
|
DiscordEmbedBuilder()
|
|
.WithColor(DiscordColor.Blurple)
|
|
.WithDescription("Pick a defense to mount for 10 hours")
|
|
.WithImageUrl("https://s10.gifyu.com/images/Defense-Degenz-V2.gif")
|
|
|
|
DiscordInteractionResponseBuilder()
|
|
.AddComponents(buttons)
|
|
.AddEmbed(embed)
|
|
.AsEphemeral true
|
|
|
|
let pickHack actionId attacker defender =
|
|
let buttons =
|
|
constructButtons actionId $"{defender.DiscordId}-{defender.Name}" attacker.Weapons
|
|
|> Seq.cast<DiscordComponent>
|
|
|
|
let embed =
|
|
DiscordEmbedBuilder()
|
|
.WithColor(DiscordColor.Blurple)
|
|
.WithDescription("Pick the hack that you want to use")
|
|
.WithImageUrl("https://s10.gifyu.com/images/Hacker-Degenz-V2.gif")
|
|
|
|
DiscordInteractionResponseBuilder()
|
|
.AddComponents(buttons)
|
|
.AddEmbed(embed.Build())
|
|
.AsEphemeral true
|
|
|
|
let eventSuccessfulHack (event : ComponentInteractionCreateEventArgs) targetId prize =
|
|
let embed =
|
|
DiscordEmbedBuilder()
|
|
.WithColor(DiscordColor.Blurple)
|
|
.WithDescription("Pick the hack that you want to use")
|
|
.WithImageUrl("https://s10.gifyu.com/images/Hacker-Degenz-V2.gif")
|
|
|
|
DiscordMessageBuilder()
|
|
.WithContent($"{event.User.Username} successfully hacked <@{targetId}> for a total of {prize} GoodBoyTokenz")
|
|
|
|
let eventFailedHack (event : ComponentInteractionCreateEventArgs) targetId prize =
|
|
let embed =
|
|
DiscordEmbedBuilder()
|
|
.WithColor(DiscordColor.Blurple)
|
|
.WithDescription("Pick the hack that you want to use")
|
|
.WithImageUrl("https://s10.gifyu.com/images/Hacker-Degenz-V2.gif")
|
|
|
|
DiscordMessageBuilder()
|
|
.WithContent($"{event.User.Username} successfully hacked <@{targetId}> for a total of {prize} GoodBoyTokenz")
|
|
|
|
[<CLIMutable>]
|
|
type Table = {
|
|
Name : string
|
|
Cost : string
|
|
Class : string
|
|
}
|
|
|
|
let storeListing store =
|
|
let embeds =
|
|
store
|
|
|> Array.map (fun ( itemType , items ) ->
|
|
items
|
|
|> Array.map (fun (item : Item) ->
|
|
let itemClass =
|
|
if itemType = ItemType.Hack
|
|
then weaponInventory
|
|
|> Array.find (fun w -> item.Name = string w)
|
|
|> int
|
|
|> getClass
|
|
else shieldInventory
|
|
|> Array.find (fun w -> item.Name = string w)
|
|
|> int
|
|
|> getClass
|
|
{ Name = item.Name ; Cost = string item.Cost ; Class = string itemClass })
|
|
|> Formatter.Format
|
|
|> sprintf "**%As**\n``` %s ```" itemType
|
|
|> constructEmbed)
|
|
|
|
DiscordInteractionResponseBuilder()
|
|
.AddEmbeds(embeds)
|
|
.AsEphemeral(true)
|