102 lines
4.2 KiB
Forth
102 lines
4.2 KiB
Forth
module Degenz.Whitelist
|
|
|
|
open System.Threading.Tasks
|
|
open DSharpPlus
|
|
open DSharpPlus.Entities
|
|
open DSharpPlus.EventArgs
|
|
open Degenz.Messaging
|
|
|
|
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://s8.gifyu.com/images/whitelist-banner-smaller2.gif"
|
|
embed.Title <- "Degenz Game Whitelist"
|
|
embed.Color <- DiscordColor.Azure
|
|
embed.Description <- $"""
|
|
**__Requirements:__**
|
|
You need to BUY Whitelist with 💰 $GBT
|
|
You must also have INVITED at least 1 Degen…
|
|
|
|
**__To Earn $GBT:__**
|
|
1️⃣ Invite Degenz in <#{GuildEnvironment.channelRecruitment}>
|
|
2️⃣ Chat to level up in the <#{GuildEnvironment.channelGeneral}>
|
|
3️⃣ Complete fun quests inside <#{GuildEnvironment.channelQuests}>
|
|
"""
|
|
builder.AddEmbed embed |> ignore
|
|
let btn1 = DiscordButtonComponent(ButtonStyle.Success, $"GimmeWhitelist", $"Buy Whitelist") :> DiscordComponent
|
|
builder.AddComponents [| btn1 |] |> 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 isOg (ctx : IDiscordContext) =
|
|
task {
|
|
let! wallet = InviteTracker.getWalletAddress (ctx.GetDiscordMember().Id)
|
|
let roleId =
|
|
match isOg , wallet with
|
|
| true , Some _ -> GuildEnvironment.roleWhiteOG
|
|
| false , Some _ -> GuildEnvironment.roleWhitelist
|
|
| true , None -> GuildEnvironment.roleWhiteOGPending
|
|
| false , None -> GuildEnvironment.roleWhitelistPending
|
|
let role = ctx.GetGuild().GetRole(roleId)
|
|
let user = ctx.GetDiscordMember()
|
|
do! user.GrantRoleAsync(role)
|
|
} :> Task
|
|
|
|
let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) =
|
|
let ctx = DiscordEventContext event :> IDiscordContext
|
|
task {
|
|
let builder = DiscordInteractionResponseBuilder()
|
|
builder.IsEphemeral <- true
|
|
builder.Content <- $"🚀 __Mint Date:__ June 20th 6:30 UTC <t:1655749800:R>"
|
|
do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, builder) |> Async.AwaitTask
|
|
} : Task
|
|
|
|
//let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) =
|
|
// let ctx = DiscordEventContext event :> IDiscordContext
|
|
// match event.Id with
|
|
// | id when id.StartsWith("GimmeWhitelist") -> Store.buy "WHITELIST" None ctx
|
|
// | id when id.StartsWith("Buy") ->
|
|
// task {
|
|
// let id = ctx.GetInteractionId()
|
|
// let itemId = id.Split("-").[1]
|
|
// let dispatch ctx = grantWhitelistRole (itemId = "WHITEOG") ctx
|
|
//
|
|
// do! Store.handleBuyItem dispatch ctx itemId
|
|
// } :> Task
|
|
// | id when id.StartsWith("CreateGuildInvite") -> InviteTracker.handleCreateInvite ctx
|
|
// | id when id.StartsWith("ShowRecruited") -> InviteTracker.getInvitedUsersForId (ctx.GetDiscordMember()) ctx
|
|
// | id when id.StartsWith("WalletStatus") -> InviteTracker.showWalletStatus ctx
|
|
// | _ ->
|
|
// task {
|
|
// let builder = DiscordInteractionResponseBuilder()
|
|
// builder.IsEphemeral <- true
|
|
// builder.Content <- $"Incorrect Action identifier {ctx.GetInteractionId()}"
|
|
// do! ctx.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
|