Some clean up
This commit is contained in:
parent
116ab79e8a
commit
a08c66a84d
@ -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<Trainer>(guild);
|
||||
sc3.RegisterCommands<HackerGame>(guild);
|
||||
sc4.RegisterCommands<Store>(guild);
|
||||
sc5.RegisterCommands<SlotMachine>(guild);
|
||||
// Degenz
|
||||
//slash.RegisterCommands<HackerGame>(922414052708327494uL);
|
||||
|
||||
let run (client : DiscordClient) =
|
||||
async {
|
||||
|
@ -7,7 +7,6 @@ open DSharpPlus.Entities
|
||||
open DSharpPlus.EventArgs
|
||||
open DSharpPlus.SlashCommands
|
||||
open Degenz
|
||||
open Emzi0767.Utilities
|
||||
open Degenz.Shared
|
||||
|
||||
[<Literal>]
|
||||
|
@ -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
|
||||
|
@ -7,7 +7,6 @@ open DSharpPlus.EventArgs
|
||||
open DSharpPlus.SlashCommands
|
||||
open Degenz
|
||||
open Degenz.Shared
|
||||
open Emzi0767.Utilities
|
||||
open Newtonsoft.Json
|
||||
|
||||
let store =
|
||||
|
@ -6,68 +6,6 @@ open DSharpPlus.Entities
|
||||
open DSharpPlus.EventArgs
|
||||
open DSharpPlus.SlashCommands
|
||||
open Degenz.Shared
|
||||
open Emzi0767.Utilities
|
||||
|
||||
type Trainer() =
|
||||
inherit ApplicationCommandModule ()
|
||||
|
||||
[<SlashCommand("defend", "Create a passive defense that will last 24 hours")>]
|
||||
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<DiscordComponent>
|
||||
|> 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
|
||||
|
||||
[<SlashCommand("hack", "Send a hack attack to another player")>]
|
||||
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<DiscordComponent>
|
||||
|> 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,27 +84,7 @@ 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 client = new DiscordClient(config)
|
||||
|
||||
let slash = client.UseSlashCommands()
|
||||
|
||||
client.add_ComponentInteractionCreated(AsyncEventHandler(handleButtonEvent))
|
||||
|
||||
// My server
|
||||
slash.RegisterCommands<Trainer>(922419263275425832uL);
|
||||
// Degenz
|
||||
//slash.RegisterCommands<HackerGame>(922414052708327494uL);
|
||||
|
||||
client.ConnectAsync ()
|
||||
|> Async.AwaitTask
|
||||
|> Async.RunSynchronously
|
||||
|
||||
let sendInitialEmbed (client : DiscordClient) =
|
||||
async {
|
||||
let! channel = client.GetChannelAsync(933298431521333258uL) |> Async.AwaitTask
|
||||
let builder = DiscordMessageBuilder()
|
||||
@ -178,12 +96,64 @@ async {
|
||||
|> Async.Ignore
|
||||
} |> Async.RunSynchronously
|
||||
|
||||
type Trainer() =
|
||||
inherit ApplicationCommandModule ()
|
||||
|
||||
Task.Delay(-1)
|
||||
[<SlashCommand("defend", "Create a passive defense that will last 24 hours")>]
|
||||
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<DiscordComponent>
|
||||
|> builder.AddComponents
|
||||
|> ignore
|
||||
|
||||
builder.AsEphemeral true |> ignore
|
||||
|
||||
do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder)
|
||||
|> Async.AwaitTask
|
||||
|> Async.RunSynchronously
|
||||
| None ->
|
||||
let builder = DiscordInteractionResponseBuilder()
|
||||
builder.Content <- "Error, please contact a moderator"
|
||||
|
||||
client.DisconnectAsync ()
|
||||
builder.AsEphemeral true |> ignore
|
||||
|
||||
do! ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, builder)
|
||||
|> Async.AwaitTask
|
||||
|> Async.RunSynchronously
|
||||
} |> Async.StartAsTask
|
||||
:> Task
|
||||
|
||||
[<SlashCommand("hack", "Send a hack attack to another player")>]
|
||||
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<DiscordComponent>
|
||||
|> 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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user