diff --git a/PlayerInteractions/Bot.fs b/PlayerInteractions/Bot.fs index 58b05ad..88e4326 100644 --- a/PlayerInteractions/Bot.fs +++ b/PlayerInteractions/Bot.fs @@ -4,8 +4,6 @@ open System open System.Threading.Tasks open DSharpPlus open DSharpPlus.SlashCommands -open Degenz.Shared -open Emzi0767.Utilities open Degenz.PlayerInteractions open Degenz.SlotMachine open Degenz.Trainer @@ -29,7 +27,6 @@ for conf in configs do conf.Intents <- DiscordIntents.All -//DotEnv.Load(DotEnvOptions(probeForEnv = true, probeLevelsToSearch = 4)) DotEnv.Load(DotEnvOptions(probeForEnv = true, probeLevelsToSearch = 5, overwriteExistingVars = false)) let guild = Environment.GetEnvironmentVariable("DISCORD_GUILD") |> uint64 @@ -61,8 +58,6 @@ sc2.RegisterCommands(guild); sc3.RegisterCommands(guild); sc4.RegisterCommands(guild); sc5.RegisterCommands(guild); -// Degenz -//slash.RegisterCommands(922414052708327494uL); let run (client : DiscordClient) = async { diff --git a/PlayerInteractions/HackerBattle.fs b/PlayerInteractions/HackerBattle.fs index 12100fd..36421c9 100644 --- a/PlayerInteractions/HackerBattle.fs +++ b/PlayerInteractions/HackerBattle.fs @@ -7,7 +7,6 @@ open DSharpPlus.Entities open DSharpPlus.EventArgs open DSharpPlus.SlashCommands open Degenz -open Emzi0767.Utilities open Degenz.Shared [] diff --git a/PlayerInteractions/PlayerInteractions.fs b/PlayerInteractions/PlayerInteractions.fs index 13fb2fa..00d1ad9 100644 --- a/PlayerInteractions/PlayerInteractions.fs +++ b/PlayerInteractions/PlayerInteractions.fs @@ -4,7 +4,6 @@ open System open System.Threading.Tasks open DSharpPlus.Entities open DSharpPlus -open DSharpPlus.EventArgs open DSharpPlus.SlashCommands open Degenz open Degenz.Shared diff --git a/PlayerInteractions/Store.fs b/PlayerInteractions/Store.fs index cbd33b2..616a475 100644 --- a/PlayerInteractions/Store.fs +++ b/PlayerInteractions/Store.fs @@ -7,7 +7,6 @@ open DSharpPlus.EventArgs open DSharpPlus.SlashCommands open Degenz open Degenz.Shared -open Emzi0767.Utilities open Newtonsoft.Json let store = diff --git a/PlayerInteractions/Trainer.fs b/PlayerInteractions/Trainer.fs index c25280b..480536a 100644 --- a/PlayerInteractions/Trainer.fs +++ b/PlayerInteractions/Trainer.fs @@ -6,68 +6,6 @@ open DSharpPlus.Entities open DSharpPlus.EventArgs open DSharpPlus.SlashCommands open Degenz.Shared -open Emzi0767.Utilities - -type Trainer() = - inherit ApplicationCommandModule () - - [] - member this.DefendCommand (ctx : InteractionContext) = - async { - let! playerResult = DbService.tryFindPlayer ctx.Member.Id - match playerResult with - | Some player -> - let builder = DiscordInteractionResponseBuilder() - builder.AddEmbed (constructEmbed "Pick a defense to mount for 24 hours") |> ignore - - constructButtons "Defend" (string player.DiscordId) player.Shields - |> Seq.cast - |> builder.AddComponents - |> ignore - - builder.AsEphemeral true |> ignore - - do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder) - |> Async.AwaitTask - | None -> - let builder = DiscordInteractionResponseBuilder() - builder.Content <- "Error, please contact a moderator" - - builder.AsEphemeral true |> ignore - - do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder) - |> Async.AwaitTask - } |> Async.StartAsTask - :> Task - - [] - member this.Attack (ctx : InteractionContext) = - async { - let! playerResult = DbService.tryFindPlayer ctx.Member.Id - match playerResult with - | Some player -> - let builder = DiscordInteractionResponseBuilder() - builder.AddEmbed (constructEmbed "Pick an attack to use on your target") |> ignore - - constructButtons "Attack" (string player.DiscordId) player.Weapons - |> Seq.cast - |> builder.AddComponents - |> ignore - - builder.AsEphemeral true |> ignore - - do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder) - |> Async.AwaitTask - | None -> - let builder = DiscordInteractionResponseBuilder() - builder.Content <- "Error, please contact a moderator" - - builder.AsEphemeral true |> ignore - - do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder) - |> Async.AwaitTask - } |> Async.StartAsTask - :> Task let sendMessage (event : ComponentInteractionCreateEventArgs) msg = async { @@ -146,44 +84,76 @@ let handleButtonEvent (_ : DiscordClient) (event : ComponentInteractionCreateEve |> Async.StartAsTask :> Task -let config = DiscordConfiguration() -config.Token <- "OTMzMDg4MTQyNDM5ODk5MTg4.YeccDQ.AbysjlHICgbNQVyduG6aGIHNpdE" -config.TokenType <- TokenType.Bot -config.Intents <- DiscordIntents.All -//config.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace +let sendInitialEmbed (client : DiscordClient) = + async { + let! channel = client.GetChannelAsync(933298431521333258uL) |> Async.AwaitTask + let builder = DiscordMessageBuilder() + builder.Content <- "Welcome to the trainer bot, are you ready to get started?" + let button = DiscordButtonComponent(ButtonStyle.Success, $"Trainer-trainer-1", $"Get started") :> DiscordComponent + builder.AddComponents [| button |] |> ignore + do! channel.SendMessageAsync(builder) + |> Async.AwaitTask + |> Async.Ignore + } |> Async.RunSynchronously -let client = new DiscordClient(config) +type Trainer() = + inherit ApplicationCommandModule () -let slash = client.UseSlashCommands() + [] + member this.DefendCommand (ctx : InteractionContext) = + async { + let! playerResult = DbService.tryFindPlayer ctx.Member.Id + match playerResult with + | Some player -> + let builder = DiscordInteractionResponseBuilder() + builder.AddEmbed (constructEmbed "Pick a defense to mount for 24 hours") |> ignore -client.add_ComponentInteractionCreated(AsyncEventHandler(handleButtonEvent)) + constructButtons "Defend" (string player.DiscordId) player.Shields + |> Seq.cast + |> builder.AddComponents + |> ignore -// My server -slash.RegisterCommands(922419263275425832uL); -// Degenz -//slash.RegisterCommands(922414052708327494uL); + builder.AsEphemeral true |> ignore -client.ConnectAsync () -|> Async.AwaitTask -|> Async.RunSynchronously + do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder) + |> Async.AwaitTask + | None -> + let builder = DiscordInteractionResponseBuilder() + builder.Content <- "Error, please contact a moderator" -async { - let! channel = client.GetChannelAsync(933298431521333258uL) |> Async.AwaitTask - let builder = DiscordMessageBuilder() - builder.Content <- "Welcome to the trainer bot, are you ready to get started?" - let button = DiscordButtonComponent(ButtonStyle.Success, $"Trainer-trainer-1", $"Get started") :> DiscordComponent - builder.AddComponents [| button |] |> ignore - do! channel.SendMessageAsync(builder) - |> Async.AwaitTask - |> Async.Ignore -} |> Async.RunSynchronously + builder.AsEphemeral true |> ignore + do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder) + |> Async.AwaitTask + } |> Async.StartAsTask + :> Task -Task.Delay(-1) -|> Async.AwaitTask -|> Async.RunSynchronously + [] + member this.Attack (ctx : InteractionContext) = + async { + let! playerResult = DbService.tryFindPlayer ctx.Member.Id + match playerResult with + | Some player -> + let builder = DiscordInteractionResponseBuilder() + builder.AddEmbed (constructEmbed "Pick an attack to use on your target") |> ignore -client.DisconnectAsync () -|> Async.AwaitTask -|> Async.RunSynchronously + constructButtons "Attack" (string player.DiscordId) player.Weapons + |> Seq.cast + |> builder.AddComponents + |> ignore + + builder.AsEphemeral true |> ignore + + do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder) + |> Async.AwaitTask + | None -> + let builder = DiscordInteractionResponseBuilder() + builder.Content <- "Error, please contact a moderator" + + builder.AsEphemeral true |> ignore + + do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder) + |> Async.AwaitTask + } |> Async.StartAsTask + :> Task