Check if player has inventory before starting. Testing autocomplete
This commit is contained in:
parent
9924460001
commit
5f4bb71245
20
Bot/Bot.fs
20
Bot/Bot.fs
@ -40,7 +40,7 @@ let storeBot = new DiscordClient(storeConfig)
|
|||||||
//let slotMachineBot = new DiscordClient(slotMachineConfig)
|
//let slotMachineBot = new DiscordClient(slotMachineConfig)
|
||||||
|
|
||||||
//let clients = [| storeBot ; trainerBot ; hackerBattleBot ; playerInteractionsBot ; slotMachineBot |]
|
//let clients = [| storeBot ; trainerBot ; hackerBattleBot ; playerInteractionsBot ; slotMachineBot |]
|
||||||
let clients = [| storeBot ; hackerBattleBot ; playerInteractionsBot |]
|
let clients = [| hackerBattleBot ; storeBot ; playerInteractionsBot |]
|
||||||
|
|
||||||
let sc1 = playerInteractionsBot.UseSlashCommands()
|
let sc1 = playerInteractionsBot.UseSlashCommands()
|
||||||
let sc3 = hackerBattleBot.UseSlashCommands()
|
let sc3 = hackerBattleBot.UseSlashCommands()
|
||||||
@ -55,12 +55,28 @@ sc4.RegisterCommands<Store>(guild);
|
|||||||
hackerBattleBot.add_ComponentInteractionCreated(AsyncEventHandler(HackerBattle.handleButtonEvent))
|
hackerBattleBot.add_ComponentInteractionCreated(AsyncEventHandler(HackerBattle.handleButtonEvent))
|
||||||
storeBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleSellButtonEvents))
|
storeBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleSellButtonEvents))
|
||||||
|
|
||||||
|
let asdf (_ : DiscordClient) (event : DSharpPlus.EventArgs.InteractionCreateEventArgs) =
|
||||||
|
async {
|
||||||
|
printfn "%A" event.Interaction.Type
|
||||||
|
match event.Interaction.Type with
|
||||||
|
| InteractionType.AutoComplete ->
|
||||||
|
printfn "%A" event.Interaction.Data.Options
|
||||||
|
let builder = DSharpPlus.Entities.DiscordInteractionResponseBuilder()
|
||||||
|
builder.AddAutoCompleteChoice(DSharpPlus.Entities.DiscordAutoCompleteChoice("Choice 1", "What does this represent?"))
|
||||||
|
|> ignore
|
||||||
|
do! event.Interaction.CreateResponseAsync(InteractionResponseType.AutoCompleteResult, builder)
|
||||||
|
|> Async.AwaitTask
|
||||||
|
| _ -> return ()
|
||||||
|
} |> Async.StartAsTask
|
||||||
|
:> Task
|
||||||
|
//hackerBattleBot.add_InteractionCreated(AsyncEventHandler(asdf))
|
||||||
|
|
||||||
let run (client : DiscordClient) =
|
let run (client : DiscordClient) =
|
||||||
async {
|
async {
|
||||||
do! client.ConnectAsync () |> Async.AwaitTask
|
do! client.ConnectAsync () |> Async.AwaitTask
|
||||||
}
|
}
|
||||||
|
|
||||||
Trainer.sendInitialEmbed hackerBattleBot
|
//Trainer.sendInitialEmbed hackerBattleBot
|
||||||
|
|
||||||
clients
|
clients
|
||||||
|> Array.map run
|
|> Array.map run
|
||||||
|
@ -5,8 +5,7 @@ open Degenz.Shared
|
|||||||
open DSharpPlus.Entities
|
open DSharpPlus.Entities
|
||||||
open AsciiTableFormatter
|
open AsciiTableFormatter
|
||||||
|
|
||||||
let getHackGif =
|
let getHackGif = function
|
||||||
function
|
|
||||||
| Hack.Virus -> "https://s10.gifyu.com/images/Attack-DegenZ.gif"
|
| Hack.Virus -> "https://s10.gifyu.com/images/Attack-DegenZ.gif"
|
||||||
| Hack.Ransom -> "https://s10.gifyu.com/images/Mind-Control-Degenz-V2.gif"
|
| Hack.Ransom -> "https://s10.gifyu.com/images/Mind-Control-Degenz-V2.gif"
|
||||||
| Hack.Worm -> "https://s10.gifyu.com/images/WormBugAttack_Degenz.gif"
|
| Hack.Worm -> "https://s10.gifyu.com/images/WormBugAttack_Degenz.gif"
|
||||||
@ -15,8 +14,7 @@ let getHackGif =
|
|||||||
| Hack.Injection -> "https://s10.gifyu.com/images/Attack-DegenZ.gif"
|
| Hack.Injection -> "https://s10.gifyu.com/images/Attack-DegenZ.gif"
|
||||||
| _ -> "https://s10.gifyu.com/images/Hacker-Degenz-V2.gif"
|
| _ -> "https://s10.gifyu.com/images/Hacker-Degenz-V2.gif"
|
||||||
|
|
||||||
let getShieldGif =
|
let getShieldGif = function
|
||||||
function
|
|
||||||
| Shield.Firewall -> "https://s10.gifyu.com/images/Defense-GIF-1-Degenz.gif"
|
| Shield.Firewall -> "https://s10.gifyu.com/images/Defense-GIF-1-Degenz.gif"
|
||||||
| Shield.PortScan -> "https://s10.gifyu.com/images/PortScanDefense_Degenz.gif"
|
| Shield.PortScan -> "https://s10.gifyu.com/images/PortScanDefense_Degenz.gif"
|
||||||
| Shield.Encryption -> "https://s10.gifyu.com/images/Anonymous-Degenz-V2.gif"
|
| Shield.Encryption -> "https://s10.gifyu.com/images/Anonymous-Degenz-V2.gif"
|
||||||
|
@ -202,7 +202,6 @@ let handleDefense (event : ComponentInteractionCreateEventArgs) =
|
|||||||
let! playerResult = DbService.tryFindPlayer event.User.Id
|
let! playerResult = DbService.tryFindPlayer event.User.Id
|
||||||
match playerResult , shieldResult with
|
match playerResult , shieldResult with
|
||||||
| Some player , true ->
|
| Some player , true ->
|
||||||
// TODO: All of this is wrong
|
|
||||||
let updatedDefenses = removeExpiredActions (TimeSpan.FromHours(6)) (fun (pro : Defense) -> pro.Timestamp) player.Defenses
|
let updatedDefenses = removeExpiredActions (TimeSpan.FromHours(6)) (fun (pro : Defense) -> pro.Timestamp) player.Defenses
|
||||||
let alreadyUsedShield = updatedDefenses |> Array.exists (fun d -> d.DefenseType = shield)
|
let alreadyUsedShield = updatedDefenses |> Array.exists (fun d -> d.DefenseType = shield)
|
||||||
|
|
||||||
@ -289,4 +288,16 @@ type HackerGame() =
|
|||||||
else
|
else
|
||||||
defend ctx
|
defend ctx
|
||||||
|
|
||||||
|
// [<SlashCommand("test-autocomplete", "Create a passive defense that will last 24 hours")>]
|
||||||
|
member this.TestAutoComplete (ctx : InteractionContext) =
|
||||||
|
async {
|
||||||
|
let builder = DiscordInteractionResponseBuilder()
|
||||||
|
// builder.WithContent("Not working")
|
||||||
|
builder.IsEphemeral <- true
|
||||||
|
do! ctx.Interaction.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder)
|
||||||
|
|> Async.AwaitTask
|
||||||
|
} |> Async.StartAsTask
|
||||||
|
:> Task
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,15 +24,22 @@ let sendInitialEmbed (client : DiscordClient) =
|
|||||||
|
|
||||||
let handleTrainerStep1 (event : ComponentInteractionCreateEventArgs) =
|
let handleTrainerStep1 (event : ComponentInteractionCreateEventArgs) =
|
||||||
async {
|
async {
|
||||||
let! membr = event.Guild.GetMemberAsync(event.User.Id) |> Async.AwaitTask
|
let! maybePlayer = DbService.tryFindPlayer event.User.Id
|
||||||
let role = event.Guild.GetRole(GuildEnvironment.roleTrainee)
|
|
||||||
do! membr.GrantRoleAsync(role) |> Async.AwaitTask
|
|
||||||
|
|
||||||
do! event.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate)
|
do! event.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
match maybePlayer with
|
||||||
|
| Some player when not <| Array.isEmpty player.Weapons && not <| Array.isEmpty player.Shields ->
|
||||||
let msg = "First time, eh? Beautopia is a dangerous place. I'm going to teach you how to protect yourself from other degenerates. "
|
let msg = "First time, eh? Beautopia is a dangerous place. I'm going to teach you how to protect yourself from other degenerates. "
|
||||||
+ "And in the process, I'll also show you how to hack some sheeple, so you can earn some cash."
|
+ "And in the process, I'll also show you how to hack some sheeple, so you can earn some cash."
|
||||||
do! Message.sendFollowUpMessageWithButton event "Trainer-2" msg
|
do! Message.sendFollowUpMessageWithButton event "Trainer-2" msg
|
||||||
|
| Some player ->
|
||||||
|
let missingItem = match player.Weapons with [||] -> "Hacks" | _ -> "Shields"
|
||||||
|
let msg = $"Looks like you don't own any {missingItem}. Go to the store and purchase some before proceeding."
|
||||||
|
do! Message.sendFollowUpMessage event msg
|
||||||
|
| None ->
|
||||||
|
let msg = "An error occurred, please contact a moderator"
|
||||||
|
do! Message.sendFollowUpMessage event msg
|
||||||
}
|
}
|
||||||
|
|
||||||
let handleTrainerStep2 (event : ComponentInteractionCreateEventArgs) =
|
let handleTrainerStep2 (event : ComponentInteractionCreateEventArgs) =
|
||||||
@ -54,9 +61,13 @@ let defend (ctx : InteractionContext) =
|
|||||||
let! playerResult = DbService.tryFindPlayer ctx.Member.Id
|
let! playerResult = DbService.tryFindPlayer ctx.Member.Id
|
||||||
match playerResult with
|
match playerResult with
|
||||||
| Some player ->
|
| Some player ->
|
||||||
let embed = Embeds.pickDefense "Trainer-3" player
|
let playerWithShields =
|
||||||
|
match player.Shields with
|
||||||
|
| [||] -> { player with Shields = [| Shield.Firewall |] }
|
||||||
|
| _ -> player
|
||||||
|
let embed = Embeds.pickDefense "Trainer-3" playerWithShields
|
||||||
|
|
||||||
do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, embed)
|
do! ctx.Interaction.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, embed)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
| None ->
|
| None ->
|
||||||
let builder = DiscordInteractionResponseBuilder()
|
let builder = DiscordInteractionResponseBuilder()
|
||||||
@ -144,6 +155,7 @@ let handleAttack (event : ComponentInteractionCreateEventArgs) =
|
|||||||
match result with
|
match result with
|
||||||
| Some player ->
|
| Some player ->
|
||||||
let prize = 2
|
let prize = 2
|
||||||
|
do! Async.Sleep 1000
|
||||||
do! sendMessage' $"{player.Name} successfully hacked Degenz-Trainer for a total of {prize} GoodBoyTokenz"
|
do! sendMessage' $"{player.Name} successfully hacked Degenz-Trainer for a total of {prize} GoodBoyTokenz"
|
||||||
do! Async.Sleep 3000
|
do! Async.Sleep 3000
|
||||||
do! sendMessage' ("Look at that, you are now officially an elite haxor! By successfully hacking other people you can earn GoodBoyTokenz. "
|
do! sendMessage' ("Look at that, you are now officially an elite haxor! By successfully hacking other people you can earn GoodBoyTokenz. "
|
||||||
@ -159,9 +171,9 @@ let handleAttack (event : ComponentInteractionCreateEventArgs) =
|
|||||||
|
|
||||||
let handleTrainerStep6 (event : ComponentInteractionCreateEventArgs) =
|
let handleTrainerStep6 (event : ComponentInteractionCreateEventArgs) =
|
||||||
async {
|
async {
|
||||||
let! membr = event.Guild.GetMemberAsync(event.User.Id) |> Async.AwaitTask
|
// let! membr = event.Guild.GetMemberAsync(event.User.Id) |> Async.AwaitTask
|
||||||
let role = event.Guild.GetRole(GuildEnvironment.roleTrainee)
|
// let role = event.Guild.GetRole(GuildEnvironment.roleTrainee)
|
||||||
do! membr.RevokeRoleAsync(role) |> Async.AwaitTask
|
// do! membr.RevokeRoleAsync(role) |> Async.AwaitTask
|
||||||
|
|
||||||
let builder = DiscordInteractionResponseBuilder()
|
let builder = DiscordInteractionResponseBuilder()
|
||||||
builder.Content <- "Get out of here!"
|
builder.Content <- "Get out of here!"
|
||||||
|
@ -11,15 +11,13 @@ let mongo = MongoClient(Environment.GetEnvironmentVariable("CONN_STRING"))
|
|||||||
let db = mongo.GetDatabase("degenz")
|
let db = mongo.GetDatabase("degenz")
|
||||||
let players = db.GetCollection<BsonDocument>("players")
|
let players = db.GetCollection<BsonDocument>("players")
|
||||||
|
|
||||||
|
|
||||||
let tryFindPlayer (id : uint64) =
|
let tryFindPlayer (id : uint64) =
|
||||||
async {
|
async {
|
||||||
let filter = Builders<BsonDocument>.Filter.Eq("Player.DiscordId", id)
|
let filter = Builders<BsonDocument>.Filter.Eq("Player.DiscordId", id)
|
||||||
let! player = players.FindAsync<BsonDocument>(filter) |> Async.AwaitTask
|
let! player = players.FindAsync<BsonDocument>(filter) |> Async.AwaitTask
|
||||||
match player.FirstOrDefault() with
|
match player.FirstOrDefault() with
|
||||||
| null -> return None
|
| null -> return None
|
||||||
| p ->
|
| p -> return p
|
||||||
return p
|
|
||||||
.GetValue("Player")
|
.GetValue("Player")
|
||||||
.ToBsonDocument()
|
.ToBsonDocument()
|
||||||
|> BsonSerializer.Deserialize<Player>
|
|> BsonSerializer.Deserialize<Player>
|
||||||
|
@ -7,9 +7,9 @@ nuget FSharp.Core >= 6.0.0
|
|||||||
|
|
||||||
source https://nuget.emzi0767.com/api/v3/index.json
|
source https://nuget.emzi0767.com/api/v3/index.json
|
||||||
|
|
||||||
nuget DSharpPlus >= 4.2.0-nightly-01061
|
nuget DSharpPlus >= 4.2.0-nightly-01063
|
||||||
nuget DSharpPlus.Interactivity >= 4.2.0-nightly-01061
|
nuget DSharpPlus.Interactivity >= 4.2.0-nightly-01063
|
||||||
nuget DSharpPlus.SlashCommands >= 4.2.0-nightly-01061
|
nuget DSharpPlus.SlashCommands >= 4.2.0-nightly-01063
|
||||||
|
|
||||||
nuget MongoDB.Driver
|
nuget MongoDB.Driver
|
||||||
|
|
||||||
|
10
paket.lock
10
paket.lock
@ -472,7 +472,7 @@ NUGET
|
|||||||
System.Runtime (>= 4.3)
|
System.Runtime (>= 4.3)
|
||||||
System.ValueTuple (4.5)
|
System.ValueTuple (4.5)
|
||||||
remote: https://nuget.emzi0767.com/api/v3/index.json
|
remote: https://nuget.emzi0767.com/api/v3/index.json
|
||||||
DSharpPlus (4.2.0-nightly-01061)
|
DSharpPlus (4.2.0-nightly-01063)
|
||||||
Emzi0767.Common (>= 2.6.2)
|
Emzi0767.Common (>= 2.6.2)
|
||||||
Microsoft.Extensions.Logging.Abstractions (>= 5.0)
|
Microsoft.Extensions.Logging.Abstractions (>= 5.0)
|
||||||
Newtonsoft.Json (>= 13.0.1)
|
Newtonsoft.Json (>= 13.0.1)
|
||||||
@ -482,9 +482,9 @@ NUGET
|
|||||||
System.Net.WebSockets.Client (>= 4.3.2)
|
System.Net.WebSockets.Client (>= 4.3.2)
|
||||||
System.Runtime.InteropServices.RuntimeInformation (>= 4.3)
|
System.Runtime.InteropServices.RuntimeInformation (>= 4.3)
|
||||||
System.Threading.Channels (>= 5.0)
|
System.Threading.Channels (>= 5.0)
|
||||||
DSharpPlus.Interactivity (4.2.0-nightly-01061)
|
DSharpPlus.Interactivity (4.2.0-nightly-01063)
|
||||||
ConcurrentHashSet (>= 1.1)
|
ConcurrentHashSet (>= 1.1)
|
||||||
DSharpPlus (>= 4.2.0-nightly-01061)
|
DSharpPlus (>= 4.2.0-nightly-01063)
|
||||||
DSharpPlus.SlashCommands (4.2.0-nightly-01061)
|
DSharpPlus.SlashCommands (4.2.0-nightly-01063)
|
||||||
DSharpPlus (>= 4.2.0-nightly-01061)
|
DSharpPlus (>= 4.2.0-nightly-01063)
|
||||||
Microsoft.Extensions.DependencyInjection (>= 5.0.1)
|
Microsoft.Extensions.DependencyInjection (>= 5.0.1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user