diff --git a/Bot/Admin.fs b/Bot/Admin.fs index b55251b..fb0cca8 100644 --- a/Bot/Admin.fs +++ b/Bot/Admin.fs @@ -8,6 +8,11 @@ open DSharpPlus.SlashCommands open DSharpPlus.SlashCommands.Attributes open Degenz.Messaging +type InitEmbeds = + | Dojo = 0 + | Whitelist = 1 + | Slots = 2 + let handleGuildDownloadReady (_ : DiscordClient) (event : GuildDownloadCompletedEventArgs) = task { let ( _ , guild ) = event.Guilds.TryGetValue(GuildEnvironment.guildId) @@ -19,6 +24,16 @@ let handleGuildDownloadReady (_ : DiscordClient) (event : GuildDownloadCompleted do! guild.BatchEditApplicationCommandPermissionsAsync(commands) |> Async.AwaitTask |> Async.Ignore } :> Task +let sendEmbed embed (ctx : IDiscordContext) = + task { + match embed with + | InitEmbeds.Dojo -> Trainer.sendInitialEmbed ctx + | InitEmbeds.Whitelist -> InviteTracker.sendInitialEmbed ctx + | InitEmbeds.Slots -> SlotMachine.sendInitialEmbed ctx + | _ -> () + do! Messaging.sendSimpleResponse ctx "Sent!" + } :> Task + type AdminBot() = inherit ApplicationCommandModule () @@ -36,3 +51,9 @@ type AdminBot() = [] member this.SetStock (ctx : InteractionContext, [] amount : int64) = enforceAdmin (DiscordInteractionContext ctx) (InviteTracker.setWhitelistStock (int amount)) + + [] + member this.SendEmbedToChannel (ctx : InteractionContext, [] embed : InitEmbeds) = + enforceAdmin (DiscordInteractionContext ctx) (sendEmbed embed) + + diff --git a/Bot/Bot.fs b/Bot/Bot.fs index 78cf38d..f8cb229 100644 --- a/Bot/Bot.fs +++ b/Bot/Bot.fs @@ -65,7 +65,7 @@ hackerCommands.RegisterCommands(guild); storeCommands.RegisterCommands(guild); stealCommands.RegisterCommands(guild); inviterCommands.RegisterCommands(guild); -slotsCommands.RegisterCommands(guild); +//slotsCommands.RegisterCommands(guild); adminCommands.RegisterCommands(guild) hackerBattleBot.add_ComponentInteractionCreated(AsyncEventHandler(HackerBattle.handleButtonEvent)) @@ -93,25 +93,22 @@ let asdf (_ : DiscordClient) (event : DSharpPlus.EventArgs.InteractionCreateEven :> Task //hackerBattleBot.add_InteractionCreated(AsyncEventHandler(asdf)) +slotsBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously +GuildEnvironment.botClientSlots <- Some slotsBot + hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously -GuildEnvironment.botUserHackerBattle <- Some hackerBattleBot.CurrentUser +GuildEnvironment.botClientHacker <- Some hackerBattleBot storeBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously -GuildEnvironment.botUserArmory <- Some storeBot.CurrentUser +//GuildEnvironment.botClient <- Some storeBot.CurrentUser inviterBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously GuildEnvironment.botClientRecruit <- Some inviterBot -//slotsBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously +adminBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously -//adminBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously //stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously -//if guild <> 922419263275425832uL then -// Trainer.sendInitialEmbed hackerBattleBot -// InviteTracker.sendInitialEmbed inviterBot -//SlotMachine.sendInitialEmbed slotsBot - let rec loop areBotsRunning = async { if not (File.Exists "fsharp-bots") then diff --git a/Bot/Bot.fsproj b/Bot/Bot.fsproj index e7fe963..ecba81f 100644 --- a/Bot/Bot.fsproj +++ b/Bot/Bot.fsproj @@ -30,6 +30,54 @@ + + images\oldtv.png + PreserveNewest + + + images\sushi.png + PreserveNewest + + + images\aneye.png + PreserveNewest + + + images\anonmask.png + PreserveNewest + + + images\obey.png + PreserveNewest + + + images\circuitboard.png + PreserveNewest + + + images\pills.png + PreserveNewest + + + images\rat.png + PreserveNewest + + + images\ramen.png + PreserveNewest + + + images\pizza.png + PreserveNewest + + + images\alcohol.png + PreserveNewest + + + images\bigbrother.png + PreserveNewest + \ No newline at end of file diff --git a/Bot/Embeds.fs b/Bot/Embeds.fs index d86644b..6496a43 100644 --- a/Bot/Embeds.fs +++ b/Bot/Embeds.fs @@ -127,11 +127,11 @@ let getArsenalEmbed (player : PlayerData) = let getAchievementEmbed rewards description achievement = let embed = DiscordEmbedBuilder() - GuildEnvironment.botUserHackerBattle + GuildEnvironment.botClientHacker |> Option.iter (fun bot -> embed.Author <- DiscordEmbedBuilder.EmbedAuthor() - embed.Author.Name <- bot.Username - embed.Author.IconUrl <- bot.AvatarUrl) + embed.Author.Name <- bot.CurrentUser.Username + embed.Author.IconUrl <- bot.CurrentUser.AvatarUrl) DiscordFollowupMessageBuilder() .AddEmbed( diff --git a/Bot/Games/SlotMachine.fs b/Bot/Games/SlotMachine.fs index 38fe33e..c4b95e3 100644 --- a/Bot/Games/SlotMachine.fs +++ b/Bot/Games/SlotMachine.fs @@ -10,56 +10,72 @@ open DSharpPlus.SlashCommands open Degenz.Messaging open Degenz.Types -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" -//|] +type SlotSymbols = + | Eye + | AnonMask + | CircuitBoard + | Obey + | OldTv + | Pills + | Pizza + | Ramen + | Rat + | Alcohol + | BigBrother + | Sushi - [| - "<:sushi:>" - "<:pizza:>" - "<:ramen:>" - "<:circuitboard:>" - "<:obey:>" - "<:pills:>" - "<:oldtv:>" - "<:rat:>" - "<:aneye:>" - "<:anon:>" -|] -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" +let slots = + [| "https://s7.gifyu.com/images/aneye.png" + "https://s7.gifyu.com/images/anonmask.png" + "https://s7.gifyu.com/images/circuitboard.png" + "https://s7.gifyu.com/images/obey.png" + "https://s7.gifyu.com/images/oldtv.png" + "https://s7.gifyu.com/images/pills.png" + "https://s7.gifyu.com/images/pizza0d47578733961746.png" + "https://s7.gifyu.com/images/ramen0515f00869e1f4eb.png" + "https://s7.gifyu.com/images/rat69609f842a0eb9f5.png" + "https://s7.gifyu.com/images/alcohol.png" + "https://s7.gifyu.com/images/bigbrother.png" + "https://s7.gifyu.com/images/sushi.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 slotEmojis = + [| "<:sushi:>" + "<:pizza:>" + "<:ramen:>" + "<:circuitboard:>" + "<:obey:>" + "<:pills:>" + "<:oldtv:>" + "<:rat:>" + "<:aneye:>" + "<:anon:>" |] + +let slotsImages = + [| "./images/anonmask.png" + "./images/circuitboard.png" + "./images/aneye.png" + "./images/obey.png" + "./images/oldtv.png" + "./images/pills.png" + "./images/pizza.png" + "./images/ramen.png" + "./images/rat.png" + "./images/bigbrother.png" + "./images/alcohol.png" + "./images/sushi.png" |] + |> Array.map (fun path -> ( Path.GetFileNameWithoutExtension(path) , File.OpenRead(path) )) + +let payTable = [| |] let PlayPrice = 10 @@ -67,12 +83,84 @@ let twoOfAKindPrize = 100 let threeOfAKindPrize = 1000 let fourOfAKindPrize = 10000 -let spin (ctx : IDiscordContext) = - PlayerInteractions.executePlayerAction ctx (fun player -> async { - let sleepTime = 1000 +let spinEmbeds (results : int array) (ctx : IDiscordContext) = + async { + let iCtx = ctx.GetInteraction() + + let builder = DiscordFollowupMessageBuilder() + + builder.Content <- "Spinning!" + builder.IsEphemeral <- true + + let e1 = DiscordEmbedBuilder().WithImageUrl(slots.[results[0]]) + let e2 = DiscordEmbedBuilder().WithImageUrl(slots.[results[1]]) + let e3 = DiscordEmbedBuilder().WithImageUrl(slots.[results[2]]) + + let! followUp = iCtx.CreateFollowupMessageAsync(builder) |> Async.AwaitTask + do! Async.Sleep 1000 + let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbeds([ e1.Build() ])) |> Async.AwaitTask + do! Async.Sleep 1000 + let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbeds([ e1.Build() ; e2.Build() ])) |> Async.AwaitTask + do! Async.Sleep 1000 + let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbeds([ e1.Build() ; e2.Build() ; e3.Build() ])) |> Async.AwaitTask + do! Async.Sleep 1000 + let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().AddEmbeds([ e1.Build() ; e2.Build() ; e3.Build() ])) |> Async.AwaitTask + + return () + } + +let spinEmojis (results : int array) (ctx : IDiscordContext) = + async { + let inter = ctx.GetInteraction() + let emojis = ctx.GetGuild().Emojis |> Seq.map (fun kvp -> kvp.Value) |> Seq.toArray + let builder = DiscordFollowupMessageBuilder() + + builder.Content <- "Spinning!" + builder.IsEphemeral <- true + let! followUp = inter.CreateFollowupMessageAsync(builder) |> Async.AwaitTask + + do! Async.Sleep 1000 + let content = $"{Formatter.Emoji(emojis.[results.[0]])}" + let! _ = inter.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().WithContent(content)) |> Async.AwaitTask + do! Async.Sleep 1000 + let content = $"{Formatter.Emoji(emojis.[results.[0]])}{Formatter.Emoji(emojis.[results.[1]])}" + let! _ = inter.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().WithContent(content)) |> Async.AwaitTask + do! Async.Sleep 1000 + let content = $"{Formatter.Emoji(emojis.[results.[0]])}{Formatter.Emoji(emojis.[results.[1]])}{Formatter.Emoji(emojis.[results.[2]])}" + let! _ = inter.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().WithContent(content)) |> Async.AwaitTask + return () + } + +let spinFiles (results : int array) (ctx : IDiscordContext) = + async { + let inter = ctx.GetInteraction() + let emojis = ctx.GetGuild().Emojis |> Seq.map (fun kvp -> kvp.Value) |> Seq.toArray + let builder = DiscordFollowupMessageBuilder() + + builder.Content <- "Spinning!" + builder.IsEphemeral <- true + let! followUp = inter.CreateFollowupMessageAsync(builder) |> Async.AwaitTask + + do! Async.Sleep 1000 + let ( name , stream ) = slotsImages.[results.[0]] + let! _ = inter.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder() + .AddFile(name + "1.png", stream)) |> Async.AwaitTask + do! Async.Sleep 1000 + let ( name , stream ) = slotsImages.[results.[1]] + let! _ = inter.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder() + .AddFile(name + "2.png", stream)) |> Async.AwaitTask + do! Async.Sleep 1000 + let ( name , stream ) = slotsImages.[results.[2]] + let! _ = inter.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder() + .AddFile(name + "3.png", stream)) |> Async.AwaitTask + return () + } + +let spin spinType (ctx : IDiscordContext) = + PlayerInteractions.executePlayerAction ctx (fun player -> async { let random = Random(System.Guid.NewGuid().GetHashCode()) let slotCount = slots.Length - let results = [ random.Next(0, slotCount) ; random.Next(0, slotCount) ; random.Next(0, slotCount) ] + let results = [| random.Next(0, slotCount) ; random.Next(0, slotCount) ; random.Next(0, slotCount) |] let winConditions = (results.[0] = results.[1] && results.[0] = results.[2]) || (results.[0] <> results.[1] && results.[1] <> results.[2] && results.[0] <> results.[2]) @@ -81,87 +169,50 @@ let spin (ctx : IDiscordContext) = then do! DbService.updatePlayerCurrency twoOfAKindPrize player |> Async.Ignore else do! DbService.updatePlayerCurrency -PlayPrice player |> 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]] + match spinType with + | "Embeds" -> do! spinEmbeds results ctx + | "Emojis" -> do! spinEmojis results ctx + | "Files" -> do! spinFiles results ctx + | _ -> () + let embed4 = DiscordEmbedBuilder() embed4.Title <- "Slot Machine" embed4.Description <- "You hit the jackpot!" - let iCtx = ctx.GetInteraction() +// 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 builder = DiscordFollowupMessageBuilder() -// let embed = DiscordEmbedBuilder() -// embed.ImageUrl <- slots.[results.[0]] -// builder.AddEmbed(embed.Build()) |> ignore - - builder.Content <- "Spinning!" - builder.IsEphemeral <- true - - let emojis = ctx.GetGuild().Emojis |> Seq.map (fun kvp -> kvp.Value) |> Seq.toArray - - - let! followUp = iCtx.CreateFollowupMessageAsync(builder) |> Async.AwaitTask - do! Async.Sleep 1500 - let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().WithContent(Formatter.Emoji(emojis.[results.[0]]))) |> Async.AwaitTask - do! Async.Sleep 1500 - let! _ = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder().WithContent($"{Formatter.Emoji(emojis.[results.[0]])}{Formatter.Emoji(emojis.[results.[1]])}")) |> Async.AwaitTask - do! Async.Sleep 1500 - let! asdf = iCtx.EditFollowupMessageAsync(followUp.Id, DiscordWebhookBuilder() - .WithContent($"{Formatter.Emoji(emojis.[results.[0]])}{Formatter.Emoji(emojis.[results.[1]])}{Formatter.Emoji(emojis.[results.[2]])}") - .AddEmbed(embed4) - ) |> Async.AwaitTask - do! Async.Sleep 1500 - - let builder = DiscordFollowupMessageBuilder() - builder.AddEmbeds([ embed4.Build() ]) |> ignore - builder.IsEphemeral <- true -// let! _ = iCtx.CreateFollowupMessageAsync(builder) |> Async.AwaitTask return () - -// 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) = + let ctx = DiscordEventContext event task { - do! spin (DiscordEventContext event) + match event.Id with + | "spin-embeds" -> do! spin "Embeds" ctx + | "spin-emojis" -> do! spin "Emojis" ctx + | "spin-files" -> do! spin "Files" ctx + | _ -> + printfn "Wrong Spin ID" + return () } :> Task -let spinCommand (ctx : IDiscordContext) = +let sendInitialEmbed (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 channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelSlots) let builder = DiscordMessageBuilder() let embed = DiscordEmbedBuilder() embed.Title <- "Degenz Slot Machine" @@ -170,29 +221,31 @@ let sendInitialEmbed (client : DiscordClient) = builder.AddEmbed(embed) |> ignore - let button = DiscordButtonComponent(ButtonStyle.Success, $"spin", $"Spin Me Right Around") :> DiscordComponent - builder.AddComponents [| button |] |> ignore - do! channel.SendMessageAsync(builder) + let button1 = DiscordButtonComponent(ButtonStyle.Success, $"spin-embeds", $"Spin Embeds 1 $GBT") :> DiscordComponent + let button2 = DiscordButtonComponent(ButtonStyle.Success, $"spin-emojis", $"Spin Emojis 5 $GBT") :> DiscordComponent + let button3 = DiscordButtonComponent(ButtonStyle.Success, $"spin-files", $"Spin Files 10 $GBT") :> DiscordComponent + builder.AddComponents [| button1 ; button2 ; button3 |] |> ignore + do! GuildEnvironment.botClientSlots.Value.SendMessageAsync(channel, 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 - } - - [] - member this.Spin (ctx : InteractionContext) = enforceChannel (DiscordInteractionContext ctx) spinCommand - - [] - member this.SpinSimple (ctx : InteractionContext) = enforceChannel (DiscordInteractionContext ctx) spin +//type SlotMachine() = +// inherit ApplicationCommandModule () +// +// let enforceChannel (ctx : IDiscordContext) (spinFn : IDiscordContext -> Task) = +// match ctx.GetChannel().Id with +// | id when id = GuildEnvironment.channelSlots -> spinFn ctx +// | _ -> +// task { +// let msg = $"You must go to <#{GuildEnvironment.channelSlots}> channel to play the slots!" +// do! Messaging.sendSimpleResponse ctx msg +// } +// +// [] +// member this.Spin (ctx : InteractionContext) = enforceChannel (DiscordInteractionContext ctx) spinCommand +// +// [] +// member this.SpinSimple (ctx : InteractionContext) = enforceChannel (DiscordInteractionContext ctx) spin diff --git a/Bot/Games/Trainer.fs b/Bot/Games/Trainer.fs index 7f7a562..4549a86 100644 --- a/Bot/Games/Trainer.fs +++ b/Bot/Games/Trainer.fs @@ -36,10 +36,10 @@ let ShieldEvents () = [ Type = Shielding (int ItemId.Cypher) } ] -let sendInitialEmbed (client : DiscordClient) = +let sendInitialEmbed (ctx : IDiscordContext) = async { try - let! channel = client.GetChannelAsync(GuildEnvironment.channelTraining) |> Async.AwaitTask + let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelTraining) let builder = DiscordMessageBuilder() let embed = DiscordEmbedBuilder() embed.ImageUrl <- "https://s10.gifyu.com/images/MasterTraining_Degenz.gif" @@ -49,7 +49,7 @@ let sendInitialEmbed (client : DiscordClient) = + "Are you ready?" let button = DiscordButtonComponent(ButtonStyle.Success, $"Trainer-1", $"LFG") :> DiscordComponent builder.AddComponents [| button |] |> ignore - do! channel.SendMessageAsync(builder) + do! GuildEnvironment.botClientHacker.Value.SendMessageAsync(channel, builder) |> Async.AwaitTask |> Async.Ignore with e -> diff --git a/Bot/GuildEnvironment.fs b/Bot/GuildEnvironment.fs index 80b0166..a384b1e 100644 --- a/Bot/GuildEnvironment.fs +++ b/Bot/GuildEnvironment.fs @@ -48,7 +48,6 @@ let roleHacker = getId "ROLE_HACKER" let rolePrisoner = getId "ROLE_PRISONER" let roleWhitelist = getId "ROLE_WHITELIST" let roleAdmin = getId "ROLE_ADMIN" - -let mutable botUserHackerBattle : DiscordUser option = None -let mutable botUserArmory : DiscordUser option = None let mutable botClientRecruit : DiscordClient option = None +let mutable botClientHacker : DiscordClient option = None +let mutable botClientSlots : DiscordClient option = None diff --git a/Bot/InviteTracker.fs b/Bot/InviteTracker.fs index d4b1de5..0dbf467 100644 --- a/Bot/InviteTracker.fs +++ b/Bot/InviteTracker.fs @@ -318,10 +318,10 @@ let acceptInvite (ctx : IDiscordContext) (invitedPlayer : PlayerData) = | true -> return () } :> Task -let sendInitialEmbed (client : DiscordClient) = +let sendInitialEmbed (ctx : IDiscordContext) = async { try - let! channel = client.GetChannelAsync(GuildEnvironment.channelWhitelist) |> Async.AwaitTask + let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelWhitelist) let builder = DiscordMessageBuilder() let embed = DiscordEmbedBuilder() embed.ImageUrl <- "https://s1.gifyu.com/images/whitelist-image-2.gif" @@ -337,7 +337,8 @@ Your NFT will be your In-Game Character that provides you with unique traits, an builder.AddEmbed embed |> ignore let button = DiscordButtonComponent(ButtonStyle.Success, $"GimmeWhitelist", $"Give Me Whitelist") :> DiscordComponent builder.AddComponents [| button |] |> ignore - do! channel.SendMessageAsync(builder) + + do! GuildEnvironment.botClientRecruit.Value.SendMessageAsync(channel, builder) |> Async.AwaitTask |> Async.Ignore with e -> @@ -538,36 +539,30 @@ let handleCreateInvite (ctx : IDiscordContext) = let! code = task { - printfn "1" let! invites = getInvitesFromUser user.Id - printfn "2" match invites |> Map.toList with | [] -> - printfn "3" - let channel = ctx.GetGuild().Channels.[GuildEnvironment.channelWelcome] - printfn "4" - let! invite = channel.CreateInviteAsync(max_age = 0, unique = true) - printfn "5" + let ( result , channel ) = ctx.GetGuild().Channels.TryGetValue(GuildEnvironment.channelWelcome) + if result then + let! invite = channel.CreateInviteAsync(max_age = 0, unique = true) - try do! createInvite (ctx.GetDiscordMember().Id) invite.Code |> Async.Ignore - with ex -> printfn "%A" ex.Message - printfn "6" + try do! createInvite (ctx.GetDiscordMember().Id) invite.Code |> Async.Ignore + with ex -> printfn "%A" ex.Message - return invite.Code + return invite.Code + else + printfn "Error finding Welcome channel" + return "" | invite::_ -> - printfn "-1" return invite |> fst } - printfn "7" let msg = DiscordFollowupMessageBuilder() .WithContent($"https://discord.gg/{code}") .AsEphemeral(true) - printfn "8" do! ctx.FollowUp(msg) - printfn "9" do! Analytics.recruitLinkButton code user.Id user.Username (ctx.GetChannel()) } :> Task