Several improvements to invite and whitelist
This commit is contained in:
		
							parent
							
								
									a8ab4a6abd
								
							
						
					
					
						commit
						58ac186a0a
					
				@ -166,31 +166,42 @@ let private getInvitedUsers userId =
 | 
				
			|||||||
    |> Sql.executeAsync (fun read -> read.string "discord_id" |> uint64)
 | 
					    |> Sql.executeAsync (fun read -> read.string "discord_id" |> uint64)
 | 
				
			||||||
    |> Async.AwaitTask
 | 
					    |> Async.AwaitTask
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let private createGuildInvite (ctx : IDiscordContext) showWhitelistReward =
 | 
					let guildInviteEmbed showWhitelistReward =
 | 
				
			||||||
 | 
					    let rewardMsg =
 | 
				
			||||||
 | 
					        if showWhitelistReward then
 | 
				
			||||||
 | 
					            $"**⏀ | Your Mission:**\nUse the link to **recruit** Degenz into Beautopia©.\n\n" +
 | 
				
			||||||
 | 
					            $"**⌼ | Your Reward:**\nGet awarded **Whitelist**."
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            $"**⏀ | Your Mission:**\nUse the link to share it with Degenz you want to `/recruit`.\n\n" +
 | 
				
			||||||
 | 
					            $"**⌼ | Your Reward:**\n`Earn {InviteRewardAmount} $GBT` 💰 for every Degen you've `/recruited`."
 | 
				
			||||||
 | 
					    let embed =
 | 
				
			||||||
 | 
					        DiscordEmbedBuilder()
 | 
				
			||||||
 | 
					            .WithDescription(rewardMsg)
 | 
				
			||||||
 | 
					            .WithImageUrl("https://pbs.twimg.com/profile_banners/1449270642340089856/1640071520/1500x500")
 | 
				
			||||||
 | 
					            .WithTitle("Recruitment")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let builder =
 | 
				
			||||||
 | 
					        DiscordFollowupMessageBuilder()
 | 
				
			||||||
 | 
					            .AddEmbed(embed)
 | 
				
			||||||
 | 
					            .AsEphemeral(true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let button = DiscordButtonComponent(ButtonStyle.Success, $"CreateGuildInvite", $"Give it to me") :> DiscordComponent
 | 
				
			||||||
 | 
					    builder.AddComponents [| button |]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let private showInviteMessage (ctx : IDiscordContext) showWhitelistReward =
 | 
				
			||||||
    task {
 | 
					    task {
 | 
				
			||||||
        let invitesRequired = 5
 | 
					        let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
 | 
				
			||||||
        let rewardMsg =
 | 
					        do! ctx.Respond(InteractionResponseType.DeferredChannelMessageWithSource, builder)
 | 
				
			||||||
            if showWhitelistReward then
 | 
					 | 
				
			||||||
                $"**⏀ | Your Mission:**\nUse the link to **recruit** {invitesRequired} Degenz into Beautopia©.\n\n" +
 | 
					 | 
				
			||||||
                $"**⌼ | Your Reward:**\nGet awarded **Whitelist**."
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
                $"**⏀ | Your Mission:**\nUse the link to share it with Degenz you want to `/recruit`.\n\n" +
 | 
					 | 
				
			||||||
                $"**⌼ | Your Reward:**\n`Earn {InviteRewardAmount} $GBT` 💰 for every Degen you've `/recruited`."
 | 
					 | 
				
			||||||
        let embed =
 | 
					 | 
				
			||||||
            DiscordEmbedBuilder()
 | 
					 | 
				
			||||||
                .WithDescription(rewardMsg)
 | 
					 | 
				
			||||||
                .WithImageUrl("https://pbs.twimg.com/profile_banners/1449270642340089856/1640071520/1500x500")
 | 
					 | 
				
			||||||
                .WithTitle("Recruitment")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        let builder =
 | 
					 | 
				
			||||||
            DiscordInteractionResponseBuilder()
 | 
					 | 
				
			||||||
                .AddEmbed(embed)
 | 
					 | 
				
			||||||
                .AsEphemeral(true)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        let button = DiscordButtonComponent(ButtonStyle.Success, $"CreateGuildInvite", $"Give it to me") :> DiscordComponent
 | 
					 | 
				
			||||||
        builder.AddComponents [| button |] |> ignore
 | 
					 | 
				
			||||||
        do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, builder)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        match! DbService.tryFindPlayer (ctx.GetDiscordMember().Id) with
 | 
				
			||||||
 | 
					        | Some player ->
 | 
				
			||||||
 | 
					            let ( result , hackerRole ) = ctx.GetGuild().Roles.TryGetValue(GuildEnvironment.roleHacker)
 | 
				
			||||||
 | 
					            match player.Active , result && Seq.contains hackerRole (ctx.GetDiscordMember().Roles) with
 | 
				
			||||||
 | 
					            | true , true -> do! ctx.FollowUp(guildInviteEmbed showWhitelistReward)
 | 
				
			||||||
 | 
					            | false , _   -> do! sendFollowUpMessage ctx $"You're not in the game! Go to <#{GuildEnvironment.channelShelters}> NOW to get assigned a private bunk, and **JOIN THE GAME!**"
 | 
				
			||||||
 | 
					            | _ , false   -> do! sendFollowUpMessage ctx $"You still haven't completed training! Go to <#{GuildEnvironment.channelTraining}> NOW to become a **HACKER**!"
 | 
				
			||||||
 | 
					        | None ->
 | 
				
			||||||
 | 
					            do! sendFollowUpMessage ctx $"You're not in the game! Go to <#{GuildEnvironment.channelShelters}> NOW to get assigned a private bunk, and **JOIN THE GAME!**"
 | 
				
			||||||
    } :> Task
 | 
					    } :> Task
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let private listServerInvites (ctx : IDiscordContext) = task {
 | 
					let private listServerInvites (ctx : IDiscordContext) = task {
 | 
				
			||||||
@ -330,14 +341,13 @@ let tryGrantWhitelist (ctx : IDiscordContext) =
 | 
				
			|||||||
        match! DbService.tryFindPlayer user.Id with
 | 
					        match! DbService.tryFindPlayer user.Id with
 | 
				
			||||||
        | Some player ->
 | 
					        | Some player ->
 | 
				
			||||||
            let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)
 | 
					            let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)
 | 
				
			||||||
            if player.Active then
 | 
					            if Seq.contains role user.Roles then
 | 
				
			||||||
                if Seq.contains role user.Roles then
 | 
					                return AlreadyWhitelisted
 | 
				
			||||||
                    return AlreadyWhitelisted
 | 
					            elif player.Active then
 | 
				
			||||||
 | 
					                if int player.Bank >= WhitelistPrice then
 | 
				
			||||||
 | 
					                    return Granted player
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                    if int player.Bank >= WhitelistPrice then
 | 
					                    return NotEnoughGBT (int player.Bank)
 | 
				
			||||||
                        return Granted player
 | 
					 | 
				
			||||||
                    else
 | 
					 | 
				
			||||||
                        return NotEnoughGBT (int player.Bank)
 | 
					 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
                return NotInGame
 | 
					                return NotInGame
 | 
				
			||||||
        | None -> return NotInGame
 | 
					        | None -> return NotInGame
 | 
				
			||||||
