111 lines
4.1 KiB
Forth

module Degenz.Bot
open System.Threading.Tasks
open DSharpPlus
open DSharpPlus.SlashCommands
open Degenz
open Degenz.HackerBattle
open Degenz.RockPaperScissors
open Degenz.Store
open Degenz.Thief
open Emzi0767.Utilities
//open Degenz.SlotMachine
type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule ()
let guild = GuildEnvironment.guildId
let hackerBattleConfig = DiscordConfiguration()
let storeConfig = DiscordConfiguration()
//let slotMachineConfig = DiscordConfiguration()
//hackerBattleConfig.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace
//let configs = [| hackerBattleConfig ; storeConfig ; slotMachineConfig ; |]
let configs = [ hackerBattleConfig ; storeConfig ]
hackerBattleConfig.TokenType <- TokenType.Bot
hackerBattleConfig.Intents <- DiscordIntents.All
storeConfig.TokenType <- TokenType.Bot
storeConfig.Intents <- DiscordIntents.All
hackerBattleConfig.Token <- GuildEnvironment.tokenHackerBattle
storeConfig.Token <- GuildEnvironment.tokenStore
//slotMachineConfig.Token <- Environment.GetEnvironmentVariable("BOT_SLOT_MACHINE")
let hackerBattleBot = new DiscordClient(hackerBattleConfig)
let storeBot = new DiscordClient(storeConfig)
//let slotMachineBot = new DiscordClient(slotMachineConfig)
//let clients = [| hackerBattleBot ; storeBot ; slotMachineBot |]
let hackerCommands = hackerBattleBot.UseSlashCommands()
let storeCommands = storeBot.UseSlashCommands()
//let sc3 = slotMachineBot.UseSlashCommands()
hackerCommands.RegisterCommands<HackerGame>(guild);
hackerCommands.RegisterCommands<StealGame>(guild);
hackerCommands.RegisterCommands<RPSGame>(guild);
storeCommands.RegisterCommands<Store>(guild);
//sc3.RegisterCommands<SlotMachine>(guild);
hackerBattleBot.add_ComponentInteractionCreated(AsyncEventHandler(HackerBattle.handleButtonEvent))
storeBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleStoreEvents))
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))
if guild <> 922419263275425832uL then
Trainer.sendInitialEmbed hackerBattleBot
hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser
storeBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
GuildEnvironment.botUserArmory <- Some storeBot.CurrentUser
//async {
// let! user = hackerBattleBot.GetUserAsync(GuildEnvironment.botIdHackerBattle) |> Async.AwaitTask
// if user <> null then
// GuildEnvironment.botUserHackerBattle <- Some user
// return ()
//} |> Async.RunSynchronously
//async {
// let! user = storeBot.GetUserAsync(GuildEnvironment.botIdHackerBattle) |> Async.AwaitTask
// if user <> null then
// GuildEnvironment.botUserHackerBattle <- Some user
// return ()
//} |> Async.RunSynchronously
if guild = 922419263275425832uL then
let interactionsConfig = DiscordConfiguration()
interactionsConfig.TokenType <- TokenType.Bot
interactionsConfig.Intents <- DiscordIntents.All
interactionsConfig.Token <- GuildEnvironment.tokenPlayerInteractions
let interactionsBot = new DiscordClient(interactionsConfig)
let commands = interactionsBot.UseSlashCommands()
commands.RegisterCommands<PlayerInteractions.PlayerInteractions>(guild)
interactionsBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
Task.Delay(-1)
|> Async.AwaitTask
|> Async.RunSynchronously