open System open System.Threading.Tasks open DSharpPlus.Entities open DSharpPlus open DSharpPlus.EventArgs open DSharpPlus.SlashCommands open DegenzGame open DegenzGame.Shared open Emzi0767.Utilities module Commands = let constructItemButtons playerInfo (items : 'a array) = items |> Seq.map (fun item -> DiscordButtonComponent(ButtonStyle.Primary, $"{playerInfo}-{item}", $"{item}")) let viewStore (ctx : InteractionContext) = async { let builder = DiscordInteractionResponseBuilder() let hacks = weaponInventory |> Array.map (fun w -> $"{w} - 5 GBT") |> String.concat "\n" builder.AddEmbed (constructEmbed $"Hacks:\n{hacks}") |> ignore let shields = shieldInventory |> Array.map (fun w -> $"{w} - 5 GBT") |> String.concat "\n" builder.AddEmbed (constructEmbed $"Shields:\n{shields}") |> ignore builder.AsEphemeral true |> ignore do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask } |> Async.StartAsTask :> Task let buyHack (ctx : InteractionContext) hackId = async { return () } |> Async.StartAsTask :> Task let buyShield (ctx : InteractionContext) shieldId = async { return () } |> Async.StartAsTask :> Task let sellItem (ctx : InteractionContext) = async { return () } |> Async.StartAsTask :> Task type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule () type Store() = inherit ApplicationCommandModule () [] member _.ViewStore (ctx : InteractionContext) = Commands.viewStore ctx [] member _.BuyHack (ctx : InteractionContext, [] hackId : Weapon) = Commands.buyHack ctx hackId [] member this.BuyShield (ctx : InteractionContext, [] shieldId : Shield) = Commands.buyShield ctx shieldId [] member this.SellItem (ctx : InteractionContext) = Commands.sellItem ctx let handleButtonEvent (_ : DiscordClient) (event : ComponentInteractionCreateEventArgs) = async { let builder = DiscordInteractionResponseBuilder() builder.IsEphemeral <- true builder.Content <- $"" do! event.Interaction.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask } |> Async.StartAsTask :> Task let config = DiscordConfiguration() config.Token <- "OTIyNDIyMDIyMTI1MDEwOTU1.YcBOcw.JxfW1CSIwEO7j6RbRFCnPZ-HoTk" config.TokenType <- TokenType.Bot config.Intents <- DiscordIntents.All //config.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace let client = new DiscordClient(config) client.add_ComponentInteractionCreated(AsyncEventHandler(handleButtonEvent)) let slash = client.UseSlashCommands() // My server slash.RegisterCommands(922419263275425832uL); // Degenz //slash.RegisterCommands(922414052708327494uL); client.ConnectAsync () |> Async.AwaitTask |> Async.RunSynchronously Task.Delay(-1) |> Async.AwaitTask |> Async.RunSynchronously client.DisconnectAsync () |> Async.AwaitTask |> Async.RunSynchronously