module Degenz.Embeds open System open DSharpPlus.EventArgs open Degenz.Types open DSharpPlus.Entities open AsciiTableFormatter let hackGif = "https://s10.gifyu.com/images/Hacker-Degenz-V20ce8eb832734aa62-min.gif" let shieldGif = "https://s10.gifyu.com/images/Defense-Degenz-V2-min.gif" let getHackGif = function | HackId.Virus -> "https://s10.gifyu.com/images/Attack-DegenZ-1.gif" | HackId.RemoteAccess -> "https://s10.gifyu.com/images/Mind-Control-Degenz-V2-min.gif" | HackId.Worm -> "https://s10.gifyu.com/images/WormBugAttack_Degenz-min.gif" | _ -> hackGif let getShieldGif = function | ShieldId.Firewall -> "https://s10.gifyu.com/images/Defense-GIF-1-Degenz-min.gif" | ShieldId.Encryption -> "https://s10.gifyu.com/images/Encryption-Degenz-V2-1-min.gif" | ShieldId.Cypher -> "https://s10.gifyu.com/images/Cypher-Smaller.gif" | _ -> shieldGif 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 = Messaging.constructButtons actionId (string player.DiscordId) (Player.shields player) |> Seq.cast let embed = DiscordEmbedBuilder() .WithColor(DiscordColor.Blurple) .WithDescription("Pick a shield to protect yourself from hacks") .WithImageUrl(shieldGif) DiscordFollowupMessageBuilder() .AddComponents(buttons) .AddEmbed(embed) .AsEphemeral true let pickHack actionId attacker defender = let buttons = let hacks = Player.hacks attacker Messaging.constructButtons actionId $"{defender.DiscordId}-{defender.Name}" hacks |> Seq.cast let embed = DiscordEmbedBuilder() .WithColor(DiscordColor.Blurple) .WithDescription("Pick the hack that you want to use") .WithImageUrl(hackGif) DiscordFollowupMessageBuilder() .AddComponents(buttons) .AddEmbed(embed.Build()) .AsEphemeral true let responseSuccessfulHack (hack : BattleItem) = let embed = DiscordEmbedBuilder() embed.ImageUrl <- getHackGif (enum(hack.Id)) DiscordFollowupMessageBuilder() .WithContent($"You successfully hacked <@{GuildEnvironment.botHackerBattle}> using {hack.Name}, and stole 💰$GBT {Game.HackPrize} from them!") .AddEmbed(embed.Build()) .AsEphemeral(true) let responseCreatedShield (shield : BattleItem) = DiscordFollowupMessageBuilder() .AddEmbed(DiscordEmbedBuilder().WithImageUrl(getShieldGif (enum(shield.Id)))) .AsEphemeral(true) .WithContent($"Mounted {shield.Name} shield for {TimeSpan.FromMinutes(int shield.Cooldown).Hours} hours") let responseCreatedShieldTrainer (shield : BattleItem) = DiscordFollowupMessageBuilder() .AddEmbed(DiscordEmbedBuilder().WithImageUrl(getShieldGif (enum(shield.Id)))) .AsEphemeral(true) .WithContent($"Mounted a {shield.Name} defense for 6 hours") let eventSuccessfulHack (event : ComponentInteractionCreateEventArgs) targetId prize = 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(hackGif) // DiscordMessageBuilder() .WithContent($"{event.User.Username} successfully hacked <@{targetId}> for a total of {prize} GoodBoyTokenz") [] type Table = { Name : string Cost : string Class : string } let storeListing store = let embeds = store |> Array.groupBy (fun (bi : BattleItem) -> bi.Type) |> Array.map (fun ( itemType , items ) -> let msg = items |> Array.map (fun item -> { Name = item.Name ; Cost = string item.Cost ; Class = string item.Class }) |> Formatter.Format |> sprintf "**%As**\n``` %s ```" itemType DiscordEmbedBuilder() .WithDescription(msg) .Build()) DiscordInteractionResponseBuilder() .AddEmbeds(embeds) .AsEphemeral(true)