module Degenz.Bot open System open System.Threading.Tasks open DSharpPlus open DSharpPlus.SlashCommands open Degenz.PlayerInteractions open Degenz.SlotMachine open Degenz.Trainer open Degenz.HackerBattle open Degenz.Store open Emzi0767.Utilities open dotenv.net type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule () let playerInteractionsConfig = DiscordConfiguration() let trainerConfig = DiscordConfiguration() let hackerBattleConfig = DiscordConfiguration() let storeConfig = DiscordConfiguration() //let slotMachineConfig = DiscordConfiguration() //let configs = [| playerInteractionsConfig ; trainerConfig ; hackerBattleConfig ; storeConfig ; slotMachineConfig ; |] let configs = [| playerInteractionsConfig ; trainerConfig ; hackerBattleConfig ; storeConfig |] for conf in configs do conf.TokenType <- TokenType.Bot conf.Intents <- DiscordIntents.All DotEnv.Load(DotEnvOptions(probeForEnv = true, probeLevelsToSearch = 5, overwriteExistingVars = false)) let guild = Environment.GetEnvironmentVariable("DISCORD_GUILD") |> uint64 playerInteractionsConfig.Token <- Environment.GetEnvironmentVariable("BOT_PLAYER_INTERACTIONS") trainerConfig.Token <- Environment.GetEnvironmentVariable("BOT_TRAINER") hackerBattleConfig.Token <- Environment.GetEnvironmentVariable("BOT_HACKER_BATTLE") storeConfig.Token <- Environment.GetEnvironmentVariable("BOT_STORE") //slotMachineConfig.Token <- Environment.GetEnvironmentVariable("BOT_SLOT_MACHINE") //config.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace let playerInteractionsBot = new DiscordClient(playerInteractionsConfig) let trainerBot = new DiscordClient(trainerConfig) let hackerBattleBot = new DiscordClient(hackerBattleConfig) let storeBot = new DiscordClient(storeConfig) //let slotMachineBot = new DiscordClient(slotMachineConfig) hackerBattleBot.add_ComponentInteractionCreated(AsyncEventHandler(HackerBattle.handleButtonEvent)) trainerBot.add_ComponentInteractionCreated(AsyncEventHandler(Trainer.handleButtonEvent)) storeBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleSellButtonEvents)) //let clients = [| storeBot ; trainerBot ; hackerBattleBot ; playerInteractionsBot ; slotMachineBot |] let clients = [| storeBot ; trainerBot ; hackerBattleBot ; playerInteractionsBot |] let sc1 = playerInteractionsBot.UseSlashCommands() let sc2 = trainerBot.UseSlashCommands() let sc3 = hackerBattleBot.UseSlashCommands() let sc4 = storeBot.UseSlashCommands() //let sc5 = slotMachineBot.UseSlashCommands() sc1.RegisterCommands(guild); sc2.RegisterCommands(guild); sc3.RegisterCommands(guild); sc4.RegisterCommands(guild); //sc5.RegisterCommands(guild); let run (client : DiscordClient) = async { do! client.ConnectAsync () |> Async.AwaitTask } clients |> Array.map run |> Array.toSeq |> Async.Sequential |> Async.RunSynchronously |> ignore Task.Delay(-1) |> Async.AwaitTask |> Async.RunSynchronously