From d779e43fd5faae666abbfde3d219ffaf297e7aaf Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Wed, 11 May 2022 22:17:56 +0700 Subject: [PATCH] Changes to Whitelist and Recruit --- Bot/Games/Store.fs | 27 +-------------------------- Bot/InviteTracker.fs | 26 ++++++++++++++++++-------- Bot/Whitelist.fs | 39 +++++++++++++++++++-------------------- 3 files changed, 38 insertions(+), 54 deletions(-) diff --git a/Bot/Games/Store.fs b/Bot/Games/Store.fs index 160cc36..cbf6d62 100644 --- a/Bot/Games/Store.fs +++ b/Bot/Games/Store.fs @@ -2,7 +2,6 @@ module Degenz.Store open System open System.Data -open System.Threading.Tasks open DSharpPlus.Entities open DSharpPlus open DSharpPlus.EventArgs @@ -111,7 +110,7 @@ let getItemEmbeds owned (items : StoreItem list) = let arr : obj array = values |> Seq.map snd |> Seq.cast |> Seq.toArray table.Rows.Add(arr) |> ignore - // TODO: This isn't working, try something else + // TODO: This isn't working, try using an image // if not (String.IsNullOrEmpty item.Item.Description) then // embed.Url <- item.Item.Description // embed.Footer <- DiscordEmbedBuilder.EmbedFooter() @@ -253,7 +252,6 @@ let handleBuyItem (ctx : IDiscordContext) itemId = 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 @@ -295,28 +293,6 @@ let handleSell (ctx : IDiscordContext) itemId = }) }) -let consume (ctx : IDiscordContext) = PlayerInteractions.executePlayerAction ctx (fun player -> async { - match player.Inventory |> Inventory.getFoods with - | [] -> do! Messaging.sendFollowUpMessage ctx "You do not have any items to consume" - | items -> - // TODO: You have to provide the correct store id here - let items' = items |> List.map (fun i -> { StoreId = i.Id ; Item = i ; Stock = 1 ; LimitStock = false ; Available = true }) - let embeds = getItemEmbeds true items' - let builder = DiscordFollowupMessageBuilder().AddEmbeds(embeds).AsEphemeral(true) - do! ctx.FollowUp builder |> Async.AwaitTask -}) - -let handleConsume (ctx : IDiscordContext) itemId = PlayerInteractions.executePlayerAction ctx (fun player -> async { - let item = player.Inventory |> Inventory.findItemById itemId - match player.Inventory |> Inventory.getFoods with - | [] -> do! Messaging.sendFollowUpMessage ctx "You do not have any items to consume" - | items -> - let items' = items |> List.map (fun i -> { StoreId = i.Id ; Item = i ; Stock = 1 ; LimitStock = false ; Available = true }) - let embeds = getItemEmbeds true items' - let builder = DiscordFollowupMessageBuilder().AddEmbeds(embeds).AsEphemeral(true) - do! ctx.FollowUp builder |> Async.AwaitTask -}) - let showStats (ctx : IDiscordContext) = PlayerInteractions.executePlayerAction ctx (fun player -> async { let embed = DiscordEmbedBuilder() PlayerStats.stats @@ -365,7 +341,6 @@ let handleStoreEvents _ (event : ComponentInteractionCreateEventArgs) = match id with | 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("ShowHacks") -> buy storeId (Some ItemType.Hack) ctx | id when id.StartsWith("ShowShields") -> buy storeId (Some ItemType.Shield) ctx | _ -> diff --git a/Bot/InviteTracker.fs b/Bot/InviteTracker.fs index 122a3ad..1b47538 100644 --- a/Bot/InviteTracker.fs +++ b/Bot/InviteTracker.fs @@ -11,6 +11,7 @@ open Npgsql.FSharp let connStr = GuildEnvironment.connectionString let InviteRewardAmount = 100 +let InviteLinkButtonText = "Get My Invite Link" type Invite = { Code : string @@ -216,7 +217,7 @@ let getInvitedUsersForId (user : DiscordUser) (ctx : IDiscordContext) = if users.Length > 0 then $"**Total Recruited:** `{total} Degenz`\n**Total Earned:** `{total * InviteRewardAmount} 💰$GBT`\n\n**Last 10 users recruited:**\n{sb}" else - $"You haven't recruited anyone yet, use the `/recruit` command to get the recruitment link" + $"You haven't recruited anyone yet, click the `{InviteLinkButtonText}` button to get your invite link and start recruiting!" DiscordFollowupMessageBuilder() .AsEphemeral(true) .WithContent(str) @@ -281,18 +282,27 @@ let sendInitialEmbed (ctx : IDiscordContext) = async { try let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelRecruitment) - let rewardMsg = - $"**Your Mission:**\nCLICK THE BUTTON below, then share your **UNIQUE LINK** with any Degenz you want to invite into the Server.\n\n" + - $"**Your Reward:**\n`Earn {InviteRewardAmount} $GBT` 💰 for every Degen you invite into the server, that **COMPLETES** hacker training." + let rewardMsg = $""" +**__Win $2,000:__** +- 🙋 1 invite = 1 entry per day +- 🎟 $100 daily raffles till mint* +- 💰 Earn an additional 100 $GBT for every Degen you invite! + +**__How To Invite:__** +- CLICK THE BUTTON below +- Share your LINK with anyone you want to invite. + +**must have invited at least 1 Degen to be eligible for that days $100 raffle* +""" let embed = DiscordEmbedBuilder() - .WithColor(DiscordColor.Green) + .WithColor(DiscordColor.CornflowerBlue) .WithDescription(rewardMsg) - .WithImageUrl("https://s1.gifyu.com/images/whitelist-image-banner-3.gif") - .WithTitle("Recruitment") + .WithImageUrl("https://cdn.discordapp.com/attachments/922422890991849542/973939752321564753/invite_banner7.png") + .WithTitle("Invite Degenz") let builder = DiscordMessageBuilder().AddEmbed(embed) - let btn1 = DiscordButtonComponent(ButtonStyle.Success, $"CreateGuildInvite", $"Get My Invite Link") :> DiscordComponent + let btn1 = DiscordButtonComponent(ButtonStyle.Success, $"CreateGuildInvite", InviteLinkButtonText) :> DiscordComponent let btn2 = DiscordButtonComponent(ButtonStyle.Primary, $"ShowRecruited", $"My Recruits") :> DiscordComponent builder.AddComponents [| btn1 ; btn2 |] |> ignore diff --git a/Bot/Whitelist.fs b/Bot/Whitelist.fs index 5426c50..b09c843 100644 --- a/Bot/Whitelist.fs +++ b/Bot/Whitelist.fs @@ -6,9 +6,6 @@ open DSharpPlus.Entities open DSharpPlus.EventArgs open Degenz.Messaging -// TODO: We're probably going to get rid of this -let InviteRewardAmount = 100 - type WhitelistResult = | NotInGame | NotAHacker @@ -27,15 +24,16 @@ let sendInitialEmbed (ctx : IDiscordContext) = embed.Title <- "Degenz Game" embed.Color <- DiscordColor.White embed.Description <- """ -Mint Date: **May 2022** -Supply: **3,333** -Price: **1.984 $SOL** - -Your NFT may be your In-Game Character that provides you with unique traits, and abilities in game. +Buy your Whitelist Discord Role below. OG's get to mint more NFTs on Mint day. """ + let! wl = DbService.getStoreItemBySymbol "WHITELIST" + let! wlOG = DbService.getStoreItemBySymbol "WHITEOG" + embed.AddField("1x Whitelist", $"Price {Inventory.getBuyPrice wl.Item} $GBT") |> ignore + embed.AddField("1x OG Whitelist", $"Price {Inventory.getBuyPrice wlOG.Item} $GBT") |> ignore builder.AddEmbed embed |> ignore - let button = DiscordButtonComponent(ButtonStyle.Success, $"GimmeWhitelist", $"Give Me Whitelist") :> DiscordComponent - builder.AddComponents [| button |] |> ignore + let btn1 = DiscordButtonComponent(ButtonStyle.Success, $"Buy-WHITELIST-WHITELIST", $"Buy Whitelist") :> DiscordComponent + let btn2 = DiscordButtonComponent(ButtonStyle.Success, $"Buy-WHITEOG-WHITELIST", $"Buy OG Whitelist") :> DiscordComponent + builder.AddComponents [| btn1 ; btn2 |] |> ignore do! GuildEnvironment.botClientRecruit.Value.SendMessageAsync(channel, builder) |> Async.AwaitTask @@ -46,27 +44,28 @@ Your NFT may be your In-Game Character that provides you with unique traits, and let grantWhitelistRole (ctx : IDiscordContext) = task { - let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist) do! ctx.GetDiscordMember().GrantRoleAsync(role) } :> Task let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) = - let eventCtx = DiscordEventContext event :> IDiscordContext + let ctx = DiscordEventContext event :> IDiscordContext match event.Id with - | id when id.StartsWith("GimmeWhitelist") -> Store.buy "WHITELIST" None eventCtx | id when id.StartsWith("Buy") -> - let id = eventCtx.GetInteractionId() - let itemId = id.Split("-").[1] - Store.handleBuyItem eventCtx itemId - | id when id.StartsWith("CreateGuildInvite") -> InviteTracker.handleCreateInvite eventCtx - | id when id.StartsWith("ShowRecruited") -> InviteTracker.getInvitedUsersForId (eventCtx.GetDiscordMember()) eventCtx + task { + let id = ctx.GetInteractionId() + let itemId = id.Split("-").[1] + do! Store.handleBuyItem ctx itemId + do! grantWhitelistRole ctx + } :> Task + | id when id.StartsWith("CreateGuildInvite") -> InviteTracker.handleCreateInvite ctx + | id when id.StartsWith("ShowRecruited") -> InviteTracker.getInvitedUsersForId (ctx.GetDiscordMember()) ctx | _ -> task { let builder = DiscordInteractionResponseBuilder() builder.IsEphemeral <- true - builder.Content <- $"Incorrect Action identifier {eventCtx.GetInteractionId()}" - do! eventCtx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask + builder.Content <- $"Incorrect Action identifier {ctx.GetInteractionId()}" + do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask } let setCurrentWhitelistStock amount (ctx : IDiscordContext) =