module Degenz.Embeds open System open Degenz open Degenz.Messaging open DSharpPlus.Entities 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 constructButtons (actionId: string) (buttonInfo : string) (player: PlayerData) (items : Inventory) ignoreCooldown = items |> List.map (fun item -> let action = player.Events |> List.tryFind (fun event -> match event.Type with | Hacking h -> h.HackId = item.Id && h.IsInstigator | Shielding id -> id = item.Id | _ -> false) let btnColor = WeaponClass.getClassButtonColor item match action , ignoreCooldown with | None , _ | Some _ , true -> DiscordButtonComponent(btnColor, $"{actionId}-{item.Id}-{buttonInfo}-{player.Name}", $"{item.Name}") | Some event , false -> let time = Messaging.getShortTimeText (TimeSpan.FromMinutes(int event.Cooldown)) event.Timestamp DiscordButtonComponent(btnColor, $"{actionId}-{item.Id}", $"{item.Name} ({time} left)", true)) |> Seq.cast let pickDefense actionId player isTrainer = let shieldItems = player.Inventory |> Inventory.getItemsByType ItemType.Shield |> List.sortBy (fun item -> item.Id) let buttons = constructButtons actionId (string player.DiscordId) player shieldItems isTrainer let embed = DiscordEmbedBuilder() .WithTitle("Shield Defense") .WithDescription("Pick a shield to protect yourself from hacks") for shield in Inventory.getShields player.Inventory do let hours = TimeSpan.FromMinutes(int shield.Cooldown).TotalHours |> int let against = WeaponClass.getGoodAgainst shield.Class |> snd embed.AddField(shield.Name, $"Active {hours} hours\nDefeats {against}", true) |> ignore DiscordFollowupMessageBuilder() .AddComponents(buttons) .AddEmbeds([ DiscordEmbedBuilder().WithImageUrl(shieldGif).Build() ; embed.Build() ]) .AsEphemeral(true) let pickHack actionId attacker defender isTrainer = let hackItems = attacker.Inventory |> Inventory.getItemsByType ItemType.Hack |> List.sortBy (fun item -> item.Id) let buttons = constructButtons actionId $"{defender.DiscordId}-{defender.Name}" attacker hackItems isTrainer let stealMsg = if not isTrainer then $"{defender.Name} has **{defender.Bank} $GBT** we can take from them. " else "" let embed = DiscordEmbedBuilder() .WithTitle("Hack Attack") .WithDescription($"{stealMsg}Pick the hack you want to use.") if not isTrainer then for hack in Inventory.getHacks attacker.Inventory do let amount = if hack.Power > int defender.Bank then int defender.Bank else hack.Power embed.AddField(hack.Name, $"Cooldown {hack.Cooldown} mins\nExtract {amount} $GBT", true) |> ignore DiscordFollowupMessageBuilder() .AddComponents(buttons) .AddEmbeds([ DiscordEmbedBuilder().WithImageUrl(hackGif).Build() ; embed.Build() ]) .AsEphemeral true let responseSuccessfulHack earnedMoney (targetId : uint64) amountTaken (hack : HackItem) = let embed = DiscordEmbedBuilder() .WithImageUrl(hack.ImageUrl) .WithTitle("Hack Attack") .WithDescription($"You successfully hacked <@{targetId}> using {hack.Name}" + (if earnedMoney then $", and took {amountTaken} 💰$GBT from them!" else "!")) DiscordFollowupMessageBuilder() .AddEmbed(embed.Build()) .AsEphemeral(true) let responseCreatedShield (shield : ShieldItem) = let embed = DiscordEmbedBuilder().WithImageUrl(shield.ImageUrl) embed.Title <- "Mounted Shield" embed.Description <- $"Mounted {shield.Name} shield for {TimeSpan.FromMinutes(int shield.Cooldown).TotalHours} hours" DiscordFollowupMessageBuilder() .AddEmbed(embed) .AsEphemeral(true) let eventSuccessfulHack (ctx : IDiscordContext) target prize = DiscordMessageBuilder() .WithContent($"{ctx.GetDiscordMember().Username} successfully hacked <@{target.DiscordId}> and took {prize} GoodBoyTokenz") let getArsenalEmbed (player : PlayerData) = DiscordFollowupMessageBuilder() .AsEphemeral(true) .AddEmbed( DiscordEmbedBuilder() .AddField( "Arsenal", Arsenal.statusFormat player )) let getAchievementEmbed rewards description achievement = let embed = DiscordEmbedBuilder() GuildEnvironment.botClientHacker |> Option.iter (fun bot -> embed.Author <- DiscordEmbedBuilder.EmbedAuthor() embed.Author.Name <- bot.CurrentUser.Username embed.Author.IconUrl <- bot.CurrentUser.AvatarUrl) DiscordFollowupMessageBuilder() .AddEmbed( embed.WithTitle("Achievement Unlocked!") .WithDescription(description) .WithColor(DiscordColor.Gold) // .AddField("Achievement", $"🏆 {achievement}") .AddField("Achievement", $"{achievement}", true) .AddField("Gifts", rewards |> String.concat "\n", true) // TODO: Once we add another achievement, fix this .WithImageUrl("https://s10.gifyu.com/images/MasterTraining_Degenz.gif")) .AsEphemeral(true)