122 lines
4.6 KiB
Forth
122 lines
4.6 KiB
Forth
module Degenz.Embeds
|
|
|
|
open DSharpPlus.EventArgs
|
|
open Degenz.Shared
|
|
open DSharpPlus.Entities
|
|
open AsciiTableFormatter
|
|
|
|
let getHackGif =
|
|
function
|
|
| Hack.Virus -> "https://s10.gifyu.com/images/Attack-DegenZ.gif"
|
|
| Hack.Ransom -> "https://s10.gifyu.com/images/Mind-Control-Degenz-V2.gif"
|
|
| Hack.Worm -> "https://s10.gifyu.com/images/WormBugAttack_Degenz.gif"
|
|
| Hack.DDos -> "https://s10.gifyu.com/images/Attack-DegenZ.gif"
|
|
| Hack.Crack -> "https://s10.gifyu.com/images/Attack-DegenZ.gif"
|
|
| Hack.Injection -> "https://s10.gifyu.com/images/Attack-DegenZ.gif"
|
|
| _ -> "https://s10.gifyu.com/images/Hacker-Degenz-V2.gif"
|
|
|
|
let getShieldGif =
|
|
function
|
|
| Shield.Firewall -> "https://s10.gifyu.com/images/Defense-GIF-1-Degenz.gif"
|
|
| Shield.PortScan -> "https://s10.gifyu.com/images/PortScanDefense_Degenz.gif"
|
|
| Shield.Encryption -> "https://s10.gifyu.com/images/Anonymous-Degenz-V2.gif"
|
|
| Shield.Hardening -> "https://s10.gifyu.com/images/Encryption-Degenz-V2.gif"
|
|
| Shield.Sanitation -> "https://s10.gifyu.com/images/VPN-Degenz.gif"
|
|
| Shield.Cypher -> "https://s10.gifyu.com/images/Matrix_Degenz.gif"
|
|
| _ -> "https://s10.gifyu.com/images/Hacker-Degenz-V2.gif"
|
|
|
|
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 hackInventory
|
|
|> 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)
|