Split whitelist and recruiting, make whitelist a store
This commit is contained in:
parent
03ffe4d4a4
commit
1bd2c6b350
12
Bot/Admin.fs
12
Bot/Admin.fs
@ -14,9 +14,10 @@ open Npgsql.FSharp
|
|||||||
type InitEmbeds =
|
type InitEmbeds =
|
||||||
| Dojo = 0
|
| Dojo = 0
|
||||||
| Whitelist = 1
|
| Whitelist = 1
|
||||||
| Slots = 2
|
| Recruit = 2
|
||||||
| JpegStore = 3
|
| Slots = 3
|
||||||
| Armory = 4
|
| JpegStore = 4
|
||||||
|
| Armory = 5
|
||||||
|
|
||||||
let handleGuildDownloadReady _ (event : GuildDownloadCompletedEventArgs) =
|
let handleGuildDownloadReady _ (event : GuildDownloadCompletedEventArgs) =
|
||||||
task {
|
task {
|
||||||
@ -34,7 +35,8 @@ let sendEmbed embed (ctx : IDiscordContext) =
|
|||||||
task {
|
task {
|
||||||
match embed with
|
match embed with
|
||||||
| InitEmbeds.Dojo -> Trainer.sendInitialEmbed ctx
|
| InitEmbeds.Dojo -> Trainer.sendInitialEmbed ctx
|
||||||
| InitEmbeds.Whitelist -> InviteTracker.sendInitialEmbed ctx
|
| InitEmbeds.Whitelist -> Whitelist.sendInitialEmbed ctx
|
||||||
|
| InitEmbeds.Recruit -> InviteTracker.sendInitialEmbed ctx
|
||||||
| InitEmbeds.Slots -> SlotMachine.sendInitialEmbedFromSlashCommand ctx
|
| InitEmbeds.Slots -> SlotMachine.sendInitialEmbedFromSlashCommand ctx
|
||||||
| InitEmbeds.JpegStore -> Store.sendBackalleyEmbed ctx
|
| InitEmbeds.JpegStore -> Store.sendBackalleyEmbed ctx
|
||||||
| InitEmbeds.Armory -> Store.sendArmoryEmbed ctx
|
| InitEmbeds.Armory -> Store.sendArmoryEmbed ctx
|
||||||
@ -151,7 +153,7 @@ type AdminBot() =
|
|||||||
[<SlashCommandPermissions(Permissions.Administrator)>]
|
[<SlashCommandPermissions(Permissions.Administrator)>]
|
||||||
[<SlashCommand("admin-whitelist-stock", "Set whitelist stock", false)>]
|
[<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.setCurrentWhitelistStock (int amount * 1<GBT>))
|
enforceAdmin (DiscordInteractionContext ctx) (Whitelist.setCurrentWhitelistStock (int amount * 1<GBT>))
|
||||||
|
|
||||||
[<SlashCommandPermissions(Permissions.Administrator)>]
|
[<SlashCommandPermissions(Permissions.Administrator)>]
|
||||||
[<SlashCommand("admin-send-embed", "Set whitelist stock", false)>]
|
[<SlashCommand("admin-send-embed", "Set whitelist stock", false)>]
|
||||||
|
@ -33,15 +33,6 @@ let invitedUserAccepted inviteCode inviterId inviteeId inviterName inviteeName =
|
|||||||
]
|
]
|
||||||
track "Invited User Accepted" inviterId data
|
track "Invited User Accepted" inviterId data
|
||||||
|
|
||||||
let recruitCommand origin id name (channel : DiscordChannel) =
|
|
||||||
let data = [
|
|
||||||
"user_display_name" , name
|
|
||||||
"origin" , origin
|
|
||||||
"channel_id" , string channel.Id
|
|
||||||
"channel_name" , channel.Name
|
|
||||||
]
|
|
||||||
track "Recruit Command Invoked" id data
|
|
||||||
|
|
||||||
let recruitLinkButton inviteCode id name (channel : DiscordChannel) =
|
let recruitLinkButton inviteCode id name (channel : DiscordChannel) =
|
||||||
let data = [
|
let data = [
|
||||||
"user_display_name" , name
|
"user_display_name" , name
|
||||||
@ -51,29 +42,14 @@ let recruitLinkButton inviteCode id name (channel : DiscordChannel) =
|
|||||||
]
|
]
|
||||||
track "Recruited Link Button Clicked" id data
|
track "Recruited Link Button Clicked" id data
|
||||||
|
|
||||||
let recruitedCommand totalUsers id name (channel : DiscordChannel) =
|
let recruitedButton totalUsers id name (channel : DiscordChannel) =
|
||||||
let data = [
|
let data = [
|
||||||
"user_display_name" , name
|
"user_display_name" , name
|
||||||
"total_users_at_the_time" , string totalUsers
|
"total_users_at_the_time" , string totalUsers
|
||||||
"channel_id" , string channel.Id
|
"channel_id" , string channel.Id
|
||||||
"channel_name" , channel.Name
|
"channel_name" , channel.Name
|
||||||
]
|
]
|
||||||
track "Recruited Command Invoked" id data
|
track "Recruited Button Clicked" id data
|
||||||
|
|
||||||
let whiteListButton availability id name =
|
|
||||||
let data = [
|
|
||||||
"user_display_name" , name
|
|
||||||
"availability" , availability
|
|
||||||
]
|
|
||||||
track "Whitelist Button Clicked" id data
|
|
||||||
|
|
||||||
let whiteListPurchased amount stock id name =
|
|
||||||
let data = [
|
|
||||||
"user_display_name" , name
|
|
||||||
"purchase_price" , string amount
|
|
||||||
"stock" , string stock
|
|
||||||
]
|
|
||||||
track "Whitelist Purchased" id data
|
|
||||||
|
|
||||||
let trainingDojoStep step id name =
|
let trainingDojoStep step id name =
|
||||||
let data = [
|
let data = [
|
||||||
|
17
Bot/Bot.fs
17
Bot/Bot.fs
@ -78,7 +78,7 @@ storeBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleStoreEven
|
|||||||
jpegBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleJpegEvents))
|
jpegBot.add_ComponentInteractionCreated(AsyncEventHandler(Store.handleJpegEvents))
|
||||||
//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(Whitelist.handleButtonEvent))
|
||||||
inviterBot.add_GuildMemberUpdated(AsyncEventHandler(InviteTracker.handleMemberUpdated))
|
inviterBot.add_GuildMemberUpdated(AsyncEventHandler(InviteTracker.handleMemberUpdated))
|
||||||
slotsBot.add_ComponentInteractionCreated(AsyncEventHandler(SlotMachine.handleButton))
|
slotsBot.add_ComponentInteractionCreated(AsyncEventHandler(SlotMachine.handleButton))
|
||||||
slotsBot.add_GuildDownloadCompleted(AsyncEventHandler(SlotMachine.handleGuildDownloadCompleted))
|
slotsBot.add_GuildDownloadCompleted(AsyncEventHandler(SlotMachine.handleGuildDownloadCompleted))
|
||||||
@ -106,20 +106,19 @@ GuildEnvironment.botClientStore <- Some storeBot
|
|||||||
jpegBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
jpegBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
GuildEnvironment.botClientJpeg <- Some jpegBot
|
GuildEnvironment.botClientJpeg <- Some jpegBot
|
||||||
|
|
||||||
slotsBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
|
||||||
GuildEnvironment.botClientSlots <- Some slotsBot
|
|
||||||
|
|
||||||
hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
|
||||||
GuildEnvironment.botClientHacker <- Some hackerBattleBot
|
|
||||||
|
|
||||||
inviterBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
inviterBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
GuildEnvironment.botClientRecruit <- Some inviterBot
|
GuildEnvironment.botClientRecruit <- Some inviterBot
|
||||||
|
|
||||||
adminBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
adminBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
|
||||||
//stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
hackerBattleBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
GuildEnvironment.botClientHacker <- Some hackerBattleBot
|
||||||
|
|
||||||
SlotMachine.sendInitialEmbedFromLaunch slotsBot
|
slotsBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
GuildEnvironment.botClientSlots <- Some slotsBot
|
||||||
|
|
||||||
|
|
||||||
|
//stealBot.ConnectAsync() |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
|
||||||
let rec loop areBotsRunning =
|
let rec loop areBotsRunning =
|
||||||
async {
|
async {
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
<Compile Include="GameHelpers.fs" />
|
<Compile Include="GameHelpers.fs" />
|
||||||
<Compile Include="Analytics.fs" />
|
<Compile Include="Analytics.fs" />
|
||||||
<Compile Include="PlayerInteractions.fs" />
|
<Compile Include="PlayerInteractions.fs" />
|
||||||
<Compile Include="InviteTracker.fs" />
|
|
||||||
<Compile Include="XP.fs" />
|
<Compile Include="XP.fs" />
|
||||||
<Compile Include="Embeds.fs" />
|
<Compile Include="Embeds.fs" />
|
||||||
<Compile Include="Games\SlotMachine.fs" />
|
<Compile Include="Games\SlotMachine.fs" />
|
||||||
@ -25,56 +24,10 @@
|
|||||||
<Compile Include="Games\Store.fs" />
|
<Compile Include="Games\Store.fs" />
|
||||||
<Compile Include="Games\Trainer.fs" />
|
<Compile Include="Games\Trainer.fs" />
|
||||||
<Compile Include="Games\HackerBattle.fs" />
|
<Compile Include="Games\HackerBattle.fs" />
|
||||||
|
<Compile Include="InviteTracker.fs" />
|
||||||
|
<Compile Include="Whitelist.fs" />
|
||||||
<Compile Include="Admin.fs" />
|
<Compile Include="Admin.fs" />
|
||||||
<Compile Include="Bot.fs" />
|
<Compile Include="Bot.fs" />
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\oldtv.png">-->
|
|
||||||
<!-- <Link>images\oldtv.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\sushi.png">-->
|
|
||||||
<!-- <Link>images\sushi.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\aneye.png">-->
|
|
||||||
<!-- <Link>images\aneye.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\anonmask.png">-->
|
|
||||||
<!-- <Link>images\anonmask.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\obey.png">-->
|
|
||||||
<!-- <Link>images\obey.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\circuitboard.png">-->
|
|
||||||
<!-- <Link>images\circuitboard.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\pills.png">-->
|
|
||||||
<!-- <Link>images\pills.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\rat.png">-->
|
|
||||||
<!-- <Link>images\rat.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\ramen.png">-->
|
|
||||||
<!-- <Link>images\ramen.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\pizza.png">-->
|
|
||||||
<!-- <Link>images\pizza.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\alcohol.png">-->
|
|
||||||
<!-- <Link>images\alcohol.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
<!-- <Content Include="..\Images\SlotMachine\new\bigbrother.png">-->
|
|
||||||
<!-- <Link>images\bigbrother.png</Link>-->
|
|
||||||
<!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>-->
|
|
||||||
<!-- </Content>-->
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DataTablePrettyPrinter\DataTablePrettyPrinter.csproj" />
|
<ProjectReference Include="..\DataTablePrettyPrinter\DataTablePrettyPrinter.csproj" />
|
||||||
|
@ -333,21 +333,6 @@ let handleButton _ (event : ComponentInteractionCreateEventArgs) =
|
|||||||
|> Async.Start
|
|> Async.Start
|
||||||
Task.CompletedTask
|
Task.CompletedTask
|
||||||
|
|
||||||
let handleGuildDownloadCompleted _ (event : GuildDownloadCompletedEventArgs) =
|
|
||||||
task {
|
|
||||||
let ( _ , guild ) = event.Guilds.TryGetValue(GuildEnvironment.guildId)
|
|
||||||
guildEmojis <-
|
|
||||||
guild.Emojis
|
|
||||||
|> Seq.map (fun kvp -> kvp.Value) |> Seq.toArray
|
|
||||||
|> Seq.filter (fun de -> Array.contains de.Name slotEmojiNames)
|
|
||||||
|> Seq.distinctBy (fun de -> de.Name)
|
|
||||||
|> Seq.map (fun de -> ( de.Name , de ))
|
|
||||||
|> Map.ofSeq
|
|
||||||
|> Some
|
|
||||||
anyEmoji <- guild.Emojis |> Seq.tryPick (fun kvp -> if kvp.Value.Name = "any" then Some kvp.Value else None)
|
|
||||||
return ()
|
|
||||||
} :> Task
|
|
||||||
|
|
||||||
let handleMessageCreated _ (event : MessageCreateEventArgs) =
|
let handleMessageCreated _ (event : MessageCreateEventArgs) =
|
||||||
task {
|
task {
|
||||||
if event.Channel.Id = GuildEnvironment.channelSlots && event.Author.Id <> GuildEnvironment.botClientSlots.Value.CurrentUser.Id then
|
if event.Channel.Id = GuildEnvironment.channelSlots && event.Author.Id <> GuildEnvironment.botClientSlots.Value.CurrentUser.Id then
|
||||||
@ -408,3 +393,20 @@ let sendInitialEmbedFromSlashCommand (ctx : IDiscordContext) =
|
|||||||
// let jackpotNumChannel = ctx.GetGuild().GetChannel(GuildEnvironment.channelJackpotNum)
|
// let jackpotNumChannel = ctx.GetGuild().GetChannel(GuildEnvironment.channelJackpotNum)
|
||||||
let slotsChannel = ctx.GetGuild().GetChannel(GuildEnvironment.channelSlots)
|
let slotsChannel = ctx.GetGuild().GetChannel(GuildEnvironment.channelSlots)
|
||||||
sendEmbedWithLoop slotsChannel slotsChannel
|
sendEmbedWithLoop slotsChannel slotsChannel
|
||||||
|
|
||||||
|
let handleGuildDownloadCompleted (client : DiscordClient) (event : GuildDownloadCompletedEventArgs) =
|
||||||
|
task {
|
||||||
|
let ( _ , guild ) = event.Guilds.TryGetValue(GuildEnvironment.guildId)
|
||||||
|
guildEmojis <-
|
||||||
|
guild.Emojis
|
||||||
|
|> Seq.map (fun kvp -> kvp.Value) |> Seq.toArray
|
||||||
|
|> Seq.filter (fun de -> Array.contains de.Name slotEmojiNames)
|
||||||
|
|> Seq.distinctBy (fun de -> de.Name)
|
||||||
|
|> Seq.map (fun de -> ( de.Name , de ))
|
||||||
|
|> Map.ofSeq
|
||||||
|
|> Some
|
||||||
|
anyEmoji <- guild.Emojis |> Seq.tryPick (fun kvp -> if kvp.Value.Name = "any" then Some kvp.Value else None)
|
||||||
|
|
||||||
|
sendInitialEmbedFromLaunch client
|
||||||
|
} :> Task
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ let channelArmory = getId "CHANNEL_ARMORY"
|
|||||||
let channelBattle = getId "CHANNEL_BATTLE"
|
let channelBattle = getId "CHANNEL_BATTLE"
|
||||||
let channelWelcome = getId "CHANNEL_WELCOME"
|
let channelWelcome = getId "CHANNEL_WELCOME"
|
||||||
let channelWhitelist = getId "CHANNEL_WHITELIST"
|
let channelWhitelist = getId "CHANNEL_WHITELIST"
|
||||||
|
let channelRecruitment = getId "CHANNEL_RECRUIT"
|
||||||
//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"
|
||||||
|
@ -178,40 +178,6 @@ let getInvitedUserCount userId =
|
|||||||
|> Sql.executeRowAsync (fun read -> read.int "count")
|
|> Sql.executeRowAsync (fun read -> read.int "count")
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
let guildInviteEmbed =
|
|
||||||
let rewardMsg =
|
|
||||||
$"**Your Mission:**\nCLICK THE BUTTON below, then share your **UNIQUE LINK** with any Degenz you want to invite into the Server.\n\n" +
|
|
||||||
$"**Your Reward:**\n`Earn {InviteRewardAmount} $GBT` 💰 for every Degen you invite into the server, that **COMPLETES** hacker training.\n\n" +
|
|
||||||
$"**Commands:**\n`/recruit` - Invite Degenz into the server.\n`/recruited` - Check how many Degenz you've invited."
|
|
||||||
let embed =
|
|
||||||
DiscordEmbedBuilder()
|
|
||||||
.WithColor(DiscordColor.Green)
|
|
||||||
.WithDescription(rewardMsg)
|
|
||||||
.WithImageUrl("https://s1.gifyu.com/images/whitelist-image-banner-3.gif")
|
|
||||||
.WithTitle("Recruitment")
|
|
||||||
|
|
||||||
let builder =
|
|
||||||
DiscordFollowupMessageBuilder()
|
|
||||||
.AddEmbed(embed)
|
|
||||||
.AsEphemeral(true)
|
|
||||||
|
|
||||||
let button = DiscordButtonComponent(ButtonStyle.Success, $"CreateGuildInvite", $"GET MY UNIQUE LINK") :> DiscordComponent
|
|
||||||
builder.AddComponents [| button |]
|
|
||||||
|
|
||||||
let private showInviteMessage (ctx : IDiscordContext) origin =
|
|
||||||
task {
|
|
||||||
let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
|
|
||||||
do! ctx.Respond(InteractionResponseType.DeferredChannelMessageWithSource, builder)
|
|
||||||
|
|
||||||
match! DbService.tryFindPlayer (ctx.GetDiscordMember().Id) with
|
|
||||||
| Some player ->
|
|
||||||
match player.Active with
|
|
||||||
| true -> do! ctx.FollowUp(guildInviteEmbed)
|
|
||||||
| false -> do! sendFollowUpMessage ctx $"You're not in the game! Go to <#{GuildEnvironment.channelShelters}> NOW to get assigned a private bunk, and **JOIN THE GAME!**"
|
|
||||||
do! Analytics.recruitCommand origin player.DiscordId (ctx.GetDiscordMember().Username) (ctx.GetChannel())
|
|
||||||
| None ->
|
|
||||||
do! sendFollowUpMessage ctx $"You're not in the game! Go to <#{GuildEnvironment.channelShelters}> NOW to get assigned a private bunk, and **JOIN THE GAME!**"
|
|
||||||
} :> Task
|
|
||||||
|
|
||||||
let private listServerInvites (ctx : IDiscordContext) = task {
|
let private listServerInvites (ctx : IDiscordContext) = task {
|
||||||
let! invites = ctx.GetGuild().GetInvitesAsync()
|
let! invites = ctx.GetGuild().GetInvitesAsync()
|
||||||
@ -238,8 +204,8 @@ let getAttributions userId (ctx : IDiscordContext) =
|
|||||||
let getInvitedUsersForId (user : DiscordUser) (ctx : IDiscordContext) =
|
let getInvitedUsersForId (user : DiscordUser) (ctx : IDiscordContext) =
|
||||||
task {
|
task {
|
||||||
do! Messaging.defer ctx
|
do! Messaging.defer ctx
|
||||||
let! users = getInvitedUsers (user.Id)
|
let! users = getInvitedUsers user.Id
|
||||||
let! total = getInvitedUserCount (user.Id)
|
let! total = getInvitedUserCount user.Id
|
||||||
let sb = StringBuilder()
|
let sb = StringBuilder()
|
||||||
let mutable count = 0
|
let mutable count = 0
|
||||||
for user in users do
|
for user in users do
|
||||||
@ -256,7 +222,7 @@ let getInvitedUsersForId (user : DiscordUser) (ctx : IDiscordContext) =
|
|||||||
.WithContent(str)
|
.WithContent(str)
|
||||||
do! ctx.FollowUp(msg)
|
do! ctx.FollowUp(msg)
|
||||||
let user = ctx.GetDiscordMember()
|
let user = ctx.GetDiscordMember()
|
||||||
do! Analytics.recruitedCommand total user.Id user.Username (ctx.GetChannel())
|
do! Analytics.recruitedButton total user.Id user.Username (ctx.GetChannel())
|
||||||
} :> Task
|
} :> Task
|
||||||
|
|
||||||
let clearInvites (ctx : IDiscordContext) = task {
|
let clearInvites (ctx : IDiscordContext) = task {
|
||||||
@ -314,22 +280,21 @@ let acceptInvite (guild : DiscordGuild) discordId memberName =
|
|||||||
let sendInitialEmbed (ctx : IDiscordContext) =
|
let sendInitialEmbed (ctx : IDiscordContext) =
|
||||||
async {
|
async {
|
||||||
try
|
try
|
||||||
let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelWhitelist)
|
let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelRecruitment)
|
||||||
let builder = DiscordMessageBuilder()
|
let rewardMsg =
|
||||||
let embed = DiscordEmbedBuilder()
|
$"**Your Mission:**\nCLICK THE BUTTON below, then share your **UNIQUE LINK** with any Degenz you want to invite into the Server.\n\n" +
|
||||||
embed.ImageUrl <- "https://s1.gifyu.com/images/whitelist-image-2.gif"
|
$"**Your Reward:**\n`Earn {InviteRewardAmount} $GBT` 💰 for every Degen you invite into the server, that **COMPLETES** hacker training."
|
||||||
embed.Title <- "Degenz Game"
|
let embed =
|
||||||
embed.Color <- DiscordColor.White
|
DiscordEmbedBuilder()
|
||||||
embed.Description <- """
|
.WithColor(DiscordColor.Green)
|
||||||
Mint Date: **May 2022**
|
.WithDescription(rewardMsg)
|
||||||
Supply: **3,333**
|
.WithImageUrl("https://s1.gifyu.com/images/whitelist-image-banner-3.gif")
|
||||||
Price: **1.984 $SOL**
|
.WithTitle("Recruitment")
|
||||||
|
|
||||||
Your NFT may be your In-Game Character that provides you with unique traits, and abilities in game.
|
let builder = DiscordMessageBuilder().AddEmbed(embed)
|
||||||
"""
|
let btn1 = DiscordButtonComponent(ButtonStyle.Success, $"CreateGuildInvite", $"Get My Invite Link") :> DiscordComponent
|
||||||
builder.AddEmbed embed |> ignore
|
let btn2 = DiscordButtonComponent(ButtonStyle.Primary, $"ShowRecruited", $"My Recruits") :> DiscordComponent
|
||||||
let button = DiscordButtonComponent(ButtonStyle.Success, $"GimmeWhitelist", $"Give Me Whitelist") :> DiscordComponent
|
builder.AddComponents [| btn1 ; btn2 |] |> ignore
|
||||||
builder.AddComponents [| button |] |> ignore
|
|
||||||
|
|
||||||
do! GuildEnvironment.botClientRecruit.Value.SendMessageAsync(channel, builder)
|
do! GuildEnvironment.botClientRecruit.Value.SendMessageAsync(channel, builder)
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
@ -337,192 +302,7 @@ Your NFT may be your In-Game Character that provides you with unique traits, and
|
|||||||
with e ->
|
with e ->
|
||||||
printfn $"Error trying to get channel Whitelist\n\n{e.Message}"
|
printfn $"Error trying to get channel Whitelist\n\n{e.Message}"
|
||||||
} |> Async.RunSynchronously
|
} |> Async.RunSynchronously
|
||||||
|
|
||||||
type WhitelistResult =
|
|
||||||
| NotInGame
|
|
||||||
| NotAHacker
|
|
||||||
| NotEnoughGBT of currentAmount : int<GBT>
|
|
||||||
| NotEnoughStock
|
|
||||||
| Granted of PlayerData
|
|
||||||
| AlreadyWhitelisted
|
|
||||||
|
|
||||||
let tryGrantWhitelist (ctx : IDiscordContext) stock price =
|
|
||||||
task {
|
|
||||||
let user = ctx.GetDiscordMember()
|
|
||||||
match! DbService.tryFindPlayer user.Id with
|
|
||||||
| Some player ->
|
|
||||||
let hasWhitelist = Seq.contains (ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)) user.Roles
|
|
||||||
|
|
||||||
match hasWhitelist , player.Active , stock > 0 , player.Bank >= price with
|
|
||||||
| true , _ , _ , _ -> return AlreadyWhitelisted
|
|
||||||
| _ , false , _ , _ -> return NotInGame
|
|
||||||
| _ , _ , false , _ -> return NotEnoughStock
|
|
||||||
| _ , _ , _ , false -> return NotEnoughGBT player.Bank
|
|
||||||
| _ , _ , _ , _ -> return Granted player
|
|
||||||
| None -> return NotInGame
|
|
||||||
}
|
|
||||||
|
|
||||||
let notAHackerMsg = $"""
|
|
||||||
Woah slow down buddy… You’re not even a hacker yet! To get Whitelisted you need to buy it with **$GBT** by playing the game.
|
|
||||||
|
|
||||||
Go to <#{GuildEnvironment.channelTraining}> NOW to finish training and become a **HACKER**!**
|
|
||||||
"""
|
|
||||||
|
|
||||||
let notInGameMsg = $"""
|
|
||||||
Woah slow down buddy… You’re not even in the game yet! To get Whitelisted you need to buy it with **$GBT** by playing the game.
|
|
||||||
|
|
||||||
Go to <#{GuildEnvironment.channelShelters}> NOW to get assigned a bunk, and **JOIN THE GAME!**
|
|
||||||
"""
|
|
||||||
|
|
||||||
let alreadyWhitelistedMsg = $"""
|
|
||||||
✅ You’re **ALREADY** Whitelisted! Save some for other Degenz…
|
|
||||||
|
|
||||||
**Remember:**
|
|
||||||
Earn `100 $GBT` 💰 for every Degen you recruit into the game!
|
|
||||||
Just type `/recruit` anywhere, or press the button below...
|
|
||||||
|
|
||||||
**Commands:**
|
|
||||||
`/recruit` - Invite Degenz into the server.
|
|
||||||
`/recruited` - Check how many Degenz you’ve invited.
|
|
||||||
"""
|
|
||||||
|
|
||||||
let notEnoughMoneyMsg price total = $"""
|
|
||||||
Oh no!
|
|
||||||
You don't have enough **$GBT** to buy a WHITELIST spot! Come back when you have `{price - total}` more $GBT.
|
|
||||||
|
|
||||||
The QUICKEST way to earn **$GBT** is by recruiting other Degenz into the server.
|
|
||||||
Earn `{InviteRewardAmount} $GBT` 💰 for every Degen you recruit into the game!
|
|
||||||
|
|
||||||
Just type `/recruit` anywhere, anytime... Or just press the button below!
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
let canBuyWhitelistMsg = $"""
|
|
||||||
Look at you Degen, you played Big Brother’s games and made it out alive! Now you can use your $GBT to pay for one of our coveted Whitelist spots.
|
|
||||||
|
|
||||||
Click buy now below and the role will be auto assigned to you.
|
|
||||||
"""
|
|
||||||
|
|
||||||
let handleGimmeWhitelist (ctx : IDiscordContext) =
|
|
||||||
task {
|
|
||||||
let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
|
|
||||||
do! ctx.Respond(InteractionResponseType.DeferredChannelMessageWithSource, builder)
|
|
||||||
|
|
||||||
let whitelistEmbed = DiscordEmbedBuilder()
|
|
||||||
whitelistEmbed.Title <- "1x Degenz Game Whitelist "
|
|
||||||
let includeInfo stock price =
|
|
||||||
whitelistEmbed.ImageUrl <- "https://s7.gifyu.com/images/whitelist-item-mock-banner18.png"
|
|
||||||
whitelistEmbed.AddField("Item", "`1x Whitelist`", true) |> ignore
|
|
||||||
whitelistEmbed.AddField("Available", $"`{stock}`", true) |> ignore
|
|
||||||
whitelistEmbed.AddField("Price 💰", $"`{price} $GBT`", true) |> ignore
|
|
||||||
whitelistEmbed.Color <- DiscordColor.Red
|
|
||||||
let buyBtn = DiscordButtonComponent(ButtonStyle.Success, $"BuyWhitelist", $"Buy Now", true) :> DiscordComponent
|
|
||||||
let buyActiveBtn = DiscordButtonComponent(ButtonStyle.Success, $"BuyWhitelist", $"Buy Now") :> DiscordComponent
|
|
||||||
let recruitBtn = DiscordButtonComponent(ButtonStyle.Danger, $"ShowRecruitmentEmbed", $"Recruit Now") :> DiscordComponent
|
|
||||||
|
|
||||||
let builder = DiscordFollowupMessageBuilder().AsEphemeral(true)
|
|
||||||
|
|
||||||
let! wlItem = DbService.getStoreItemBySymbol "WHITELIST"
|
|
||||||
let wlPrice = Inventory.getBuyPrice wlItem.Item
|
|
||||||
let! availability = tryGrantWhitelist ctx wlItem.Stock wlPrice
|
|
||||||
match availability with
|
|
||||||
| NotAHacker -> whitelistEmbed.Description <- notAHackerMsg
|
|
||||||
| NotInGame -> whitelistEmbed.Description <- notInGameMsg
|
|
||||||
| AlreadyWhitelisted ->
|
|
||||||
builder.AddComponents([ recruitBtn ]) |> ignore
|
|
||||||
whitelistEmbed.Color <- DiscordColor.Green
|
|
||||||
whitelistEmbed.Color <- DiscordColor.Green
|
|
||||||
whitelistEmbed.Description <- alreadyWhitelistedMsg
|
|
||||||
| NotEnoughStock -> whitelistEmbed.Description <- "Oh no! We do not have any whitelist spots available for now. Check back later or go bother Kitty and ask him why the fuck you can't whitelist"
|
|
||||||
| NotEnoughGBT total ->
|
|
||||||
includeInfo wlItem.Stock wlPrice
|
|
||||||
builder.AddComponents([ buyBtn ; recruitBtn ]) |> ignore
|
|
||||||
whitelistEmbed.Description <- notEnoughMoneyMsg wlPrice total
|
|
||||||
| Granted _ ->
|
|
||||||
includeInfo wlItem.Stock wlPrice
|
|
||||||
whitelistEmbed.Color <- DiscordColor.Green
|
|
||||||
whitelistEmbed.Color <- DiscordColor.Green
|
|
||||||
builder.AddComponents([ buyActiveBtn ]) |> ignore
|
|
||||||
whitelistEmbed.Description <- canBuyWhitelistMsg
|
|
||||||
builder.AddEmbed(whitelistEmbed) |> ignore
|
|
||||||
do! ctx.FollowUp(builder)
|
|
||||||
let availabilityStr =
|
|
||||||
match availability with
|
|
||||||
| NotEnoughGBT _ -> "NotEnoughGBT"
|
|
||||||
| Granted _ -> "Granted"
|
|
||||||
| _ -> string availability
|
|
||||||
let user = ctx.GetDiscordMember()
|
|
||||||
do! Analytics.whiteListButton availabilityStr user.Id user.Username
|
|
||||||
} :> Task
|
|
||||||
|
|
||||||
let buyWhitelistMsg = $"""
|
|
||||||
🎉 Congratulations you’ve been **WHITELISTED!**
|
|
||||||
|
|
||||||
**Remember:**
|
|
||||||
Earn `100 $GBT` 💰 for every Degen you recruit into the game!
|
|
||||||
Just type `/recruit` anywhere, or press the button below...
|
|
||||||
|
|
||||||
**Commands:**
|
|
||||||
`/recruit` - Invite Degenz into the server.
|
|
||||||
`/recruited` - Check how many Degenz you’ve invited.
|
|
||||||
"""
|
|
||||||
|
|
||||||
let handleBuyWhitelist (ctx : IDiscordContext) =
|
|
||||||
task {
|
|
||||||
let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
|
|
||||||
do! ctx.Respond(InteractionResponseType.DeferredChannelMessageWithSource, builder)
|
|
||||||
|
|
||||||
let! wlItem = DbService.getStoreItemBySymbol "WHITELIST"
|
|
||||||
let builder = DiscordFollowupMessageBuilder().AsEphemeral(true)
|
|
||||||
let wlPrice = Inventory.getBuyPrice wlItem.Item
|
|
||||||
match! tryGrantWhitelist ctx wlItem.Stock wlPrice with
|
|
||||||
| NotAHacker ->
|
|
||||||
builder.Content <- $"You are somehow not a hacker anymore, what exactly are you doing?"
|
|
||||||
do! ctx.FollowUp(builder)
|
|
||||||
| NotInGame ->
|
|
||||||
builder.Content <- $"You somehow have left the game, what exactly are you doing?"
|
|
||||||
do! ctx.FollowUp(builder)
|
|
||||||
| AlreadyWhitelisted ->
|
|
||||||
builder.Content <- "🎉 You're already WHITELISTED!"
|
|
||||||
do! ctx.FollowUp(builder)
|
|
||||||
| NotEnoughGBT _ ->
|
|
||||||
builder.Content <- $"You somehow do not have enough $GBT, what exactly are you doing?"
|
|
||||||
do! ctx.FollowUp(builder)
|
|
||||||
| NotEnoughStock ->
|
|
||||||
builder.Content <- $"We just ran out of stock, tough shit"
|
|
||||||
do! ctx.FollowUp(builder)
|
|
||||||
| Granted player ->
|
|
||||||
match! DbService.decrementItemStock wlItem.Item with
|
|
||||||
| true ->
|
|
||||||
let embed = DiscordEmbedBuilder()
|
|
||||||
embed.Description <- buyWhitelistMsg
|
|
||||||
embed.Color <- DiscordColor.Green
|
|
||||||
|
|
||||||
let recruitBtn = DiscordButtonComponent(ButtonStyle.Danger, $"ShowRecruitmentEmbed", $"Recruit Now") :> DiscordComponent
|
|
||||||
builder.AddComponents [ recruitBtn ] |> ignore
|
|
||||||
let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)
|
|
||||||
do! ctx.GetDiscordMember().GrantRoleAsync(role)
|
|
||||||
let! _ = DbService.updatePlayerCurrency -wlPrice player.DiscordId
|
|
||||||
builder.AddEmbed(embed) |> ignore
|
|
||||||
do! ctx.FollowUp(builder)
|
|
||||||
|
|
||||||
// Send message to hall of privacy
|
|
||||||
let builder = DiscordMessageBuilder()
|
|
||||||
builder.WithContent($"{player.Name} just purchased WHITELIST!") |> ignore
|
|
||||||
let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelEventsHackerBattle)
|
|
||||||
do! channel.SendMessageAsync(builder)
|
|
||||||
|> Async.AwaitTask
|
|
||||||
|> Async.Ignore
|
|
||||||
let user = ctx.GetDiscordMember()
|
|
||||||
do! Analytics.whiteListPurchased wlPrice wlItem.Stock user.Id user.Username
|
|
||||||
| false ->
|
|
||||||
let embed = DiscordEmbedBuilder()
|
|
||||||
embed.Description <- "Oh no! Looks like the last Whitelist spot was taken. Don't worry you weren't charged..."
|
|
||||||
embed.Color <- DiscordColor.Red
|
|
||||||
builder.AddEmbed(embed) |> ignore
|
|
||||||
do! ctx.FollowUp(builder)
|
|
||||||
} :> Task
|
|
||||||
|
|
||||||
let handleCreateInvite (ctx : IDiscordContext) =
|
let handleCreateInvite (ctx : IDiscordContext) =
|
||||||
task {
|
task {
|
||||||
let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
|
let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
|
||||||
@ -573,21 +353,6 @@ let handleMemberUpdated (client : DiscordClient) (event : GuildMemberUpdateEvent
|
|||||||
return ()
|
return ()
|
||||||
} :> Task
|
} :> Task
|
||||||
|
|
||||||
let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) =
|
|
||||||
let eventCtx = DiscordEventContext event :> IDiscordContext
|
|
||||||
match event.Id with
|
|
||||||
| id when id.StartsWith("GimmeWhitelist") -> handleGimmeWhitelist eventCtx
|
|
||||||
| id when id.StartsWith("BuyWhitelist") -> handleBuyWhitelist eventCtx
|
|
||||||
| id when id.StartsWith("CreateGuildInvite") -> handleCreateInvite eventCtx
|
|
||||||
| id when id.StartsWith("ShowRecruitmentEmbed") -> showInviteMessage eventCtx "RecruitButton"
|
|
||||||
| _ ->
|
|
||||||
task {
|
|
||||||
let builder = DiscordInteractionResponseBuilder()
|
|
||||||
builder.IsEphemeral <- true
|
|
||||||
builder.Content <- $"Incorrect Action identifier {eventCtx.GetInteractionId()}"
|
|
||||||
do! eventCtx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask
|
|
||||||
}
|
|
||||||
|
|
||||||
let handleGuildMemberAdded _ (eventArgs : GuildMemberAddEventArgs) =
|
let handleGuildMemberAdded _ (eventArgs : GuildMemberAddEventArgs) =
|
||||||
task {
|
task {
|
||||||
let! exists = checkUserAlreadyInvited eventArgs.Member.Id
|
let! exists = checkUserAlreadyInvited eventArgs.Member.Id
|
||||||
@ -595,33 +360,23 @@ let handleGuildMemberAdded _ (eventArgs : GuildMemberAddEventArgs) =
|
|||||||
do! processNewUser eventArgs
|
do! processNewUser eventArgs
|
||||||
} :> Task
|
} :> Task
|
||||||
|
|
||||||
let setCurrentWhitelistStock amount (ctx : IDiscordContext) =
|
|
||||||
task {
|
|
||||||
do! Messaging.defer ctx
|
|
||||||
let! result = DbService.setItemStock amount "WHITELIST"
|
|
||||||
if result then
|
|
||||||
do! Messaging.sendFollowUpMessage ctx $"Set Whitelist stock to {amount}"
|
|
||||||
else
|
|
||||||
do! Messaging.sendFollowUpMessage ctx $"Error setting WL to {amount}, make sure it's greater than 0"
|
|
||||||
} :> Task
|
|
||||||
|
|
||||||
type Inviter() =
|
type Inviter() =
|
||||||
inherit ApplicationCommandModule ()
|
inherit ApplicationCommandModule ()
|
||||||
|
|
||||||
[<SlashCommand("recruit", "Recruit another user to this discord and earn rewards")>]
|
// [<SlashCommand("recruit", "Recruit another user to this discord and earn rewards")>]
|
||||||
member this.CreateInvite (ctx : InteractionContext) =
|
// member this.CreateInvite (ctx : InteractionContext) =
|
||||||
showInviteMessage (DiscordInteractionContext ctx) "RecruitCommand"
|
// showInviteMessage (DiscordInteractionContext ctx) "RecruitCommand"
|
||||||
|
//
|
||||||
[<SlashCommand("recruited", "Get total invites from a specific user")>]
|
// [<SlashCommand("recruited", "Get total invites from a specific user")>]
|
||||||
member this.ListInvitedPeople (ctx : InteractionContext) =
|
// member this.ListInvitedPeople (ctx : InteractionContext) =
|
||||||
let ictx = DiscordInteractionContext ctx :> IDiscordContext
|
// let ictx = DiscordInteractionContext ctx :> IDiscordContext
|
||||||
getInvitedUsersForId (ictx.GetDiscordMember()) ictx
|
// getInvitedUsersForId (ictx.GetDiscordMember()) ictx
|
||||||
|
|
||||||
// [<SlashCommand("invites-list", "List all the invites")>]
|
// [<SlashCommand("invites-list", "List all the invites")>]
|
||||||
member this.ListServerInvites (ctx : InteractionContext) =
|
// member this.ListServerInvites (ctx : InteractionContext) =
|
||||||
listServerInvites (DiscordInteractionContext ctx)
|
// listServerInvites (DiscordInteractionContext ctx)
|
||||||
|
|
||||||
// [<SlashCommand("invites-clear", "Get total invites from a specific user")>]
|
// [<SlashCommand("invites-clear", "Get total invites from a specific user")>]
|
||||||
member this.ClearInvites (ctx : InteractionContext) =
|
// member this.ClearInvites (ctx : InteractionContext) =
|
||||||
clearInvites (DiscordInteractionContext ctx)
|
// clearInvites (DiscordInteractionContext ctx)
|
||||||
|
|
||||||
|
80
Bot/Whitelist.fs
Normal file
80
Bot/Whitelist.fs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
module Degenz.Whitelist
|
||||||
|
|
||||||
|
open System.Threading.Tasks
|
||||||
|
open DSharpPlus
|
||||||
|
open DSharpPlus.Entities
|
||||||
|
open DSharpPlus.EventArgs
|
||||||
|
open Degenz.Messaging
|
||||||
|
|
||||||
|
// TODO: We're probably going to get rid of this
|
||||||
|
let InviteRewardAmount = 100<GBT>
|
||||||
|
|
||||||
|
type WhitelistResult =
|
||||||
|
| NotInGame
|
||||||
|
| NotAHacker
|
||||||
|
| NotEnoughGBT of currentAmount : int<GBT>
|
||||||
|
| NotEnoughStock
|
||||||
|
| Granted of PlayerData
|
||||||
|
| AlreadyWhitelisted
|
||||||
|
|
||||||
|
let sendInitialEmbed (ctx : IDiscordContext) =
|
||||||
|
async {
|
||||||
|
try
|
||||||
|
let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelWhitelist)
|
||||||
|
let builder = DiscordMessageBuilder()
|
||||||
|
let embed = DiscordEmbedBuilder()
|
||||||
|
embed.ImageUrl <- "https://s1.gifyu.com/images/whitelist-image-2.gif"
|
||||||
|
embed.Title <- "Degenz Game"
|
||||||
|
embed.Color <- DiscordColor.White
|
||||||
|
embed.Description <- """
|
||||||
|
Mint Date: **May 2022**
|
||||||
|
Supply: **3,333**
|
||||||
|
Price: **1.984 $SOL**
|
||||||
|
|
||||||
|
Your NFT may be your In-Game Character that provides you with unique traits, and abilities in game.
|
||||||
|
"""
|
||||||
|
builder.AddEmbed embed |> ignore
|
||||||
|
let button = DiscordButtonComponent(ButtonStyle.Success, $"GimmeWhitelist", $"Give Me Whitelist") :> DiscordComponent
|
||||||
|
builder.AddComponents [| button |] |> ignore
|
||||||
|
|
||||||
|
do! GuildEnvironment.botClientRecruit.Value.SendMessageAsync(channel, builder)
|
||||||
|
|> Async.AwaitTask
|
||||||
|
|> Async.Ignore
|
||||||
|
with e ->
|
||||||
|
printfn $"Error trying to get channel Whitelist\n\n{e.Message}"
|
||||||
|
} |> Async.RunSynchronously
|
||||||
|
|
||||||
|
let grantWhitelistRole (ctx : IDiscordContext) =
|
||||||
|
task {
|
||||||
|
|
||||||
|
let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)
|
||||||
|
do! ctx.GetDiscordMember().GrantRoleAsync(role)
|
||||||
|
} :> Task
|
||||||
|
|
||||||
|
let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) =
|
||||||
|
let eventCtx = DiscordEventContext event :> IDiscordContext
|
||||||
|
match event.Id with
|
||||||
|
| id when id.StartsWith("GimmeWhitelist") -> Store.buy "WHITELIST" None eventCtx
|
||||||
|
| id when id.StartsWith("Buy") ->
|
||||||
|
let id = eventCtx.GetInteractionId()
|
||||||
|
let itemId = id.Split("-").[1]
|
||||||
|
Store.handleBuyItem eventCtx itemId
|
||||||
|
| id when id.StartsWith("CreateGuildInvite") -> InviteTracker.handleCreateInvite eventCtx
|
||||||
|
| id when id.StartsWith("ShowRecruited") -> InviteTracker.getInvitedUsersForId (eventCtx.GetDiscordMember()) eventCtx
|
||||||
|
| _ ->
|
||||||
|
task {
|
||||||
|
let builder = DiscordInteractionResponseBuilder()
|
||||||
|
builder.IsEphemeral <- true
|
||||||
|
builder.Content <- $"Incorrect Action identifier {eventCtx.GetInteractionId()}"
|
||||||
|
do! eventCtx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask
|
||||||
|
}
|
||||||
|
|
||||||
|
let setCurrentWhitelistStock amount (ctx : IDiscordContext) =
|
||||||
|
task {
|
||||||
|
do! Messaging.defer ctx
|
||||||
|
let! result = DbService.setItemStock amount "WHITELIST"
|
||||||
|
if result then
|
||||||
|
do! Messaging.sendFollowUpMessage ctx $"Set Whitelist stock to {amount}"
|
||||||
|
else
|
||||||
|
do! Messaging.sendFollowUpMessage ctx $"Error setting WL to {amount}, make sure it's greater than 0"
|
||||||
|
} :> Task
|
Loading…
x
Reference in New Issue
Block a user