87 lines
2.9 KiB
Forth
87 lines
2.9 KiB
Forth
open System
|
|
open System.Threading.Tasks
|
|
open DSharpPlus
|
|
open DSharpPlus.Entities
|
|
open DSharpPlus.SlashCommands
|
|
open System.IO
|
|
|
|
let slots = [| "https://i.ibb.co/pKqZdr7/cherry.png" ; "https://i.ibb.co/Mk8wQmv/lemon.jpg" ; "https://i.ibb.co/1JTFPSs/seven.png" |]
|
|
|
|
type EmptyGlobalCommandToAvoidFamousDuplicateSlashCommandsBug() = inherit ApplicationCommandModule ()
|
|
|
|
type SlotMachine() =
|
|
inherit ApplicationCommandModule ()
|
|
|
|
[<SlashCommand("spin", "Want to try your luck?")>]
|
|
member this.AttackCommand (ctx : InteractionContext) =
|
|
async {
|
|
let sleepTime = 1000
|
|
let random = Random(System.Guid.NewGuid().GetHashCode())
|
|
let results = [ random.Next(0, 3) ; random.Next(0, 3) ; random.Next(0, 3)]
|
|
|
|
do! ctx.Interaction.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource)
|
|
|> Async.AwaitTask
|
|
|
|
do! Async.Sleep sleepTime
|
|
let builder = DiscordFollowupMessageBuilder()
|
|
let embed = DiscordEmbedBuilder()
|
|
embed.ImageUrl <- slots.[results.[0]]
|
|
builder.AddEmbed(embed.Build()) |> ignore
|
|
do! ctx.Interaction.CreateFollowupMessageAsync(builder)
|
|
|> Async.AwaitTask
|
|
|> Async.Ignore
|
|
|
|
do! Async.Sleep sleepTime
|
|
let builder = DiscordFollowupMessageBuilder()
|
|
embed.ImageUrl <- slots.[results.[1]]
|
|
builder.AddEmbed(embed.Build()) |> ignore
|
|
do! ctx.Interaction.CreateFollowupMessageAsync(builder)
|
|
|> Async.AwaitTask
|
|
|> Async.Ignore
|
|
|
|
do! Async.Sleep sleepTime
|
|
let builder = DiscordFollowupMessageBuilder()
|
|
embed.ImageUrl <- slots.[results.[2]]
|
|
builder.AddEmbed(embed.Build()) |> ignore
|
|
do! ctx.Interaction.CreateFollowupMessageAsync(builder)
|
|
|> Async.AwaitTask
|
|
|> Async.Ignore
|
|
|
|
do! Async.Sleep sleepTime
|
|
let builder = DiscordFollowupMessageBuilder()
|
|
builder.Content <- "You win!"
|
|
do! ctx.Interaction.CreateFollowupMessageAsync(builder)
|
|
|> Async.AwaitTask
|
|
|> Async.Ignore
|
|
|
|
} |> Async.StartAsTask
|
|
:> Task
|
|
|
|
let config = DiscordConfiguration()
|
|
config.Token <- "OTMyMzQ3NzQ1NDE3NzE1ODE0.YeRqgA.PHandjk0jQGIxlM8NlqKc7cJD3s"
|
|
config.TokenType <- TokenType.Bot
|
|
config.Intents <- DiscordIntents.All
|
|
//config.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace
|
|
|
|
let client = new DiscordClient(config)
|
|
|
|
let slash = client.UseSlashCommands()
|
|
|
|
// My server
|
|
slash.RegisterCommands<SlotMachine>(922419263275425832uL);
|
|
// Degenz
|
|
//slash.RegisterCommands<HackerGame>(922414052708327494uL);
|
|
|
|
client.ConnectAsync ()
|
|
|> Async.AwaitTask
|
|
|> Async.RunSynchronously
|
|
|
|
Task.Delay(-1)
|
|
|> Async.AwaitTask
|
|
|> Async.RunSynchronously
|
|
|
|
client.DisconnectAsync ()
|
|
|> Async.AwaitTask
|
|
|> Async.RunSynchronously
|
|
|