81 lines
3.1 KiB
Forth
81 lines
3.1 KiB
Forth
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
|