diff --git a/Bot/Admin.fs b/Bot/Admin.fs index fb0cca8..7ecfca0 100644 --- a/Bot/Admin.fs +++ b/Bot/Admin.fs @@ -29,7 +29,7 @@ let sendEmbed embed (ctx : IDiscordContext) = match embed with | InitEmbeds.Dojo -> Trainer.sendInitialEmbed ctx | InitEmbeds.Whitelist -> InviteTracker.sendInitialEmbed ctx - | InitEmbeds.Slots -> SlotMachine.sendInitialEmbed ctx + | InitEmbeds.Slots -> SlotMachine.sendInitialEmbedFromSlashCommand ctx | _ -> () do! Messaging.sendSimpleResponse ctx "Sent!" } :> Task diff --git a/Bot/Bot.fs b/Bot/Bot.fs index 69cde6c..71bafd2 100644 --- a/Bot/Bot.fs +++ b/Bot/Bot.fs @@ -111,6 +111,8 @@ adminBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously //stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously +SlotMachine.sendInitialEmbedFromLaunch slotsBot + let rec loop areBotsRunning = async { if not (File.Exists "fsharp-bots") then diff --git a/Bot/Games/SlotMachine.fs b/Bot/Games/SlotMachine.fs index 4402cde..3c0a8ca 100644 --- a/Bot/Games/SlotMachine.fs +++ b/Bot/Games/SlotMachine.fs @@ -32,8 +32,8 @@ let Obey = { index = 2 ; reel1Count = 3 ; reel2Count = 3 ; reel3Count = 3 let AnonMask = { index = 3 ; reel1Count = 2 ; reel2Count = 2 ; reel3Count = 4 ; emojiName = "anonmask" } let Rat = { index = 4 ; reel1Count = 4 ; reel2Count = 4 ; reel3Count = 3 ; emojiName = "rat" } let Ramen = { index = 5 ; reel1Count = 5 ; reel2Count = 5 ; reel3Count = 5 ; emojiName = "ramen" } -let Sushi = { index = 6 ; reel1Count = 6 ; reel2Count = 6 ; reel3Count = 3 ; emojiName = "sushi" } -let Pizza = { index = 7 ; reel1Count = 0 ; reel2Count = 3 ; reel3Count = 7 ; emojiName = "pizza" } +let Sushi = { index = 6 ; reel1Count = 6 ; reel2Count = 5 ; reel3Count = 3 ; emojiName = "sushi" } +let Pizza = { index = 7 ; reel1Count = 1 ; reel2Count = 3 ; reel3Count = 6 ; emojiName = "pizza" } //let Alcohol = { index = 8 ; reel1Count = 1 ; reel2Count = 1 ; reel3Count = 1 ; emojiName = "alcohol" } //let Circuit = { index = 9 ; reel1Count = 0 ; reel2Count = 0 ; reel3Count = 2 ; emojiName = "circuitboard" } //let OldTv = { index = 10 ; reel1Count = 1 ; reel2Count = 2 ; reel3Count = 2 ; emojiName = "oldtv" } @@ -366,37 +366,50 @@ let handleMessageCreated (_ : DiscordClient) (event : MessageCreateEventArgs) = do! event.Message.DeleteAsync() } :> Task -let sendInitialEmbed (ctx : IDiscordContext) = - let updateFn (ctx : IDiscordContext) (message : DiscordMessage option) = async { - let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelSlots) - let builder = DiscordMessageBuilder() - let embed = DiscordEmbedBuilder() - embed.Title <- "Degenz Slot Machine" - embed.ImageUrl <- "https://s7.gifyu.com/images/ezgif.com-gif-maker-268ecb6e4d28bd55a0.gif" - embed.Description <- "Want to try your luck?" - let! jackpot = getJackpotAmount () - embed.Title <- $"CURRENT JACKPOT: `{jackpot} 💰 $GBT`" +let sendEmbed channel (message : DiscordMessage option) = async { + printfn "SENT EMBED" + let builder = DiscordMessageBuilder() + let embed = DiscordEmbedBuilder() + embed.Title <- "Degenz Slot Machine" + embed.ImageUrl <- "https://s7.gifyu.com/images/ezgif.com-gif-maker-268ecb6e4d28bd55a0.gif" + embed.Description <- "Want to try your luck?" + let! jackpot = getJackpotAmount () + embed.Title <- $"CURRENT JACKPOT: `{jackpot} 💰 $GBT`" - builder.AddEmbed(embed) |> ignore + builder.AddEmbed(embed) |> ignore - let button1 = DiscordButtonComponent(ButtonStyle.Success, $"spin-1x", $"🎰 Bet {PlayPricex1} $GBT") :> DiscordComponent - let button2 = DiscordButtonComponent(ButtonStyle.Success, $"spin-2x", $"🎰 Bet {PlayPricex2} $GBT") :> DiscordComponent - let button3 = DiscordButtonComponent(ButtonStyle.Success, $"spin-3x", $"🎰 Bet {PlayPricex3} $GBT") :> DiscordComponent - let button4 = DiscordButtonComponent(ButtonStyle.Primary, $"prizes", $"Prize Table") :> DiscordComponent - builder.AddComponents([| button1 ; button2 ; button3 ; button4 |]) |> ignore - match GuildEnvironment.botClientSlots, message with - | _ , Some m -> - let! _ = m.ModifyAsync(builder) |> Async.AwaitTask - return Some m - | Some bot , None -> - let! m = bot.SendMessageAsync(channel, builder) |> Async.AwaitTask - return Some m - | _ -> return None - } - + let button1 = DiscordButtonComponent(ButtonStyle.Success, $"spin-1x", $"🎰 Bet {PlayPricex1} $GBT") :> DiscordComponent + let button2 = DiscordButtonComponent(ButtonStyle.Success, $"spin-2x", $"🎰 Bet {PlayPricex2} $GBT") :> DiscordComponent + let button3 = DiscordButtonComponent(ButtonStyle.Success, $"spin-3x", $"🎰 Bet {PlayPricex3} $GBT") :> DiscordComponent + let button4 = DiscordButtonComponent(ButtonStyle.Primary, $"prizes", $"Prize Table") :> DiscordComponent + builder.AddComponents([| button1 ; button2 ; button3 ; button4 |]) |> ignore + match GuildEnvironment.botClientSlots, message with + | _ , Some m -> + let! _ = m.ModifyAsync(builder) |> Async.AwaitTask + return Some m + | Some bot , None -> + let! m = bot.SendMessageAsync(channel, builder) |> Async.AwaitTask + do! m.PinAsync() |> Async.AwaitTask + return Some m + | _ -> return None +} + +let sendEmbedWithLoop (channel : DiscordChannel) = async { - let! message = updateFn ctx None + let! pins = channel.GetPinnedMessagesAsync() |> Async.AwaitTask + let! message = + match pins |> Seq.toList with + | [] -> sendEmbed channel None + | msg::_ -> async.Return (Some msg) while true do do! Async.Sleep 60000 - do! updateFn ctx (message) |> Async.Ignore + do! sendEmbed channel (message) |> Async.Ignore } |> Async.Start + +let sendInitialEmbedFromLaunch (client : DiscordClient) = + let channel = client.Guilds.[GuildEnvironment.guildId].GetChannel(GuildEnvironment.channelSlots) + sendEmbedWithLoop channel + +let sendInitialEmbedFromSlashCommand (ctx : IDiscordContext) = + let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelSlots) + sendEmbedWithLoop channel