@ -365,6 +375,7 @@ Go to <#{GuildEnvironment.channelShelters}> NOW to get assigned a private bunk,
 | 
				
			|||||||
Come hang with all the other VIP Degenz in the <#{GuildEnvironment.channelElite}>
 | 
					Come hang with all the other VIP Degenz in the <#{GuildEnvironment.channelElite}>
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
        | NotEnoughGBT total ->
 | 
					        | NotEnoughGBT total ->
 | 
				
			||||||
 | 
					            builder.AddComponents([ DiscordButtonComponent(ButtonStyle.Success, $"BuyWhitelist", $"Buy Now", true) :> DiscordComponent ]) |> ignore
 | 
				
			||||||
            builder.Content <- $"""
 | 
					            builder.Content <- $"""
 | 
				
			||||||
You don't have enough **$GBT** to buy a WHITELIST spot!
 | 
					You don't have enough **$GBT** to buy a WHITELIST spot!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -381,8 +392,7 @@ Go earn more $GBT, and come back when you have `{WhitelistPrice} $GBT`!
 | 
				
			|||||||
Good luck Degen ✊
 | 
					Good luck Degen ✊
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
        | Granted _ ->
 | 
					        | Granted _ ->
 | 
				
			||||||
            let button = DiscordButtonComponent(ButtonStyle.Success, $"BuyWhitelist", $"Buy Now") :> DiscordComponent
 | 
					            builder.AddComponents([ DiscordButtonComponent(ButtonStyle.Success, $"BuyWhitelist", $"Buy Now") :> DiscordComponent ]) |> ignore
 | 
				
			||||||
            builder.AddComponents([ button ]) |> ignore
 | 
					 | 
				
			||||||
            builder.Content <- """
 | 
					            builder.Content <- """
 | 
				
			||||||
Look at you Degen, you played Big Brother’s games and made it out alive!
 | 
					Look at you Degen, you played Big Brother’s games and made it out alive!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -479,7 +489,7 @@ type Inviter() =
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    [<SlashCommand("recruit", "Recruit another user to this discord and earn rewards")>]
 | 
					    [<SlashCommand("recruit", "Recruit another user to this discord and earn rewards")>]
 | 
				
			||||||
    member this.CreateInvite (ctx : InteractionContext) =
 | 
					    member this.CreateInvite (ctx : InteractionContext) =
 | 
				
			||||||
        createGuildInvite (DiscordInteractionContext ctx) false
 | 
					        showInviteMessage (DiscordInteractionContext ctx) false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [<SlashCommand("recruited", "Get total invites from a specific user")>]
 | 
					    [<SlashCommand("recruited", "Get total invites from a specific user")>]
 | 
				
			||||||
    member this.ListInvitedPeople (ctx : InteractionContext) =
 | 
					    member this.ListInvitedPeople (ctx : InteractionContext) =
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user