Return last 10 invites, make everything prettier
This commit is contained in:
		
							parent
							
								
									0d39032095
								
							
						
					
					
						commit
						9046aee6b6
					
				@ -85,7 +85,6 @@ if guild <> 922419263275425832uL then
 | 
				
			|||||||
//    Trainer.sendInitialEmbed hackerBattleBot
 | 
					//    Trainer.sendInitialEmbed hackerBattleBot
 | 
				
			||||||
    InviteTracker.sendInitialEmbed inviterBot
 | 
					    InviteTracker.sendInitialEmbed inviterBot
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
 | 
					hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
 | 
				
			||||||
GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser
 | 
					GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -95,8 +94,6 @@ GuildEnvironment.botUserArmory <- Some storeBot.CurrentUser
 | 
				
			|||||||
inviterBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
 | 
					inviterBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
 | 
				
			||||||
//stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
 | 
					//stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
let rec loop areBotsRunning =
 | 
					let rec loop areBotsRunning =
 | 
				
			||||||
    async {
 | 
					    async {
 | 
				
			||||||
        if not (File.Exists "fsharp-bots") then
 | 
					        if not (File.Exists "fsharp-bots") then
 | 
				
			||||||
 | 
				
			|||||||
@ -161,23 +161,22 @@ let private getInvitedUsers userId =
 | 
				
			|||||||
    |> Sql.query """
 | 
					    |> Sql.query """
 | 
				
			||||||
            WITH invite AS (SELECT id FROM invite WHERE inviter = @did)
 | 
					            WITH invite AS (SELECT id FROM invite WHERE inviter = @did)
 | 
				
			||||||
            SELECT discord_id FROM invited_user, invite
 | 
					            SELECT discord_id FROM invited_user, invite
 | 
				
			||||||
            WHERE invite.id = invited_user.invite_id AND invited_user.accepted = true;
 | 
					            WHERE invite.id = invited_user.invite_id AND invited_user.accepted = true
 | 
				
			||||||
 | 
					            ORDER BY created_at DESC LIMIT 10
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
    |> Sql.executeAsync (fun read -> read.string "discord_id" |> uint64)
 | 
					    |> Sql.executeAsync (fun read -> read.string "discord_id" |> uint64)
 | 
				
			||||||
    |> Async.AwaitTask
 | 
					    |> Async.AwaitTask
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let guildInviteEmbed showWhitelistReward =
 | 
					let guildInviteEmbed =
 | 
				
			||||||
    let rewardMsg =
 | 
					    let rewardMsg =
 | 
				
			||||||
        if showWhitelistReward then
 | 
					        $"**⏀ | Your Mission:**\nShare your UNIQUE LINK with any Degenz you want to `/recruit`.\n\n" +
 | 
				
			||||||
            $"**⏀ | Your Mission:**\nUse the link to **recruit** Degenz into Beautopia©.\n\n" +
 | 
					        $"**⌼ | Your Reward:**\n`Earn {InviteRewardAmount} $GBT` 💰 for every Degen you `/recruit`.\n\n" +
 | 
				
			||||||
            $"**⌼ | Your Reward:**\nGet awarded **Whitelist**."
 | 
					        $"To check how many Degenz you have recruited into the army just type `/recruited`"
 | 
				
			||||||
        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 =
 | 
					    let embed =
 | 
				
			||||||
        DiscordEmbedBuilder()
 | 
					        DiscordEmbedBuilder()
 | 
				
			||||||
 | 
					            .WithColor(DiscordColor.Green)
 | 
				
			||||||
            .WithDescription(rewardMsg)
 | 
					            .WithDescription(rewardMsg)
 | 
				
			||||||
            .WithImageUrl("https://pbs.twimg.com/profile_banners/1449270642340089856/1640071520/1500x500")
 | 
					            .WithImageUrl("https://s1.gifyu.com/images/whitelist-image-banner-3.gif")
 | 
				
			||||||
            .WithTitle("Recruitment")
 | 
					            .WithTitle("Recruitment")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let builder =
 | 
					    let builder =
 | 
				
			||||||
@ -185,10 +184,10 @@ let guildInviteEmbed showWhitelistReward =
 | 
				
			|||||||
            .AddEmbed(embed)
 | 
					            .AddEmbed(embed)
 | 
				
			||||||
            .AsEphemeral(true)
 | 
					            .AsEphemeral(true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let button = DiscordButtonComponent(ButtonStyle.Success, $"CreateGuildInvite", $"Give it to me") :> DiscordComponent
 | 
					    let button = DiscordButtonComponent(ButtonStyle.Success, $"CreateGuildInvite", $"Give Me the Link") :> DiscordComponent
 | 
				
			||||||
    builder.AddComponents [| button |]
 | 
					    builder.AddComponents [| button |]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let private showInviteMessage (ctx : IDiscordContext) showWhitelistReward =
 | 
					let private showInviteMessage (ctx : IDiscordContext) =
 | 
				
			||||||
    task {
 | 
					    task {
 | 
				
			||||||
        let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
 | 
					        let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
 | 
				
			||||||
        do! ctx.Respond(InteractionResponseType.DeferredChannelMessageWithSource, builder)
 | 
					        do! ctx.Respond(InteractionResponseType.DeferredChannelMessageWithSource, builder)
 | 
				
			||||||
@ -197,7 +196,7 @@ let private showInviteMessage (ctx : IDiscordContext) showWhitelistReward =
 | 
				
			|||||||
        | Some player ->
 | 
					        | Some player ->
 | 
				
			||||||
            let ( result , hackerRole ) = ctx.GetGuild().Roles.TryGetValue(GuildEnvironment.roleHacker)
 | 
					            let ( result , hackerRole ) = ctx.GetGuild().Roles.TryGetValue(GuildEnvironment.roleHacker)
 | 
				
			||||||
            match player.Active , result && Seq.contains hackerRole (ctx.GetDiscordMember().Roles) with
 | 
					            match player.Active , result && Seq.contains hackerRole (ctx.GetDiscordMember().Roles) with
 | 
				
			||||||
            | true , true -> do! ctx.FollowUp(guildInviteEmbed showWhitelistReward)
 | 
					            | true , true -> do! ctx.FollowUp(guildInviteEmbed)
 | 
				
			||||||
            | 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'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**!"
 | 
					            | _ , false   -> do! sendFollowUpMessage ctx $"You still haven't completed training! Go to <#{GuildEnvironment.channelTraining}> NOW to become a **HACKER**!"
 | 
				
			||||||
        | None ->
 | 
					        | None ->
 | 
				
			||||||
@ -226,7 +225,7 @@ let private getAttributions (ctx : IDiscordContext) userId = task {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let private getInvitedUsersForId (ctx : IDiscordContext) = task {
 | 
					let private getInvitedUsersForId (ctx : IDiscordContext) = task {
 | 
				
			||||||
    let! users = getInvitedUsers(ctx.GetDiscordMember().Id)
 | 
					    let! users = getInvitedUsers (ctx.GetDiscordMember().Id)
 | 
				
			||||||
    let sb = StringBuilder()
 | 
					    let sb = StringBuilder()
 | 
				
			||||||
    let mutable count = 0
 | 
					    let mutable count = 0
 | 
				
			||||||
    for user in users do
 | 
					    for user in users do
 | 
				
			||||||
@ -313,12 +312,12 @@ let sendInitialEmbed (client : DiscordClient)  =
 | 
				
			|||||||
            embed.ImageUrl <- "https://s1.gifyu.com/images/whitelist-image-2.gif"
 | 
					            embed.ImageUrl <- "https://s1.gifyu.com/images/whitelist-image-2.gif"
 | 
				
			||||||
            embed.Title <- "Degenz Game"
 | 
					            embed.Title <- "Degenz Game"
 | 
				
			||||||
            embed.Description <- """
 | 
					            embed.Description <- """
 | 
				
			||||||
                Mint Date: **April 2022**
 | 
					Mint Date: **April 2022**
 | 
				
			||||||
                Supply: **3,333**
 | 
					Supply: **3,333**
 | 
				
			||||||
                Price: **1.984 $SOL**
 | 
					Price: **1.984 $SOL**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                Your NFT will be your In-Game Character that provides you with unique traits, and abilities in game.
 | 
					Your NFT will be your In-Game Character that provides you with unique traits, and abilities in game.
 | 
				
			||||||
            """
 | 
					"""
 | 
				
			||||||
            builder.AddEmbed embed |> ignore
 | 
					            builder.AddEmbed embed |> ignore
 | 
				
			||||||
            let button = DiscordButtonComponent(ButtonStyle.Success, $"GimmeWhitelist", $"Give Me Whitelist") :> DiscordComponent
 | 
					            let button = DiscordButtonComponent(ButtonStyle.Success, $"GimmeWhitelist", $"Give Me Whitelist") :> DiscordComponent
 | 
				
			||||||
            builder.AddComponents [| button |] |> ignore
 | 
					            builder.AddComponents [| button |] |> ignore
 | 
				
			||||||
@ -358,6 +357,14 @@ let handleGimmeWhitelist (ctx : IDiscordContext) =
 | 
				
			|||||||
        let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
 | 
					        let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
 | 
				
			||||||
        do! ctx.Respond(InteractionResponseType.DeferredChannelMessageWithSource, builder)
 | 
					        do! ctx.Respond(InteractionResponseType.DeferredChannelMessageWithSource, builder)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let whitelistEmbed = DiscordEmbedBuilder()
 | 
				
			||||||
 | 
					        let thumb = DiscordEmbedBuilder.EmbedThumbnail()
 | 
				
			||||||
 | 
					        thumb.Url <- "https://s7.gifyu.com/images/Card-5x-rotate.png"
 | 
				
			||||||
 | 
					        whitelistEmbed.Thumbnail <- thumb
 | 
				
			||||||
 | 
					        whitelistEmbed.Title <- "1x Degenz Game Whitelist"
 | 
				
			||||||
 | 
					        whitelistEmbed.AddField("Mint April 2022         | ", "Join us on the moon", true) |> ignore
 | 
				
			||||||
 | 
					        whitelistEmbed.AddField("Price 💰", $"{WhitelistPrice} $GBT", true) |> ignore
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let builder = DiscordFollowupMessageBuilder().AsEphemeral(true)
 | 
					        let builder = DiscordFollowupMessageBuilder().AsEphemeral(true)
 | 
				
			||||||
        match! tryGrantWhitelist ctx with
 | 
					        match! tryGrantWhitelist ctx with
 | 
				
			||||||
        | NotInGame ->
 | 
					        | NotInGame ->
 | 
				
			||||||
@ -375,31 +382,38 @@ 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
 | 
					            whitelistEmbed.Color <- DiscordColor.Red
 | 
				
			||||||
            builder.Content <- $"""
 | 
					            let buyBtn = DiscordButtonComponent(ButtonStyle.Success, $"BuyWhitelist", $"Buy Now", true) :> DiscordComponent
 | 
				
			||||||
 | 
					            let recruitBtn = DiscordButtonComponent(ButtonStyle.Danger, $"ShowRecruitmentEmbed", $"Recruit Now") :> DiscordComponent
 | 
				
			||||||
 | 
					            let msgEmbed = DiscordEmbedBuilder()
 | 
				
			||||||
 | 
					            msgEmbed.Color <- DiscordColor.Red
 | 
				
			||||||
 | 
					            msgEmbed.Description <- $"""
 | 
				
			||||||
 | 
					Oh no!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
You don't have enough **$GBT** to buy a WHITELIST spot!
 | 
					You don't have enough **$GBT** to buy a WHITELIST spot!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WHITELIST ain’t cheap, and looks like you're `{WhitelistPrice - total} $GBT` short.
 | 
					Come back when you have `{WhitelistPrice - total}` more $GBT.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Go earn more $GBT, and come back when you have `{WhitelistPrice} $GBT`!
 | 
					The quickest way to earn $GBT is to `/recruit`. You will earn `{InviteRewardAmount} 💰 $GBT` for every Degen you `/recruit`!
 | 
				
			||||||
 | 
					 | 
				
			||||||
`/recruit` other Degenz and get `{InviteRewardAmount} 💰 $GBT` for every Degen you recruit!
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
`/hack` other Degenz in <#{GuildEnvironment.channelBattle}> to steal their **$GBT**
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
`/toss` against <@{GuildEnvironment.botIdTosserTed}> in <#{GuildEnvironment.channelTosserTed}> to try double up!
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Good luck Degen ✊
 | 
					 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					            builder.AddComponents([ buyBtn ; recruitBtn ]) |> ignore
 | 
				
			||||||
 | 
					            builder.AddEmbed(msgEmbed) |> ignore
 | 
				
			||||||
 | 
					            builder.AddEmbed(whitelistEmbed) |> ignore
 | 
				
			||||||
        | Granted _ ->
 | 
					        | Granted _ ->
 | 
				
			||||||
 | 
					            whitelistEmbed.Color <- DiscordColor.Green
 | 
				
			||||||
            builder.AddComponents([ DiscordButtonComponent(ButtonStyle.Success, $"BuyWhitelist", $"Buy Now") :> DiscordComponent ]) |> ignore
 | 
					            builder.AddComponents([ DiscordButtonComponent(ButtonStyle.Success, $"BuyWhitelist", $"Buy Now") :> DiscordComponent ]) |> ignore
 | 
				
			||||||
            builder.Content <- """
 | 
					            let msgEmbed = DiscordEmbedBuilder()
 | 
				
			||||||
 | 
					            msgEmbed.Title <- "Buy Whitelist"
 | 
				
			||||||
 | 
					            msgEmbed.Color <- DiscordColor.Green
 | 
				
			||||||
 | 
					            msgEmbed.Description <- $"""
 | 
				
			||||||
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!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Now you can use your $GBT to pay for one of our coveted Whitelist spots.
 | 
					Now you can use your $GBT to pay for one of our coveted Whitelist spots.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Click buy now below and the role will be auto assigned to you.
 | 
					Click buy now below and the role will be auto assigned to you.
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
 | 
					            builder.AddEmbed(msgEmbed) |> ignore
 | 
				
			||||||
 | 
					            builder.AddEmbed(whitelistEmbed) |> ignore
 | 
				
			||||||
        do! ctx.FollowUp(builder)
 | 
					        do! ctx.FollowUp(builder)
 | 
				
			||||||
    } :> Task
 | 
					    } :> Task
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -469,6 +483,7 @@ let handleButtonEvent  (_ : DiscordClient) (event : ComponentInteractionCreateEv
 | 
				
			|||||||
    | id when id.StartsWith("GimmeWhitelist")  -> handleGimmeWhitelist eventCtx
 | 
					    | id when id.StartsWith("GimmeWhitelist")  -> handleGimmeWhitelist eventCtx
 | 
				
			||||||
    | id when id.StartsWith("BuyWhitelist")  -> handleBuyWhitelist eventCtx
 | 
					    | id when id.StartsWith("BuyWhitelist")  -> handleBuyWhitelist eventCtx
 | 
				
			||||||
    | id when id.StartsWith("CreateGuildInvite")  -> handleCreateInvite eventCtx
 | 
					    | id when id.StartsWith("CreateGuildInvite")  -> handleCreateInvite eventCtx
 | 
				
			||||||
 | 
					    | id when id.StartsWith("ShowRecruitmentEmbed")  -> showInviteMessage eventCtx
 | 
				
			||||||
    | _ ->
 | 
					    | _ ->
 | 
				
			||||||
        task {
 | 
					        task {
 | 
				
			||||||
            let builder = DiscordInteractionResponseBuilder()
 | 
					            let builder = DiscordInteractionResponseBuilder()
 | 
				
			||||||
@ -489,7 +504,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) =
 | 
				
			||||||
        showInviteMessage (DiscordInteractionContext ctx) false
 | 
					        showInviteMessage (DiscordInteractionContext ctx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [<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