Update voice channel with jackpot. Show jackpot prize in HoP

This commit is contained in:
Joseph Ferano 2022-04-25 18:05:29 +07:00
parent d5fc7ae229
commit fcd1f63154
2 changed files with 19 additions and 11 deletions

View File

@ -312,7 +312,7 @@ let spin multiplier (ctx : IDiscordContext) =
match result with match result with
| "WON" -> s1 + $" **WON** {prizeAmount} $GBT playing slots!" | "WON" -> s1 + $" **WON** {prizeAmount} $GBT playing slots!"
| "LOST" -> s1 + $" **LOST** 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) let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelEventsHackerBattle)
do! channel.SendMessageAsync(hopMsg) |> Async.AwaitTask |> Async.Ignore do! channel.SendMessageAsync(hopMsg) |> Async.AwaitTask |> Async.Ignore
@ -372,7 +372,7 @@ let handleMessageCreated (_ : DiscordClient) (event : MessageCreateEventArgs) =
do! event.Message.DeleteAsync() do! event.Message.DeleteAsync()
} :> Task } :> Task
let sendEmbed channel (message : DiscordMessage option) = async { let sendEmbed (jackpotNumChannel : DiscordChannel) slotsChannel (message : DiscordMessage option) = async {
let builder = DiscordMessageBuilder() let builder = DiscordMessageBuilder()
let embed = DiscordEmbedBuilder() let embed = DiscordEmbedBuilder()
embed.Title <- "Degenz Slot Machine" embed.Title <- "Degenz Slot Machine"
@ -381,6 +381,11 @@ let sendEmbed channel (message : DiscordMessage option) = async {
let! jackpot = getJackpotAmount () let! jackpot = getJackpotAmount ()
embed.Title <- $"CURRENT JACKPOT: `{jackpot} 💰 $GBT`" 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 builder.AddEmbed(embed) |> ignore
let button1 = DiscordButtonComponent(ButtonStyle.Success, $"spin-1x", $"🎰 Bet {PlayPricex1} $GBT") :> DiscordComponent let button1 = DiscordButtonComponent(ButtonStyle.Success, $"spin-1x", $"🎰 Bet {PlayPricex1} $GBT") :> DiscordComponent
@ -393,28 +398,30 @@ let sendEmbed channel (message : DiscordMessage option) = async {
let! _ = m.ModifyAsync(builder) |> Async.AwaitTask let! _ = m.ModifyAsync(builder) |> Async.AwaitTask
return Some m return Some m
| Some bot , None -> | Some bot , None ->
let! m = bot.SendMessageAsync(channel, builder) |> Async.AwaitTask let! m = bot.SendMessageAsync(slotsChannel, builder) |> Async.AwaitTask
do! m.PinAsync() |> Async.AwaitTask do! m.PinAsync() |> Async.AwaitTask
return Some m return Some m
| _ -> return None | _ -> return None
} }
let sendEmbedWithLoop (channel : DiscordChannel) = let sendEmbedWithLoop (jackpotNumChannel : DiscordChannel) (slotsChannel : DiscordChannel) =
async { async {
let! pins = channel.GetPinnedMessagesAsync() |> Async.AwaitTask let! pins = slotsChannel.GetPinnedMessagesAsync() |> Async.AwaitTask
let! message = let! message =
match pins |> Seq.toList with match pins |> Seq.toList with
| [] -> sendEmbed channel None | [] -> sendEmbed jackpotNumChannel slotsChannel None
| msg::_ -> async.Return (Some msg) | msg::_ -> async.Return (Some msg)
while true do while true do
do! Async.Sleep 10000 do! Async.Sleep 10000
do! sendEmbed channel (message) |> Async.Ignore do! sendEmbed jackpotNumChannel slotsChannel message |> Async.Ignore
} |> Async.Start } |> Async.Start
let sendInitialEmbedFromLaunch (client : DiscordClient) = let sendInitialEmbedFromLaunch (client : DiscordClient) =
let channel = client.Guilds.[GuildEnvironment.guildId].GetChannel(GuildEnvironment.channelSlots) let jackpotNumChannel = client.Guilds.[GuildEnvironment.guildId].GetChannel(GuildEnvironment.channelJackpotNum)
sendEmbedWithLoop channel let slotsChannel = client.Guilds.[GuildEnvironment.guildId].GetChannel(GuildEnvironment.channelSlots)
sendEmbedWithLoop jackpotNumChannel slotsChannel
let sendInitialEmbedFromSlashCommand (ctx : IDiscordContext) = let sendInitialEmbedFromSlashCommand (ctx : IDiscordContext) =
let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelSlots) let jackpotNumChannel = ctx.GetGuild().GetChannel(GuildEnvironment.channelJackpotNum)
sendEmbedWithLoop channel let slotsChannel = ctx.GetGuild().GetChannel(GuildEnvironment.channelSlots)
sendEmbedWithLoop jackpotNumChannel slotsChannel

View File

@ -34,6 +34,7 @@ let channelWhitelist = getId "CHANNEL_WHITELIST"
//let channelTosserTed = getId "CHANNEL_TOSSERTED" //let channelTosserTed = getId "CHANNEL_TOSSERTED"
let channelShelters = getId "CHANNEL_SHELTERS" let channelShelters = getId "CHANNEL_SHELTERS"
let channelSlots = getId "CHANNEL_SLOTS" let channelSlots = getId "CHANNEL_SLOTS"
let channelJackpotNum = getId "CHANNEL_JACKPOTNUM"
//let channelBackAlley = getId "CHANNEL_BACKALLEY" //let channelBackAlley = getId "CHANNEL_BACKALLEY"
//let channelMarket = getId "CHANNEL_MARKET" //let channelMarket = getId "CHANNEL_MARKET"
//let channelAccessoryShop = getId "CHANNEL_ACCESSORIES" //let channelAccessoryShop = getId "CHANNEL_ACCESSORIES"