From fcd1f63154a52fd410f0ac6d801c307b28b68fe3 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Mon, 25 Apr 2022 18:05:29 +0700 Subject: [PATCH] Update voice channel with jackpot. Show jackpot prize in HoP --- Bot/Games/SlotMachine.fs | 29 ++++++++++++++++++----------- Bot/GuildEnvironment.fs | 1 + 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Bot/Games/SlotMachine.fs b/Bot/Games/SlotMachine.fs index aac21e9..94b28e1 100644 --- a/Bot/Games/SlotMachine.fs +++ b/Bot/Games/SlotMachine.fs @@ -312,7 +312,7 @@ let spin multiplier (ctx : IDiscordContext) = match result with | "WON" -> s1 + $" **WON** {prizeAmount} $GBT playing slots!" | "LOST" -> s1 + $" **LOST** playing slots" - | "JACKPOT" -> s1 + $" 🎉🎉🎉 **JUST HIT THE JACKPOT** and **WON**!!! 🎉🎉🎉" + | "JACKPOT" -> s1 + $" 🎉🎉🎉 **JUST HIT THE JACKPOT** and **WON** {prizeAmount}!!! 🎉🎉🎉" | _ -> "" let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelEventsHackerBattle) do! channel.SendMessageAsync(hopMsg) |> Async.AwaitTask |> Async.Ignore @@ -372,7 +372,7 @@ let handleMessageCreated (_ : DiscordClient) (event : MessageCreateEventArgs) = do! event.Message.DeleteAsync() } :> Task -let sendEmbed channel (message : DiscordMessage option) = async { +let sendEmbed (jackpotNumChannel : DiscordChannel) slotsChannel (message : DiscordMessage option) = async { let builder = DiscordMessageBuilder() let embed = DiscordEmbedBuilder() embed.Title <- "Degenz Slot Machine" @@ -380,6 +380,11 @@ let sendEmbed channel (message : DiscordMessage option) = async { embed.Description <- "Try Your Hand at a Game of SLOTS!\nEvery Spin Adds to The JACKPOT!\nGood luck Degenz ✊" let! jackpot = getJackpotAmount () embed.Title <- $"CURRENT JACKPOT: `{jackpot} 💰 $GBT`" + + // Update Jackpot channel + try + do! jackpotNumChannel.ModifyAsync(fun channelEditModel -> channelEditModel.Name <- $"Jackpot: {jackpot} 💰 $GBT") |> Async.AwaitTask + with ex -> printfn $"{ex.Message}" builder.AddEmbed(embed) |> ignore @@ -393,28 +398,30 @@ let sendEmbed channel (message : DiscordMessage option) = async { let! _ = m.ModifyAsync(builder) |> Async.AwaitTask return Some m | Some bot , None -> - let! m = bot.SendMessageAsync(channel, builder) |> Async.AwaitTask + let! m = bot.SendMessageAsync(slotsChannel, builder) |> Async.AwaitTask do! m.PinAsync() |> Async.AwaitTask return Some m | _ -> return None } -let sendEmbedWithLoop (channel : DiscordChannel) = +let sendEmbedWithLoop (jackpotNumChannel : DiscordChannel) (slotsChannel : DiscordChannel) = async { - let! pins = channel.GetPinnedMessagesAsync() |> Async.AwaitTask + let! pins = slotsChannel.GetPinnedMessagesAsync() |> Async.AwaitTask let! message = match pins |> Seq.toList with - | [] -> sendEmbed channel None + | [] -> sendEmbed jackpotNumChannel slotsChannel None | msg::_ -> async.Return (Some msg) while true do do! Async.Sleep 10000 - do! sendEmbed channel (message) |> Async.Ignore + do! sendEmbed jackpotNumChannel slotsChannel message |> Async.Ignore } |> Async.Start let sendInitialEmbedFromLaunch (client : DiscordClient) = - let channel = client.Guilds.[GuildEnvironment.guildId].GetChannel(GuildEnvironment.channelSlots) - sendEmbedWithLoop channel + let jackpotNumChannel = client.Guilds.[GuildEnvironment.guildId].GetChannel(GuildEnvironment.channelJackpotNum) + let slotsChannel = client.Guilds.[GuildEnvironment.guildId].GetChannel(GuildEnvironment.channelSlots) + sendEmbedWithLoop jackpotNumChannel slotsChannel let sendInitialEmbedFromSlashCommand (ctx : IDiscordContext) = - let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelSlots) - sendEmbedWithLoop channel + let jackpotNumChannel = ctx.GetGuild().GetChannel(GuildEnvironment.channelJackpotNum) + let slotsChannel = ctx.GetGuild().GetChannel(GuildEnvironment.channelSlots) + sendEmbedWithLoop jackpotNumChannel slotsChannel diff --git a/Bot/GuildEnvironment.fs b/Bot/GuildEnvironment.fs index a384b1e..47fe62d 100644 --- a/Bot/GuildEnvironment.fs +++ b/Bot/GuildEnvironment.fs @@ -34,6 +34,7 @@ let channelWhitelist = getId "CHANNEL_WHITELIST" //let channelTosserTed = getId "CHANNEL_TOSSERTED" let channelShelters = getId "CHANNEL_SHELTERS" let channelSlots = getId "CHANNEL_SLOTS" +let channelJackpotNum = getId "CHANNEL_JACKPOTNUM" //let channelBackAlley = getId "CHANNEL_BACKALLEY" //let channelMarket = getId "CHANNEL_MARKET" //let channelAccessoryShop = getId "CHANNEL_ACCESSORIES"