Changes to Whitelist and Recruit
This commit is contained in:
		
							parent
							
								
									08c6373c96
								
							
						
					
					
						commit
						d779e43fd5
					
				@ -2,7 +2,6 @@ module Degenz.Store
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
open System
 | 
					open System
 | 
				
			||||||
open System.Data
 | 
					open System.Data
 | 
				
			||||||
open System.Threading.Tasks
 | 
					 | 
				
			||||||
open DSharpPlus.Entities
 | 
					open DSharpPlus.Entities
 | 
				
			||||||
open DSharpPlus
 | 
					open DSharpPlus
 | 
				
			||||||
open DSharpPlus.EventArgs
 | 
					open DSharpPlus.EventArgs
 | 
				
			||||||
@ -111,7 +110,7 @@ let getItemEmbeds owned (items : StoreItem list) =
 | 
				
			|||||||
        let arr : obj array = values |> Seq.map snd |> Seq.cast<obj> |> Seq.toArray
 | 
					        let arr : obj array = values |> Seq.map snd |> Seq.cast<obj> |> Seq.toArray
 | 
				
			||||||
        table.Rows.Add(arr) |> ignore
 | 
					        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
 | 
					//        if not (String.IsNullOrEmpty item.Item.Description) then
 | 
				
			||||||
//            embed.Url <- item.Item.Description
 | 
					//            embed.Url <- item.Item.Description
 | 
				
			||||||
//            embed.Footer <- DiscordEmbedBuilder.EmbedFooter()
 | 
					//            embed.Footer <- DiscordEmbedBuilder.EmbedFooter()
 | 
				
			||||||
