From fc632025356706efac5b418e51bd31ec8a6178bb Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sat, 11 Jun 2022 22:54:08 +0700 Subject: [PATCH] Grant role (comment out) depending on how many recruits --- Bot/Bot.fs | 4 ++-- Bot/Games/Store.fs | 8 ++++---- Bot/GuildEnvironment.fs | 3 +++ Bot/InviteTracker.fs | 27 +++++++++++++++++---------- Bot/Whitelist.fs | 4 ++-- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/Bot/Bot.fs b/Bot/Bot.fs index 887c5cc..9bfee26 100644 --- a/Bot/Bot.fs +++ b/Bot/Bot.fs @@ -108,11 +108,11 @@ GuildEnvironment.botClientJpeg <- Some jpegBot storeBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously GuildEnvironment.botClientStore <- Some storeBot +adminBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously + hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously GuildEnvironment.botClientHacker <- Some hackerBattleBot -adminBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously - inviterBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously GuildEnvironment.botClientRecruit <- Some inviterBot diff --git a/Bot/Games/Store.fs b/Bot/Games/Store.fs index 603e790..f5edd04 100644 --- a/Bot/Games/Store.fs +++ b/Bot/Games/Store.fs @@ -432,13 +432,13 @@ let sendBackalleyEmbed (ctx : IDiscordContext) = let embed = DiscordEmbedBuilder() embed.ImageUrl <- "https://s7.gifyu.com/images/ezgif.com-gif-maker-23203b9dca779ba7cf.gif" embed.Title <- "🎟️ Raffle Store" - embed.Color <- DiscordColor.Black + embed.Color <- DiscordColor.Lilac embed.Description <- $"Hey, what do you want, kid?\nI ain’t got all day…" builder.AddEmbed embed |> ignore - let button1 = DiscordButtonComponent(ButtonStyle.Danger, $"ShowStore-0-BACKALLEY1", $"NFT Raffles") :> DiscordComponent - let button2 = DiscordButtonComponent(ButtonStyle.Success, $"ShowStore-0-BACKALLEY2", $"Whitelist Raffles") :> DiscordComponent + let button1 = DiscordButtonComponent(ButtonStyle.Danger, $"ShowStore-0-BACKALLEY1", $"NFT Raffle") :> DiscordComponent + let button2 = DiscordButtonComponent(ButtonStyle.Success, $"ShowStore-0-BACKALLEY2", $"Whitelist Raffle") :> DiscordComponent // let button3 = DiscordButtonComponent(ButtonStyle.Success, $"ShowStore-0-BACKALLEY3", $"USDT Raffles") :> DiscordComponent - let button4 = DiscordButtonComponent(ButtonStyle.Primary, $"ShowJpegInventory-0-0", $"View My Stash") :> DiscordComponent + let button4 = DiscordButtonComponent(ButtonStyle.Primary, $"ShowJpegInventory-0-0", $"My Stash") :> DiscordComponent builder.AddComponents [| button1 ; button2 ; button4 |] |> ignore do! GuildEnvironment.botClientJpeg.Value.SendMessageAsync(channel, builder) diff --git a/Bot/GuildEnvironment.fs b/Bot/GuildEnvironment.fs index a0b440c..142d996 100644 --- a/Bot/GuildEnvironment.fs +++ b/Bot/GuildEnvironment.fs @@ -60,6 +60,9 @@ let roleWhitelist = getId "ROLE_WHITELIST" let roleWhiteOG = getId "ROLE_WHITEOG" let roleAdmin = getId "ROLE_ADMIN" let roleMagicEden = getId "ROLE_MAGICEDEN" +let roleRecruiter1x = getId "ROLE_RECRUITER_1X" +let roleRecruiter2x = getId "ROLE_RECRUITER_2X" +let roleRecruiter3x = getId "ROLE_RECRUITER_3X" let mutable botClientRecruit : DiscordClient option = None let mutable botClientHacker : DiscordClient option = None let mutable botClientSlots : DiscordClient option = None diff --git a/Bot/InviteTracker.fs b/Bot/InviteTracker.fs index a37f31f..6818687 100644 --- a/Bot/InviteTracker.fs +++ b/Bot/InviteTracker.fs @@ -286,13 +286,13 @@ let private processNewUser (eventArgs : GuildMemberAddEventArgs) = | None -> () } :> Task -let acceptInvite (guild : DiscordGuild) discordId memberName = +let acceptInvite (guild : DiscordGuild) (user : DiscordMember) = task { - match! checkInviteAccepted discordId with + match! checkInviteAccepted user.Id with | false -> - let! _ = markInvitedAccepted discordId |> Async.Ignore + let! _ = markInvitedAccepted user.Id |> Async.Ignore try - let! invite = getInviteFromInvitedUser discordId + let! invite = getInviteFromInvitedUser user.Id let! player = DbService.tryFindPlayer invite.Inviter match player with | Some player -> @@ -300,14 +300,21 @@ let acceptInvite (guild : DiscordGuild) discordId memberName = do! match GuildEnvironment.botClientRecruit with | Some recruitBot -> async { let builder = DiscordMessageBuilder() - builder.WithContent($"{memberName} was recruited and is now a Degen. **{player.Name}** just earned `{InviteRewardAmount} 💰$GBT` for their efforts! - <@!{player.DiscordId}>") |> ignore + builder.WithContent($"{user.Username} was recruited and is now a Degen. **{player.Name}** just earned `{InviteRewardAmount} 💰$GBT` for their efforts! - <@!{player.DiscordId}>") |> ignore let channel = guild.GetChannel(GuildEnvironment.channelEventsHackerBattle) do! recruitBot.SendMessageAsync(channel, builder) |> Async.AwaitTask |> Async.Ignore } | None -> async.Return() - do! Analytics.invitedUserAccepted invite.Code player.DiscordId discordId player.Name memberName + let role = + match invite.Count with + | count when count > 10 -> guild.Roles.TryGetValue(GuildEnvironment.roleRecruiter3x) + | count when count > 5 -> guild.Roles.TryGetValue(GuildEnvironment.roleRecruiter2x) + | _ -> guild.Roles.TryGetValue(GuildEnvironment.roleRecruiter1x) + |> snd + do! user.GrantRoleAsync(role) + do! Analytics.invitedUserAccepted invite.Code player.DiscordId user.Id player.Name user.Username | None -> return () with _ -> () | true -> return () @@ -327,13 +334,13 @@ let sendInitialEmbed (ctx : IDiscordContext) = 2️⃣ Share your unique link with Friends **__Bonus__** -💰 Earn an extra 300 $GBT for every invite! +💰 Earn an extra {InviteRewardAmount} $GBT for every invite! **Every invite increases your chances of winning* """ let embed = DiscordEmbedBuilder() - .WithColor(DiscordColor.CornflowerBlue) + .WithColor(DiscordColor.Gold) .WithDescription(rewardMsg) .WithImageUrl("https://s8.gifyu.com/images/invite-banner-usdcb670496dc3653cb3.png") .WithTitle("Invite Degenz") @@ -376,7 +383,7 @@ To confirm your **Whitelist** please submit it below: **Check status anytime to double check it worked*""" let embed = DiscordEmbedBuilder() - .WithColor(DiscordColor.White) + .WithColor(DiscordColor.Teal) .WithDescription(rewardMsg) .WithImageUrl("https://s8.gifyu.com/images/whitelist-submit-banner7.png") .WithTitle("Submit Your Solana Wallet Address") @@ -446,7 +453,7 @@ let handleMemberUpdated (client : DiscordClient) (event : GuildMemberUpdateEvent | role::_ -> if role.Name = "Degen" then let (_,guild) = client.Guilds.TryGetValue(GuildEnvironment.guildId) - do! acceptInvite guild event.Member.Id event.Member.Username |> Async.AwaitTask + do! acceptInvite guild event.Member |> Async.AwaitTask return () } :> Task diff --git a/Bot/Whitelist.fs b/Bot/Whitelist.fs index 02f0c07..d4f2764 100644 --- a/Bot/Whitelist.fs +++ b/Bot/Whitelist.fs @@ -22,11 +22,11 @@ let sendInitialEmbed (ctx : IDiscordContext) = let embed = DiscordEmbedBuilder() embed.ImageUrl <- "https://s8.gifyu.com/images/whitelist-banner-smaller2.gif" embed.Title <- "Degenz Game Whitelist" - embed.Color <- DiscordColor.White + embed.Color <- DiscordColor.Azure embed.Description <- $""" **__Requirements:__** You need to BUY Whitelist with 💰 $GBT -You must have INVITED at least 1 Degen… +You must also have INVITED at least 1 Degen… **__To Earn $GBT:__** 1️⃣ Invite Degenz in <#{GuildEnvironment.channelRecruitment}>