Remove hacker requirement to recruit and accept invite when verified (for now)
This commit is contained in:
parent
2ea9b65c46
commit
a4b0834047
@ -74,6 +74,7 @@ storeBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleStoreEven
|
||||
//stealBot.add_ComponentInteractionCreated(AsyncEventHandler(Thief.handleStealButton))
|
||||
inviterBot.add_GuildMemberAdded(AsyncEventHandler(InviteTracker.handleGuildMemberAdded))
|
||||
inviterBot.add_ComponentInteractionCreated(AsyncEventHandler(InviteTracker.handleButtonEvent))
|
||||
inviterBot.add_GuildMemberUpdated(AsyncEventHandler(InviteTracker.handleRoleAssigned))
|
||||
slotsBot.add_ComponentInteractionCreated(AsyncEventHandler(SlotMachine.handleButton))
|
||||
slotsBot.add_GuildDownloadCompleted(AsyncEventHandler(SlotMachine.handleGuildDownloadCompleted))
|
||||
slotsBot.add_MessageCreated(AsyncEventHandler(SlotMachine.handleMessageCreated))
|
||||
|
@ -379,12 +379,12 @@ type Store() =
|
||||
// member this.BuyShield (ctx : InteractionContext) =
|
||||
// enforceChannel (DiscordInteractionContext(ctx)) buy
|
||||
|
||||
[<SlashCommand("sell-hack", "Sell a hack for GoodBoyTokenz")>]
|
||||
member this.SellHack (ctx : InteractionContext) = enforceChannel (DiscordInteractionContext(ctx)) (sell "Hacks" (Inventory.getItemsByType ItemType.Hack))
|
||||
|
||||
[<SlashCommand("sell-shield", "Sell a shield for GoodBoyTokenz")>]
|
||||
member this.SellShield (ctx : InteractionContext) = enforceChannel (DiscordInteractionContext(ctx)) (sell "Shields" (Inventory.getItemsByType ItemType.Shield))
|
||||
|
||||
// [<SlashCommand("sell-hack", "Sell a hack for GoodBoyTokenz")>]
|
||||
// member this.SellHack (ctx : InteractionContext) = enforceChannel (DiscordInteractionContext(ctx)) (sell "Hacks" (Inventory.getItemsByType ItemType.Hack))
|
||||
//
|
||||
// [<SlashCommand("sell-shield", "Sell a shield for GoodBoyTokenz")>]
|
||||
// member this.SellShield (ctx : InteractionContext) = enforceChannel (DiscordInteractionContext(ctx)) (sell "Shields" (Inventory.getItemsByType ItemType.Shield))
|
||||
//
|
||||
// [<SlashCommand("consume", "Consume a food item")>]
|
||||
// member this.Consume (ctx : InteractionContext) = consume (DiscordInteractionContext ctx)
|
||||
//
|
||||
|
@ -238,7 +238,7 @@ let handleArsenal (ctx : IDiscordContext) = PlayerInteractions.executePlayerActi
|
||||
let role = ctx.GetGuild().GetRole(GuildEnvironment.roleHacker)
|
||||
do! ctx.GetDiscordMember().GrantRoleAsync(role) |> Async.AwaitTask
|
||||
|
||||
do! InviteTracker.acceptInvite ctx player |> Async.AwaitTask
|
||||
// do! InviteTracker.acceptInvite ctx player |> Async.AwaitTask
|
||||
|
||||
do! Async.Sleep 1000
|
||||
|
||||
|
@ -205,16 +205,9 @@ let private showInviteMessage (ctx : IDiscordContext) origin =
|
||||
|
||||
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)
|
||||
| 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 $"""
|
||||
⚠️ Only Degen Hackers can `/recuit` others to the Degenz Army.
|
||||
You must **COMPLETE YOUR TRAINING FIRST!** Then you can `/recruit`...
|
||||
Go to <#{GuildEnvironment.channelTraining}> now to become a **HACKER**!
|
||||
"""
|
||||
match player.Active with
|
||||
| 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!**"
|
||||
do! Analytics.recruitCommand origin player.DiscordId (ctx.GetDiscordMember().Username) (ctx.GetChannel())
|
||||
| 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!**"
|
||||
@ -291,13 +284,13 @@ let private processNewUser (eventArgs : GuildMemberAddEventArgs) =
|
||||
| None -> ()
|
||||
} :> Task
|
||||
|
||||
let acceptInvite (ctx : IDiscordContext) (invitedPlayer : PlayerData) =
|
||||
let acceptInvite (guild : DiscordGuild) discordId memberName =
|
||||
task {
|
||||
match! checkInviteAccepted invitedPlayer.DiscordId with
|
||||
match! checkInviteAccepted discordId with
|
||||
| false ->
|
||||
let! _ = markInvitedAccepted invitedPlayer.DiscordId |> Async.Ignore
|
||||
let! _ = markInvitedAccepted discordId |> Async.Ignore
|
||||
try
|
||||
let! invite = getInviteFromInvitedUser invitedPlayer.DiscordId
|
||||
let! invite = getInviteFromInvitedUser discordId
|
||||
let! player = DbService.tryFindPlayer invite.Inviter
|
||||
match player with
|
||||
| Some player ->
|
||||
@ -305,14 +298,14 @@ let acceptInvite (ctx : IDiscordContext) (invitedPlayer : PlayerData) =
|
||||
do! match GuildEnvironment.botClientRecruit with
|
||||
| Some recruitBot -> async {
|
||||
let builder = DiscordMessageBuilder()
|
||||
builder.WithContent($"{invitedPlayer.Name} was recruited and is now a Degen. <@{player.DiscordId}> just earned {InviteRewardAmount} 💰$GBT for their efforts!") |> ignore
|
||||
let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelEventsHackerBattle)
|
||||
builder.WithContent($"{memberName} was recruited and is now a Degen. <@{player.DiscordId}> just earned {InviteRewardAmount} 💰$GBT for their efforts!") |> 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 invitedPlayer.DiscordId player.Name invitedPlayer.Name
|
||||
do! Analytics.invitedUserAccepted invite.Code player.DiscordId discordId player.Name memberName
|
||||
| None -> return ()
|
||||
with _ -> ()
|
||||
| true -> return ()
|
||||
@ -359,15 +352,13 @@ let tryGrantWhitelist (ctx : IDiscordContext) stock price =
|
||||
match! DbService.tryFindPlayer user.Id with
|
||||
| Some player ->
|
||||
let hasWhitelist = Seq.contains (ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)) user.Roles
|
||||
let isHacker = Seq.contains (ctx.GetGuild().GetRole(GuildEnvironment.roleHacker)) user.Roles
|
||||
|
||||
match hasWhitelist , player.Active , isHacker , stock > 0 , player.Bank >= price with
|
||||
| true , _ , _ , _ , _ -> return AlreadyWhitelisted
|
||||
| _ , false , _ , _ , _ -> return NotInGame
|
||||
| _ , _ , false , _ , _ -> return NotAHacker
|
||||
| _ , _ , _ , false , _ -> return NotEnoughStock
|
||||
| _ , _ , _ , _ , false -> return NotEnoughGBT player.Bank
|
||||
| _ , _ , _ , _ , _ -> return Granted player
|
||||
match hasWhitelist , player.Active , stock > 0 , player.Bank >= price with
|
||||
| true , _ , _ , _ -> return AlreadyWhitelisted
|
||||
| _ , false , _ , _ -> return NotInGame
|
||||
| _ , _ , false , _ -> return NotEnoughStock
|
||||
| _ , _ , _ , false -> return NotEnoughGBT player.Bank
|
||||
| _ , _ , _ , _ -> return Granted player
|
||||
| None -> return NotInGame
|
||||
}
|
||||
|
||||
@ -567,8 +558,21 @@ let handleCreateInvite (ctx : IDiscordContext) =
|
||||
do! ctx.FollowUp(msg)
|
||||
do! Analytics.recruitLinkButton code user.Id user.Username (ctx.GetChannel())
|
||||
} :> Task
|
||||
|
||||
let handleButtonEvent (_ : DiscordClient) (event : ComponentInteractionCreateEventArgs) =
|
||||
|
||||
let handleRoleAssigned (client : DiscordClient) (event : GuildMemberUpdateEventArgs) =
|
||||
let addedRole (rolesBefore : DiscordRole seq) (rolesAfter : DiscordRole seq) =
|
||||
rolesAfter |> Seq.filter ((fun role -> rolesBefore |> Seq.exists (fun r -> role.Id = r.Id)) >> not)
|
||||
task {
|
||||
let symmetricDifference = addedRole event.RolesBefore event.RolesAfter |> Seq.toList
|
||||
match symmetricDifference with
|
||||
| [] -> ()
|
||||
| role::_ ->
|
||||
let (_,guild) = client.Guilds.TryGetValue(GuildEnvironment.guildId)
|
||||
do! acceptInvite guild event.Member.Id event.Member.Username |> Async.AwaitTask
|
||||
return ()
|
||||
} :> Task
|
||||
|
||||
let handleButtonEvent (_ : DiscordClient) (event : ComponentInteractionCreateEventArgs) =
|
||||
let eventCtx = DiscordEventContext event :> IDiscordContext
|
||||
match event.Id with
|
||||
| id when id.StartsWith("GimmeWhitelist") -> handleGimmeWhitelist eventCtx
|
||||
|
Loading…
x
Reference in New Issue
Block a user