@ -253,7 +252,6 @@ let handleBuyItem (ctx : IDiscordContext) itemId =
 | 
				
			|||||||
                let embed = purchaseItemEmbed 1 item
 | 
					                let embed = purchaseItemEmbed 1 item
 | 
				
			||||||
                match item.Attributes , getTotalOwnedOfItem item player.Inventory |> Option.defaultValue 0 with
 | 
					                match item.Attributes , getTotalOwnedOfItem item player.Inventory |> Option.defaultValue 0 with
 | 
				
			||||||
                | CanStack max , amount ->
 | 
					                | CanStack max , amount ->
 | 
				
			||||||
                    // TODO: Maybe find a way to show current amount owned
 | 
					 | 
				
			||||||
                    embed.AddField("Owned", $"{amount + 1}", true) |> ignore
 | 
					                    embed.AddField("Owned", $"{amount + 1}", true) |> ignore
 | 
				
			||||||
                    embed.AddField("New $GBT Balance", $"`💰` {player.Bank} ⋙ `💰` {player.Bank - price} `({price} $GBT)`", true) |> ignore
 | 
					                    embed.AddField("New $GBT Balance", $"`💰` {player.Bank} ⋙ `💰` {player.Bank - price} `({price} $GBT)`", true) |> ignore
 | 
				
			||||||
                    if amount + 1 < max then
 | 
					                    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 showStats (ctx : IDiscordContext) = PlayerInteractions.executePlayerAction ctx (fun player -> async {
 | 
				
			||||||
    let embed = DiscordEmbedBuilder()
 | 
					    let embed = DiscordEmbedBuilder()
 | 
				
			||||||
    PlayerStats.stats
 | 
					    PlayerStats.stats
 | 
				
			||||||
@ -365,7 +341,6 @@ let handleStoreEvents _ (event : ComponentInteractionCreateEventArgs) =
 | 
				
			|||||||
    match id with
 | 
					    match id with
 | 
				
			||||||
    | id when id.StartsWith("Buy") -> handleBuyItem ctx itemId
 | 
					    | id when id.StartsWith("Buy") -> handleBuyItem ctx itemId
 | 
				
			||||||
    | id when id.StartsWith("Sell") -> handleSell 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("ShowHacks") -> buy storeId (Some ItemType.Hack) ctx
 | 
				
			||||||
    | id when id.StartsWith("ShowShields") -> buy storeId (Some ItemType.Shield) ctx
 | 
					    | id when id.StartsWith("ShowShields") -> buy storeId (Some ItemType.Shield) ctx
 | 
				
			||||||
    | _ ->
 | 
					    | _ ->
 | 
				
			||||||
 | 
				
			|||||||
@ -11,6 +11,7 @@ open Npgsql.FSharp
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
let connStr = GuildEnvironment.connectionString
 | 
					let connStr = GuildEnvironment.connectionString
 | 
				
			||||||
let InviteRewardAmount = 100<GBT>
 | 
					let InviteRewardAmount = 100<GBT>
 | 
				
			||||||
 | 
					let InviteLinkButtonText = "Get My Invite Link"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Invite = {
 | 
					type Invite = {
 | 
				
			||||||
    Code : string
 | 
					    Code : string
 | 
				
			||||||
@ -216,7 +217,7 @@ let getInvitedUsersForId (user : DiscordUser) (ctx : IDiscordContext) =
 | 
				
			|||||||
                if users.Length > 0 then
 | 
					                if users.Length > 0 then
 | 
				
			||||||
                    $"**Total Recruited:** `{total} Degenz`\n**Total Earned:** `{total * InviteRewardAmount} 💰$GBT`\n\n**Last 10 users recruited:**\n{sb}"
 | 
					                    $"**Total Recruited:** `{total} Degenz`\n**Total Earned:** `{total * InviteRewardAmount} 💰$GBT`\n\n**Last 10 users recruited:**\n{sb}"
 | 
				
			||||||
                else
 | 
					                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()
 | 
					            DiscordFollowupMessageBuilder()
 | 
				
			||||||
                .AsEphemeral(true)
 | 
					                .AsEphemeral(true)
 | 
				
			||||||
                .WithContent(str)
 | 
					                .WithContent(str)
 | 
				
			||||||
@ -281,18 +282,27 @@ let sendInitialEmbed (ctx : IDiscordContext)  =
 | 
				
			|||||||
    async {
 | 
					    async {
 | 
				
			||||||
        try
 | 
					        try
 | 
				
			||||||
            let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelRecruitment)
 | 
					            let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelRecruitment)
 | 
				
			||||||
            let rewardMsg =
 | 
					            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" +
 | 
					**__Win $2,000:__**
 | 
				
			||||||
                $"**Your Reward:**\n`Earn {InviteRewardAmount} $GBT` 💰 for every Degen you invite into the server, that **COMPLETES** hacker training."
 | 
					- 🙋 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 =
 | 
					            let embed =
 | 
				
			||||||
                DiscordEmbedBuilder()
 | 
					                DiscordEmbedBuilder()
 | 
				
			||||||
                    .WithColor(DiscordColor.Green)
 | 
					                    .WithColor(DiscordColor.CornflowerBlue)
 | 
				
			||||||
                    .WithDescription(rewardMsg)
 | 
					                    .WithDescription(rewardMsg)
 | 
				
			||||||
                    .WithImageUrl("https://s1.gifyu.com/images/whitelist-image-banner-3.gif")
 | 
					                    .WithImageUrl("https://cdn.discordapp.com/attachments/922422890991849542/973939752321564753/invite_banner7.png")
 | 
				
			||||||
                    .WithTitle("Recruitment")
 | 
					                    .WithTitle("Invite Degenz")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            let builder = DiscordMessageBuilder().AddEmbed(embed)
 | 
					            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
 | 
					            let btn2 = DiscordButtonComponent(ButtonStyle.Primary, $"ShowRecruited", $"My Recruits") :> DiscordComponent
 | 
				
			||||||
            builder.AddComponents [| btn1 ; btn2 |] |> ignore
 | 
					            builder.AddComponents [| btn1 ; btn2 |] |> ignore
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -6,9 +6,6 @@ open DSharpPlus.Entities
 | 
				
			|||||||
open DSharpPlus.EventArgs
 | 
					open DSharpPlus.EventArgs
 | 
				
			||||||
open Degenz.Messaging
 | 
					open Degenz.Messaging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: We're probably going to get rid of this
 | 
					 | 
				
			||||||
let InviteRewardAmount = 100<GBT>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type WhitelistResult =
 | 
					type WhitelistResult =
 | 
				
			||||||
    | NotInGame
 | 
					    | NotInGame
 | 
				
			||||||
    | NotAHacker
 | 
					    | NotAHacker
 | 
				
			||||||
@ -27,15 +24,16 @@ let sendInitialEmbed (ctx : IDiscordContext)  =
 | 
				
			|||||||
            embed.Title <- "Degenz Game"
 | 
					            embed.Title <- "Degenz Game"
 | 
				
			||||||
            embed.Color <- DiscordColor.White
 | 
					            embed.Color <- DiscordColor.White
 | 
				
			||||||
            embed.Description <- """
 | 
					            embed.Description <- """
 | 
				
			||||||
Mint Date: **May 2022**
 | 
					Buy your Whitelist Discord Role below. OG's get to mint more NFTs on Mint day.
 | 
				
			||||||
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.
 | 
					 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					            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
 | 
					            builder.AddEmbed embed |> ignore
 | 
				
			||||||
            let button = DiscordButtonComponent(ButtonStyle.Success, $"GimmeWhitelist", $"Give Me Whitelist") :> DiscordComponent
 | 
					            let btn1 = DiscordButtonComponent(ButtonStyle.Success, $"Buy-WHITELIST-WHITELIST", $"Buy Whitelist") :> DiscordComponent
 | 
				
			||||||
            builder.AddComponents [| button |] |> ignore
 | 
					            let btn2 = DiscordButtonComponent(ButtonStyle.Success, $"Buy-WHITEOG-WHITELIST", $"Buy OG Whitelist") :> DiscordComponent
 | 
				
			||||||
 | 
					            builder.AddComponents [| btn1 ; btn2 |] |> ignore
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            do! GuildEnvironment.botClientRecruit.Value.SendMessageAsync(channel, builder)
 | 
					            do! GuildEnvironment.botClientRecruit.Value.SendMessageAsync(channel, builder)
 | 
				
			||||||
                |> Async.AwaitTask
 | 
					                |> 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) =
 | 
					let grantWhitelistRole (ctx : IDiscordContext) =
 | 
				
			||||||
    task {
 | 
					    task {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)
 | 
					        let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)
 | 
				
			||||||
        do! ctx.GetDiscordMember().GrantRoleAsync(role)
 | 
					        do! ctx.GetDiscordMember().GrantRoleAsync(role)
 | 
				
			||||||
    } :> Task
 | 
					    } :> Task
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) =
 | 
					let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) =
 | 
				
			||||||
    let eventCtx = DiscordEventContext event :> IDiscordContext
 | 
					    let ctx = DiscordEventContext event :> IDiscordContext
 | 
				
			||||||
    match event.Id with
 | 
					    match event.Id with
 | 
				
			||||||
    | id when id.StartsWith("GimmeWhitelist") -> Store.buy "WHITELIST" None eventCtx
 | 
					 | 
				
			||||||
    | id when id.StartsWith("Buy") ->
 | 
					    | id when id.StartsWith("Buy") ->
 | 
				
			||||||
        let id = eventCtx.GetInteractionId()
 | 
					        task {
 | 
				
			||||||
 | 
					            let id = ctx.GetInteractionId()
 | 
				
			||||||
            let itemId = id.Split("-").[1]
 | 
					            let itemId = id.Split("-").[1]
 | 
				
			||||||
        Store.handleBuyItem eventCtx itemId
 | 
					            do! Store.handleBuyItem ctx itemId
 | 
				
			||||||
    | id when id.StartsWith("CreateGuildInvite") -> InviteTracker.handleCreateInvite eventCtx
 | 
					            do! grantWhitelistRole ctx
 | 
				
			||||||
    | id when id.StartsWith("ShowRecruited") -> InviteTracker.getInvitedUsersForId (eventCtx.GetDiscordMember()) eventCtx
 | 
					        } :> Task
 | 
				
			||||||
 | 
					    | id when id.StartsWith("CreateGuildInvite") -> InviteTracker.handleCreateInvite ctx
 | 
				
			||||||
 | 
					    | id when id.StartsWith("ShowRecruited") -> InviteTracker.getInvitedUsersForId (ctx.GetDiscordMember()) ctx
 | 
				
			||||||
    | _ ->
 | 
					    | _ ->
 | 
				
			||||||
        task {
 | 
					        task {
 | 
				
			||||||
            let builder = DiscordInteractionResponseBuilder()
 | 
					            let builder = DiscordInteractionResponseBuilder()
 | 
				
			||||||
            builder.IsEphemeral <- true
 | 
					            builder.IsEphemeral <- true
 | 
				
			||||||
            builder.Content <- $"Incorrect Action identifier {eventCtx.GetInteractionId()}"
 | 
					            builder.Content <- $"Incorrect Action identifier {ctx.GetInteractionId()}"
 | 
				
			||||||
            do! eventCtx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask
 | 
					            do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
let setCurrentWhitelistStock amount (ctx : IDiscordContext) =
 | 
					let setCurrentWhitelistStock amount (ctx : IDiscordContext) =
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user