New improved slots, improve admin commands, GetInteraction()
This commit is contained in:
parent
2404fd42db
commit
893fe1133d
1
.gitignore
vendored
1
.gitignore
vendored
@ -456,3 +456,4 @@ $RECYCLE.BIN/
|
|||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
*.org
|
*.org
|
||||||
/.paket/load/
|
/.paket/load/
|
||||||
|
/Images/
|
||||||
|
18
Bot/Admin.fs
18
Bot/Admin.fs
@ -1,10 +1,24 @@
|
|||||||
module Degenz.Admin
|
module Degenz.Admin
|
||||||
|
|
||||||
open System.Threading.Tasks
|
open System.Threading.Tasks
|
||||||
|
open DSharpPlus
|
||||||
open DSharpPlus.Entities
|
open DSharpPlus.Entities
|
||||||
|
open DSharpPlus.EventArgs
|
||||||
open DSharpPlus.SlashCommands
|
open DSharpPlus.SlashCommands
|
||||||
|
open DSharpPlus.SlashCommands.Attributes
|
||||||
open Degenz.Messaging
|
open Degenz.Messaging
|
||||||
|
|
||||||
|
let handleGuildDownloadReady (_ : DiscordClient) (event : GuildDownloadCompletedEventArgs) =
|
||||||
|
task {
|
||||||
|
let ( _ , guild ) = event.Guilds.TryGetValue(GuildEnvironment.guildId)
|
||||||
|
let! commands = guild.GetApplicationCommandsAsync()
|
||||||
|
let ( _ , adminRole ) = guild.Roles.TryGetValue(GuildEnvironment.roleAdmin)
|
||||||
|
|
||||||
|
let permission = DiscordApplicationCommandPermission(adminRole, true)
|
||||||
|
let commands = commands |> Seq.map (fun com -> DiscordGuildApplicationCommandPermissions(com.Id, [ permission ]))
|
||||||
|
do! guild.BatchEditApplicationCommandPermissionsAsync(commands) |> Async.AwaitTask |> Async.Ignore
|
||||||
|
} :> Task
|
||||||
|
|
||||||
type AdminBot() =
|
type AdminBot() =
|
||||||
inherit ApplicationCommandModule ()
|
inherit ApplicationCommandModule ()
|
||||||
|
|
||||||
@ -15,10 +29,10 @@ type AdminBot() =
|
|||||||
else
|
else
|
||||||
Messaging.sendSimpleResponse ctx $"You are not admin" |> Async.StartAsTask :> Task
|
Messaging.sendSimpleResponse ctx $"You are not admin" |> Async.StartAsTask :> Task
|
||||||
|
|
||||||
[<SlashCommand("admin-invites", "Get total invites from a specific user")>]
|
[<SlashCommand("admin-invites", "Get total invites from a specific user", false)>]
|
||||||
member this.GetAttributions (ctx : InteractionContext, [<Option("player", "The player you want to check")>] user : DiscordUser) =
|
member this.GetAttributions (ctx : InteractionContext, [<Option("player", "The player you want to check")>] user : DiscordUser) =
|
||||||
enforceAdmin (DiscordInteractionContext ctx) (InviteTracker.getInvitedUsersForId)
|
enforceAdmin (DiscordInteractionContext ctx) (InviteTracker.getInvitedUsersForId)
|
||||||
|
|
||||||
[<SlashCommand("admin-whitelist-stock", "Set whitelist stock")>]
|
[<SlashCommand("admin-whitelist-stock", "Set whitelist stock", false)>]
|
||||||
member this.SetStock (ctx : InteractionContext, [<Option("amount", "Set the amount of WL available for purchase")>] amount : int64) =
|
member this.SetStock (ctx : InteractionContext, [<Option("amount", "Set the amount of WL available for purchase")>] amount : int64) =
|
||||||
enforceAdmin (DiscordInteractionContext ctx) (InviteTracker.setWhitelistStock (int amount))
|
enforceAdmin (DiscordInteractionContext ctx) (InviteTracker.setWhitelistStock (int amount))
|
||||||
|
51
Bot/Bot.fs
51
Bot/Bot.fs
@ -3,6 +3,7 @@ module Degenz.Bot
|
|||||||
open System.IO
|
open System.IO
|
||||||
open System.Threading.Tasks
|
open System.Threading.Tasks
|
||||||
open DSharpPlus
|
open DSharpPlus
|
||||||
|
open DSharpPlus.Entities
|
||||||
open DSharpPlus.SlashCommands
|
open DSharpPlus.SlashCommands
|
||||||
open Degenz
|
open Degenz
|
||||||
open Emzi0767.Utilities
|
open Emzi0767.Utilities
|
||||||
@ -16,9 +17,9 @@ let hackerBattleConfig = DiscordConfiguration()
|
|||||||
let storeConfig = DiscordConfiguration()
|
let storeConfig = DiscordConfiguration()
|
||||||
let stealConfig = DiscordConfiguration()
|
let stealConfig = DiscordConfiguration()
|
||||||
let inviterConfig = DiscordConfiguration()
|
let inviterConfig = DiscordConfiguration()
|
||||||
|
let slotsConfig = DiscordConfiguration()
|
||||||
let adminConfig = DiscordConfiguration()
|
let adminConfig = DiscordConfiguration()
|
||||||
//let slotMachineConfig = DiscordConfiguration()
|
//adminConfig.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace
|
||||||
//hackerBattleConfig.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace
|
|
||||||
//storeConfig.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace
|
//storeConfig.MinimumLogLevel <- Microsoft.Extensions.Logging.LogLevel.Trace
|
||||||
|
|
||||||
hackerBattleConfig.TokenType <- TokenType.Bot
|
hackerBattleConfig.TokenType <- TokenType.Bot
|
||||||
@ -33,6 +34,9 @@ stealConfig.Intents <- DiscordIntents.All
|
|||||||
inviterConfig.TokenType <- TokenType.Bot
|
inviterConfig.TokenType <- TokenType.Bot
|
||||||
inviterConfig.Intents <- DiscordIntents.All
|
inviterConfig.Intents <- DiscordIntents.All
|
||||||
|
|
||||||
|
slotsConfig.TokenType <- TokenType.Bot
|
||||||
|
slotsConfig.Intents <- DiscordIntents.All
|
||||||
|
|
||||||
adminConfig.TokenType <- TokenType.Bot
|
adminConfig.TokenType <- TokenType.Bot
|
||||||
adminConfig.Intents <- DiscordIntents.All
|
adminConfig.Intents <- DiscordIntents.All
|
||||||
|
|
||||||
@ -40,31 +44,29 @@ hackerBattleConfig.Token <- GuildEnvironment.tokenHackerBattle
|
|||||||
storeConfig.Token <- GuildEnvironment.tokenStore
|
storeConfig.Token <- GuildEnvironment.tokenStore
|
||||||
stealConfig.Token <- GuildEnvironment.tokenSteal
|
stealConfig.Token <- GuildEnvironment.tokenSteal
|
||||||
inviterConfig.Token <- GuildEnvironment.tokenInviter
|
inviterConfig.Token <- GuildEnvironment.tokenInviter
|
||||||
|
slotsConfig.Token <- GuildEnvironment.tokenSlots
|
||||||
adminConfig.Token <- GuildEnvironment.tokenAdmin
|
adminConfig.Token <- GuildEnvironment.tokenAdmin
|
||||||
//slotMachineConfig.Token <- Environment.GetEnvironmentVariable("BOT_SLOT_MACHINE")
|
|
||||||
|
|
||||||
let hackerBattleBot = new DiscordClient(hackerBattleConfig)
|
let hackerBattleBot = new DiscordClient(hackerBattleConfig)
|
||||||
let storeBot = new DiscordClient(storeConfig)
|
let storeBot = new DiscordClient(storeConfig)
|
||||||
let stealBot = new DiscordClient(stealConfig)
|
let stealBot = new DiscordClient(stealConfig)
|
||||||
let inviterBot = new DiscordClient(inviterConfig)
|
let inviterBot = new DiscordClient(inviterConfig)
|
||||||
|
let slotsBot = new DiscordClient(slotsConfig)
|
||||||
let adminBot = new DiscordClient(adminConfig)
|
let adminBot = new DiscordClient(adminConfig)
|
||||||
//let slotMachineBot = new DiscordClient(slotMachineConfig)
|
|
||||||
|
|
||||||
//let clients = [| hackerBattleBot ; storeBot ; slotMachineBot |]
|
|
||||||
let hackerCommands = hackerBattleBot.UseSlashCommands()
|
let hackerCommands = hackerBattleBot.UseSlashCommands()
|
||||||
let storeCommands = storeBot.UseSlashCommands()
|
let storeCommands = storeBot.UseSlashCommands()
|
||||||
let stealCommands = stealBot.UseSlashCommands()
|
let stealCommands = stealBot.UseSlashCommands()
|
||||||
let inviterCommands = inviterBot.UseSlashCommands()
|
let inviterCommands = inviterBot.UseSlashCommands()
|
||||||
|
let slotsCommands = slotsBot.UseSlashCommands()
|
||||||
let adminCommands = adminBot.UseSlashCommands()
|
let adminCommands = adminBot.UseSlashCommands()
|
||||||
//let sc3 = slotMachineBot.UseSlashCommands()
|
|
||||||
|
|
||||||
hackerCommands.RegisterCommands<HackerBattle.HackerGame>(guild);
|
hackerCommands.RegisterCommands<HackerBattle.HackerGame>(guild);
|
||||||
storeCommands.RegisterCommands<Store.Store>(guild);
|
storeCommands.RegisterCommands<Store.Store>(guild);
|
||||||
stealCommands.RegisterCommands<Thief.StealGame>(guild);
|
stealCommands.RegisterCommands<Thief.StealGame>(guild);
|
||||||
inviterCommands.RegisterCommands<InviteTracker.Inviter>(guild);
|
inviterCommands.RegisterCommands<InviteTracker.Inviter>(guild);
|
||||||
adminCommands.RegisterCommands<Admin.AdminBot>(guild);
|
slotsCommands.RegisterCommands<SlotMachine.SlotMachine>(guild);
|
||||||
//hackerCommands.RegisterCommands<RPSGame>(guild);
|
adminCommands.RegisterCommands<Admin.AdminBot>(guild)
|
||||||
//sc3.RegisterCommands<SlotMachine>(guild);
|
|
||||||
|
|
||||||
hackerBattleBot.add_ComponentInteractionCreated(AsyncEventHandler(HackerBattle.handleButtonEvent))
|
hackerBattleBot.add_ComponentInteractionCreated(AsyncEventHandler(HackerBattle.handleButtonEvent))
|
||||||
hackerBattleBot.add_MessageCreated(AsyncEventHandler(HackerBattle.handleMessageCreated))
|
hackerBattleBot.add_MessageCreated(AsyncEventHandler(HackerBattle.handleMessageCreated))
|
||||||
@ -72,7 +74,8 @@ storeBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleStoreEven
|
|||||||
stealBot.add_ComponentInteractionCreated(AsyncEventHandler(Thief.handleStealButton))
|
stealBot.add_ComponentInteractionCreated(AsyncEventHandler(Thief.handleStealButton))
|
||||||
inviterBot.add_GuildMemberAdded(AsyncEventHandler(InviteTracker.handleGuildMemberAdded))
|
inviterBot.add_GuildMemberAdded(AsyncEventHandler(InviteTracker.handleGuildMemberAdded))
|
||||||
inviterBot.add_ComponentInteractionCreated(AsyncEventHandler(InviteTracker.handleButtonEvent))
|
inviterBot.add_ComponentInteractionCreated(AsyncEventHandler(InviteTracker.handleButtonEvent))
|
||||||
//inviterBot.add_GuildMemberRemoved(AsyncEventHandler(InviteTracker.handleGuildMemberRemoved))
|
slotsBot.add_ComponentInteractionCreated(AsyncEventHandler(SlotMachine.handleSpin))
|
||||||
|
adminBot.add_GuildDownloadCompleted(AsyncEventHandler(Admin.handleGuildDownloadReady))
|
||||||
|
|
||||||
let asdf (_ : DiscordClient) (event : DSharpPlus.EventArgs.InteractionCreateEventArgs) =
|
let asdf (_ : DiscordClient) (event : DSharpPlus.EventArgs.InteractionCreateEventArgs) =
|
||||||
async {
|
async {
|
||||||
@ -90,21 +93,25 @@ let asdf (_ : DiscordClient) (event : DSharpPlus.EventArgs.InteractionCreateEven
|
|||||||
:> Task
|
:> Task
|
||||||
//hackerBattleBot.add_InteractionCreated(AsyncEventHandler(asdf))
|
//hackerBattleBot.add_InteractionCreated(AsyncEventHandler(asdf))
|
||||||
|
|
||||||
|
slotsBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
|
||||||
|
//hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
//GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser
|
||||||
|
|
||||||
|
//storeBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
//GuildEnvironment.botUserArmory <- Some storeBot.CurrentUser
|
||||||
|
|
||||||
|
//inviterBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
//GuildEnvironment.botClientRecruit <- Some inviterBot
|
||||||
|
|
||||||
|
|
||||||
|
//adminBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
//stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
|
||||||
//if guild <> 922419263275425832uL then
|
//if guild <> 922419263275425832uL then
|
||||||
// Trainer.sendInitialEmbed hackerBattleBot
|
// Trainer.sendInitialEmbed hackerBattleBot
|
||||||
// InviteTracker.sendInitialEmbed inviterBot
|
// InviteTracker.sendInitialEmbed inviterBot
|
||||||
|
SlotMachine.sendInitialEmbed slotsBot
|
||||||
hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
|
||||||
GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser
|
|
||||||
|
|
||||||
storeBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
|
||||||
GuildEnvironment.botUserArmory <- Some storeBot.CurrentUser
|
|
||||||
|
|
||||||
inviterBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
|
||||||
GuildEnvironment.botClientRecruit <- Some inviterBot
|
|
||||||
|
|
||||||
adminBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
|
||||||
//stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
|
||||||
|
|
||||||
let rec loop areBotsRunning =
|
let rec loop areBotsRunning =
|
||||||
async {
|
async {
|
||||||
|
@ -103,7 +103,7 @@ let tryFindPlayer (discordId : uint64) = async {
|
|||||||
return None
|
return None
|
||||||
}
|
}
|
||||||
|
|
||||||
let updatePlayerCurrency addAmount (player : PlayerData) =
|
let updatePlayerCurrency (addAmount : int<GBT>) (player : PlayerData) =
|
||||||
connStr
|
connStr
|
||||||
|> Sql.connect
|
|> Sql.connect
|
||||||
|> Sql.parameters [
|
|> Sql.parameters [
|
||||||
@ -257,7 +257,7 @@ let getWhitelistItem () =
|
|||||||
|> Sql.query """
|
|> Sql.query """
|
||||||
SELECT stock, price FROM item WHERE symbol = 'WHITELIST'
|
SELECT stock, price FROM item WHERE symbol = 'WHITELIST'
|
||||||
"""
|
"""
|
||||||
|> Sql.executeRowAsync (fun read -> {| Stock = read.int "stock" ; Price = read.int "price" |})
|
|> Sql.executeRowAsync (fun read -> {| Stock = read.int "stock" ; Price = (read.int "price") * 1<GBT> |})
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
let updateWhitelistStock () = async {
|
let updateWhitelistStock () = async {
|
||||||
|
@ -1,76 +1,202 @@
|
|||||||
module Degenz.SlotMachine
|
module Degenz.SlotMachine
|
||||||
|
|
||||||
open System
|
open System
|
||||||
|
open System.IO
|
||||||
|
open System.Threading.Tasks
|
||||||
open DSharpPlus
|
open DSharpPlus
|
||||||
open DSharpPlus.Entities
|
open DSharpPlus.Entities
|
||||||
|
open DSharpPlus.EventArgs
|
||||||
open DSharpPlus.SlashCommands
|
open DSharpPlus.SlashCommands
|
||||||
open Degenz.Messaging
|
open Degenz.Messaging
|
||||||
open Degenz.Types
|
open Degenz.Types
|
||||||
|
|
||||||
let slots = [| "https://i.ibb.co/pKqZdr7/cherry.png" ; "https://i.ibb.co/JnghQsL/lemon.jpg" ; "https://i.ibb.co/1JTFPSs/seven.png" |]
|
let slots =
|
||||||
|
// [|
|
||||||
|
// "https://s7.gifyu.com/images/A-bottle-of-pills.png"
|
||||||
|
// "https://s7.gifyu.com/images/an-eye.png"
|
||||||
|
// "https://s7.gifyu.com/images/anon-face-mask.png"
|
||||||
|
// "https://s7.gifyu.com/images/a-piece-of-sushi.png"
|
||||||
|
// "https://s7.gifyu.com/images/Circuit-board.png"
|
||||||
|
// "https://s7.gifyu.com/images/OBEY.png"
|
||||||
|
// "https://s7.gifyu.com/images/old-tv-screen.png"
|
||||||
|
// "https://s7.gifyu.com/images/pizza.png"
|
||||||
|
// "https://s7.gifyu.com/images/ramen.png"
|
||||||
|
// "https://s7.gifyu.com/images/rat.png"
|
||||||
|
//|]
|
||||||
|
[|
|
||||||
|
"https://s7.gifyu.com/images/A-bottle-of-pills0a3006d0170e08df.png"
|
||||||
|
"https://s7.gifyu.com/images/an-eyec362d8152ae2382b.png"
|
||||||
|
"https://s7.gifyu.com/images/anon-face-mask6c7624821c89fc08.png"
|
||||||
|
"https://s7.gifyu.com/images/a-piece-of-sushi77071d30f60a89c6.png"
|
||||||
|
"https://s7.gifyu.com/images/Circuit-board89056017b80f1d13.png"
|
||||||
|
"https://s7.gifyu.com/images/OBEYf2a8234109836c03.png"
|
||||||
|
"https://s7.gifyu.com/images/old-tv-screendc6bc9d4b6c1fd65.png"
|
||||||
|
"https://s7.gifyu.com/images/pizza030ffc00ff50da0e.png"
|
||||||
|
"https://s7.gifyu.com/images/ramen08336d448018c98f.png"
|
||||||
|
"https://s7.gifyu.com/images/rat14f65f54f0d75036.png"
|
||||||
|
|]
|
||||||
|
let slotsLocal =
|
||||||
|
[|
|
||||||
|
"/home/joe/Development/DegenzGame/Images/SlotMachine/new/A bottle of pills.png"
|
||||||
|
"/home/joe/Development/DegenzGame/Images/SlotMachine/new/a piece of sushi.png"
|
||||||
|
"/home/joe/Development/DegenzGame/Images/SlotMachine/new/an eye.png"
|
||||||
|
"/home/joe/Development/DegenzGame/Images/SlotMachine/new/anon face mask.png"
|
||||||
|
"/home/joe/Development/DegenzGame/Images/SlotMachine/new/Circuit board.png"
|
||||||
|
"/home/joe/Development/DegenzGame/Images/SlotMachine/new/OBEY.png"
|
||||||
|
"/home/joe/Development/DegenzGame/Images/SlotMachine/new/old tv screen.png"
|
||||||
|
"/home/joe/Development/DegenzGame/Images/SlotMachine/new/pizza.png"
|
||||||
|
"/home/joe/Development/DegenzGame/Images/SlotMachine/new/ramen.png"
|
||||||
|
"/home/joe/Development/DegenzGame/Images/SlotMachine/new/rat.png"
|
||||||
|
|]
|
||||||
|
|
||||||
type SlotMachine() =
|
let PlayPrice = 10<GBT>
|
||||||
inherit ApplicationCommandModule ()
|
let twoOfAKindPrize = 100<GBT>
|
||||||
|
let threeOfAKindPrize = 1000<GBT>
|
||||||
|
let fourOfAKindPrize = 10000<GBT>
|
||||||
|
|
||||||
[<SlashCommand("spin", "Want to try your luck?")>]
|
let spin (ctx : IDiscordContext) =
|
||||||
member this.Spin (ctx : InteractionContext) =
|
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
||||||
PlayerInteractions.executePlayerAction (DiscordInteractionContext ctx) (fun player -> async {
|
|
||||||
let sleepTime = 1000
|
let sleepTime = 1000
|
||||||
let random = Random(System.Guid.NewGuid().GetHashCode())
|
let random = Random(System.Guid.NewGuid().GetHashCode())
|
||||||
let results = [ random.Next(0, 3) ; random.Next(0, 3) ; random.Next(0, 3)]
|
let slotCount = slots.Length
|
||||||
|
let results = [ random.Next(0, slotCount) ; random.Next(0, slotCount) ; random.Next(0, slotCount) ]
|
||||||
|
|
||||||
let winConditions = (results.[0] = results.[1] && results.[0] = results.[2])
|
let winConditions = (results.[0] = results.[1] && results.[0] = results.[2])
|
||||||
|| (results.[0] <> results.[1] && results.[1] <> results.[2] && results.[0] <> results.[2])
|
|| (results.[0] <> results.[1] && results.[1] <> results.[2] && results.[0] <> results.[2])
|
||||||
|
|
||||||
if winConditions then
|
if winConditions
|
||||||
do! DbService.updatePlayer { player with Bank = player.Bank + 10<GBT> }
|
then do! DbService.updatePlayerCurrency twoOfAKindPrize player |> Async.Ignore
|
||||||
|> Async.Ignore
|
else do! DbService.updatePlayerCurrency -PlayPrice player |> Async.Ignore
|
||||||
else
|
|
||||||
do! DbService.updatePlayer { player with Bank = max (player.Bank - 1<GBT>) 0<GBT> }
|
|
||||||
|> Async.Ignore
|
|
||||||
|
|
||||||
|
let embed1 = DiscordEmbedBuilder()
|
||||||
|
embed1.ImageUrl <- slots.[results.[0]]
|
||||||
|
let embed2 = DiscordEmbedBuilder()
|
||||||
|
embed2.ImageUrl <- slots.[results.[1]]
|
||||||
|
let embed3 = DiscordEmbedBuilder()
|
||||||
|
embed3.ImageUrl <- slots.[results.[2]]
|
||||||
|
let embed4 = DiscordEmbedBuilder()
|
||||||
|
embed4.Title <- "Slot Machine"
|
||||||
|
embed4.Description <- "You hit the jackpot!"
|
||||||
|
|
||||||
do! ctx.Interaction.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource)
|
let iCtx = ctx.GetInteraction()
|
||||||
|> Async.AwaitTask
|
|
||||||
|
|
||||||
do! Async.Sleep sleepTime
|
|
||||||
let builder = DiscordFollowupMessageBuilder()
|
let builder = DiscordFollowupMessageBuilder()
|
||||||
let embed = DiscordEmbedBuilder()
|
// let embed = DiscordEmbedBuilder()
|
||||||
embed.ImageUrl <- slots.[results.[0]]
|
// embed.ImageUrl <- slots.[results.[0]]
|
||||||
builder.AddEmbed(embed.Build()) |> ignore
|
// builder.AddEmbed(embed.Build()) |> ignore
|
||||||
do! ctx.Interaction.CreateFollowupMessageAsync(builder)
|
|
||||||
|> Async.AwaitTask
|
|
||||||
|> Async.Ignore
|
|
||||||
|
|
||||||
do! Async.Sleep sleepTime
|
builder.Content <- "Spinning!"
|
||||||
let builder = DiscordFollowupMessageBuilder()
|
builder.IsEphemeral <- true
|
||||||
embed.ImageUrl <- slots.[results.[1]]
|
|
||||||
builder.AddEmbed(embed.Build()) |> ignore
|
|
||||||
do! ctx.Interaction.CreateFollowupMessageAsync(builder)
|
|
||||||
|> Async.AwaitTask
|
|
||||||
|> Async.Ignore
|
|
||||||
|
|
||||||
do! Async.Sleep sleepTime
|
let! followUp = iCtx.CreateFollowupMessageAsync(builder) |> Async.AwaitTask
|
||||||
let builder = DiscordFollowupMessageBuilder()
|
do! Async.Sleep 1500
|
||||||
embed.ImageUrl <- slots.[results.[2]]
|
use f1 = new FileStream(slotsLocal.[0], FileMode.Open)
|
||||||
builder.AddEmbed(embed.Build()) |> ignore
|
let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddFile(f1)) |> Async.AwaitTask
|
||||||
do! ctx.Interaction.CreateFollowupMessageAsync(builder)
|
do! Async.Sleep 1500
|
||||||
|> Async.AwaitTask
|
use f2 = new FileStream(slotsLocal.[1], FileMode.Open)
|
||||||
|> Async.Ignore
|
let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddFile(f2)) |> Async.AwaitTask
|
||||||
|
do! Async.Sleep 1500
|
||||||
|
use f3 = new FileStream(slotsLocal.[2], FileMode.Open)
|
||||||
|
let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddFile(f3)) |> Async.AwaitTask
|
||||||
|
|
||||||
if winConditions then
|
do! Async.Sleep 1500
|
||||||
do! Async.Sleep sleepTime
|
|
||||||
let builder = DiscordFollowupMessageBuilder()
|
let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbed(embed1)) |> Async.AwaitTask
|
||||||
builder.Content <- "You win 10 GBT!"
|
do! Async.Sleep 1500
|
||||||
do! ctx.Interaction.CreateFollowupMessageAsync(builder)
|
let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbeds([embed1.Build() ; embed2.Build()])) |> Async.AwaitTask
|
||||||
|> Async.AwaitTask
|
do! Async.Sleep 1500
|
||||||
|> Async.Ignore
|
let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbeds([embed1.Build() ; embed2.Build() ; embed3.Build() ])) |> Async.AwaitTask
|
||||||
else
|
do! Async.Sleep 1500
|
||||||
do! Async.Sleep sleepTime
|
let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbeds([embed1.Build() ; embed2.Build() ; embed3.Build() ; embed4.Build() ])) |> Async.AwaitTask
|
||||||
let builder = DiscordFollowupMessageBuilder()
|
return ()
|
||||||
builder.Content <- "You lose 0.5 GBT! Try your luck again!"
|
|
||||||
do! ctx.Interaction.CreateFollowupMessageAsync(builder)
|
// do! Async.Sleep sleepTime
|
||||||
|> Async.AwaitTask
|
// let builder = DiscordFollowupMessageBuilder()
|
||||||
|> Async.Ignore
|
// let embed = DiscordEmbedBuilder()
|
||||||
|
// embed.ImageUrl <- slots.[results.[0]]
|
||||||
|
// builder.AddEmbed(embed.Build()) |> ignore
|
||||||
|
//
|
||||||
|
// do! Async.Sleep sleepTime
|
||||||
|
// let builder = DiscordFollowupMessageBuilder()
|
||||||
|
// embed.ImageUrl <- slots.[results.[1]]
|
||||||
|
// builder.AddEmbed(embed.Build()) |> ignore
|
||||||
|
//
|
||||||
|
// do! Async.Sleep sleepTime
|
||||||
|
// let builder = DiscordFollowupMessageBuilder()
|
||||||
|
// embed.ImageUrl <- slots.[results.[2]]
|
||||||
|
// builder.AddEmbed(embed.Build()) |> ignore
|
||||||
|
//
|
||||||
|
// if winConditions then
|
||||||
|
// do! Async.Sleep sleepTime
|
||||||
|
// let builder = DiscordFollowupMessageBuilder()
|
||||||
|
// builder.Content <- "You win 10 GBT!"
|
||||||
|
// do! ctx.FollowUp(builder)
|
||||||
|
// |> Async.AwaitTask
|
||||||
|
// |> Async.Ignore
|
||||||
|
// else
|
||||||
|
// do! Async.Sleep sleepTime
|
||||||
|
// let builder = DiscordFollowupMessageBuilder()
|
||||||
|
// builder.Content <- "You lose 0.5 GBT! Try your luck again!"
|
||||||
|
// do! ctx.FollowUp(builder)
|
||||||
|
// |> Async.AwaitTask
|
||||||
|
// |> Async.Ignore
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let handleSpin (_ : DiscordClient) (event : ComponentInteractionCreateEventArgs) =
|
||||||
|
task {
|
||||||
|
do! spin (DiscordEventContext event)
|
||||||
|
} :> Task
|
||||||
|
|
||||||
|
let spinCommand (ctx : IDiscordContext) =
|
||||||
|
async {
|
||||||
|
try
|
||||||
|
let builder = DiscordInteractionResponseBuilder()
|
||||||
|
builder.Content <- "The message"
|
||||||
|
builder.IsEphemeral <- true
|
||||||
|
let button = DiscordButtonComponent(ButtonStyle.Success, $"spin", $"Spin Me Right Around") :> DiscordComponent
|
||||||
|
builder.AddComponents [| button |] |> ignore
|
||||||
|
do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, builder)
|
||||||
|
|> Async.AwaitTask
|
||||||
|
|> Async.Ignore
|
||||||
|
with e ->
|
||||||
|
printfn $"Error trying to get channel Casino\n\n{e.Message}"
|
||||||
|
} |> Async.StartAsTask :> Task
|
||||||
|
|
||||||
|
let sendInitialEmbed (client : DiscordClient) =
|
||||||
|
async {
|
||||||
|
try
|
||||||
|
let! channel = client.GetChannelAsync(961472561319903352uL) |> Async.AwaitTask
|
||||||
|
let builder = DiscordMessageBuilder()
|
||||||
|
let embed = DiscordEmbedBuilder()
|
||||||
|
embed.Title <- "Degenz Slot Machine"
|
||||||
|
embed.Description <- "Hello I am an embed"
|
||||||
|
embed.ImageUrl <- "https://i.kym-cdn.com/photos/images/original/001/169/608/a43.gif"
|
||||||
|
|
||||||
|
builder.AddEmbed(embed) |> ignore
|
||||||
|
|
||||||
|
let button = DiscordButtonComponent(ButtonStyle.Success, $"spin", $"Spin Me Right Around") :> DiscordComponent
|
||||||
|
builder.AddComponents [| button |] |> ignore
|
||||||
|
do! channel.SendMessageAsync(builder)
|
||||||
|
|> Async.AwaitTask
|
||||||
|
|> Async.Ignore
|
||||||
|
with e ->
|
||||||
|
printfn $"Error trying to get channel Training Dojo\n\n{e.Message}"
|
||||||
|
} |> Async.RunSynchronously
|
||||||
|
|
||||||
|
type SlotMachine() =
|
||||||
|
inherit ApplicationCommandModule ()
|
||||||
|
|
||||||
|
let enforceChannel (ctx : IDiscordContext) (spinFn : IDiscordContext -> Task) =
|
||||||
|
match ctx.GetChannel().Id with
|
||||||
|
| id when id = 961472561319903352uL -> spinFn ctx
|
||||||
|
| _ ->
|
||||||
|
task {
|
||||||
|
let msg = $"You must go to <#961472561319903352> channel to spin"
|
||||||
|
do! Messaging.sendSimpleResponse ctx msg
|
||||||
|
}
|
||||||
|
|
||||||
|
[<SlashCommand("spin", "Want to try your luck?")>]
|
||||||
|
member this.Spin (ctx : InteractionContext) = enforceChannel (DiscordInteractionContext ctx) spinCommand
|
||||||
|
|
||||||
|
[<SlashCommand("spin-simple", "Want to try your luck?")>]
|
||||||
|
member this.SpinSimple (ctx : InteractionContext) = enforceChannel (DiscordInteractionContext ctx) spin
|
||||||
|
@ -22,6 +22,7 @@ let tokenSteal = getVar "TOKEN_STEAL"
|
|||||||
let tokenHackerBattle = getVar "TOKEN_HACKER_BATTLE"
|
let tokenHackerBattle = getVar "TOKEN_HACKER_BATTLE"
|
||||||
let tokenStore = getVar "TOKEN_STORE"
|
let tokenStore = getVar "TOKEN_STORE"
|
||||||
let tokenInviter = getVar "TOKEN_INVITER"
|
let tokenInviter = getVar "TOKEN_INVITER"
|
||||||
|
let tokenSlots = getVar "TOKEN_SLOTS"
|
||||||
let tokenAdmin = getVar "TOKEN_ADMINBOT"
|
let tokenAdmin = getVar "TOKEN_ADMINBOT"
|
||||||
let tokenMixpanel = getVar "TOKEN_MIXPANEL"
|
let tokenMixpanel = getVar "TOKEN_MIXPANEL"
|
||||||
let channelEventsHackerBattle = getId "CHANNEL_EVENTS_HACKER_BATTLE"
|
let channelEventsHackerBattle = getId "CHANNEL_EVENTS_HACKER_BATTLE"
|
||||||
|
@ -301,7 +301,7 @@ let acceptInvite (ctx : IDiscordContext) (invitedPlayer : PlayerData) =
|
|||||||
let! player = DbService.tryFindPlayer invite.Inviter
|
let! player = DbService.tryFindPlayer invite.Inviter
|
||||||
match player with
|
match player with
|
||||||
| Some player ->
|
| Some player ->
|
||||||
do! DbService.updatePlayerCurrency (int InviteRewardAmount) player |> Async.Ignore
|
do! DbService.updatePlayerCurrency InviteRewardAmount player |> Async.Ignore
|
||||||
do! match GuildEnvironment.botClientRecruit with
|
do! match GuildEnvironment.botClientRecruit with
|
||||||
| Some recruitBot -> async {
|
| Some recruitBot -> async {
|
||||||
let builder = DiscordMessageBuilder()
|
let builder = DiscordMessageBuilder()
|
||||||
@ -341,13 +341,13 @@ Your NFT will be your In-Game Character that provides you with unique traits, an
|
|||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|> Async.Ignore
|
|> Async.Ignore
|
||||||
with e ->
|
with e ->
|
||||||
printfn $"Error trying to get channel Training Dojo\n\n{e.Message}"
|
printfn $"Error trying to get channel Whitelist\n\n{e.Message}"
|
||||||
} |> Async.RunSynchronously
|
} |> Async.RunSynchronously
|
||||||
|
|
||||||
type WhitelistResult =
|
type WhitelistResult =
|
||||||
| NotInGame
|
| NotInGame
|
||||||
| NotAHacker
|
| NotAHacker
|
||||||
| NotEnoughGBT of currentAmount : int
|
| NotEnoughGBT of currentAmount : int<GBT>
|
||||||
| NotEnoughStock
|
| NotEnoughStock
|
||||||
| Granted of PlayerData
|
| Granted of PlayerData
|
||||||
| AlreadyWhitelisted
|
| AlreadyWhitelisted
|
||||||
@ -360,12 +360,12 @@ let tryGrantWhitelist (ctx : IDiscordContext) stock price =
|
|||||||
let hasWhitelist = Seq.contains (ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)) user.Roles
|
let hasWhitelist = Seq.contains (ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)) user.Roles
|
||||||
let isHacker = Seq.contains (ctx.GetGuild().GetRole(GuildEnvironment.roleHacker)) user.Roles
|
let isHacker = Seq.contains (ctx.GetGuild().GetRole(GuildEnvironment.roleHacker)) user.Roles
|
||||||
|
|
||||||
match hasWhitelist , player.Active , isHacker , stock > 0 , int player.Bank >= price with
|
match hasWhitelist , player.Active , isHacker , stock > 0 , player.Bank >= price with
|
||||||
| true , _ , _ , _ , _ -> return AlreadyWhitelisted
|
| true , _ , _ , _ , _ -> return AlreadyWhitelisted
|
||||||
| _ , false , _ , _ , _ -> return NotInGame
|
| _ , false , _ , _ , _ -> return NotInGame
|
||||||
| _ , _ , false , _ , _ -> return NotAHacker
|
| _ , _ , false , _ , _ -> return NotAHacker
|
||||||
| _ , _ , _ , false , _ -> return NotEnoughStock
|
| _ , _ , _ , false , _ -> return NotEnoughStock
|
||||||
| _ , _ , _ , _ , false -> return NotEnoughGBT (int player.Bank)
|
| _ , _ , _ , _ , false -> return NotEnoughGBT player.Bank
|
||||||
| _ , _ , _ , _ , _ -> return Granted player
|
| _ , _ , _ , _ , _ -> return Granted player
|
||||||
| None -> return NotInGame
|
| None -> return NotInGame
|
||||||
}
|
}
|
||||||
@ -505,7 +505,7 @@ let handleBuyWhitelist (ctx : IDiscordContext) =
|
|||||||
embed.Color <- DiscordColor.Green
|
embed.Color <- DiscordColor.Green
|
||||||
|
|
||||||
let recruitBtn = DiscordButtonComponent(ButtonStyle.Danger, $"ShowRecruitmentEmbed", $"Recruit Now") :> DiscordComponent
|
let recruitBtn = DiscordButtonComponent(ButtonStyle.Danger, $"ShowRecruitmentEmbed", $"Recruit Now") :> DiscordComponent
|
||||||
builder.AddComponents ([ recruitBtn ]) |> ignore
|
builder.AddComponents [ recruitBtn ] |> ignore
|
||||||
let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)
|
let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)
|
||||||
do! ctx.GetDiscordMember().GrantRoleAsync(role)
|
do! ctx.GetDiscordMember().GrantRoleAsync(role)
|
||||||
let! _ = DbService.updatePlayerCurrency -wlItem.Price player
|
let! _ = DbService.updatePlayerCurrency -wlItem.Price player
|
||||||
|
@ -23,6 +23,7 @@ type IDiscordContext =
|
|||||||
abstract member FollowUp : DiscordFollowupMessageBuilder -> Task
|
abstract member FollowUp : DiscordFollowupMessageBuilder -> Task
|
||||||
abstract member GetDiscordMember : unit -> DiscordMember
|
abstract member GetDiscordMember : unit -> DiscordMember
|
||||||
abstract member GetGuild : unit -> DiscordGuild
|
abstract member GetGuild : unit -> DiscordGuild
|
||||||
|
abstract member GetInteraction : unit -> DiscordInteraction
|
||||||
abstract member GetInteractionId : unit -> string
|
abstract member GetInteractionId : unit -> string
|
||||||
abstract member GetChannel : unit -> DiscordChannel
|
abstract member GetChannel : unit -> DiscordChannel
|
||||||
abstract member GetContext : unit -> obj
|
abstract member GetContext : unit -> obj
|
||||||
@ -43,6 +44,7 @@ type DiscordInteractionContext(ctx : InteractionContext) =
|
|||||||
} |> Async.StartAsTask :> Task
|
} |> Async.StartAsTask :> Task
|
||||||
member this.GetDiscordMember() = ctx.Member
|
member this.GetDiscordMember() = ctx.Member
|
||||||
member this.GetGuild() = ctx.Guild
|
member this.GetGuild() = ctx.Guild
|
||||||
|
member this.GetInteraction() = ctx.Interaction
|
||||||
member this.GetInteractionId() = string ctx.InteractionId
|
member this.GetInteractionId() = string ctx.InteractionId
|
||||||
member this.GetChannel() = ctx.Channel
|
member this.GetChannel() = ctx.Channel
|
||||||
member this.GetContext() = ctx
|
member this.GetContext() = ctx
|
||||||
@ -63,6 +65,7 @@ type DiscordEventContext(ctx : ComponentInteractionCreateEventArgs) =
|
|||||||
} |> Async.StartAsTask :> Task
|
} |> Async.StartAsTask :> Task
|
||||||
member this.GetDiscordMember() = ctx.User :?> DiscordMember
|
member this.GetDiscordMember() = ctx.User :?> DiscordMember
|
||||||
member this.GetGuild() = ctx.Guild
|
member this.GetGuild() = ctx.Guild
|
||||||
|
member this.GetInteraction() = ctx.Interaction
|
||||||
member this.GetInteractionId() = ctx.Id
|
member this.GetInteractionId() = ctx.Id
|
||||||
member this.GetChannel() = ctx.Channel
|
member this.GetChannel() = ctx.Channel
|
||||||
member this.GetContext() = ctx
|
member this.GetContext() = ctx
|
||||||
|
Loading…
x
Reference in New Issue
Block a user