Grant roles
This commit is contained in:
parent
8b31b24e10
commit
11fd4a45e6
@ -54,6 +54,8 @@ let botIdArmory = getId "BOT_ARMORY"
|
|||||||
let roleTrainee = getId "ROLE_TRAINEE"
|
let roleTrainee = getId "ROLE_TRAINEE"
|
||||||
let roleHacker = getId "ROLE_HACKER"
|
let roleHacker = getId "ROLE_HACKER"
|
||||||
let rolePrisoner = getId "ROLE_PRISONER"
|
let rolePrisoner = getId "ROLE_PRISONER"
|
||||||
|
let roleWhitelistPending = getId "ROLE_WHITELIST_PENDING"
|
||||||
|
let roleWhiteOGPending = getId "ROLE_WHITEOG_PENDING"
|
||||||
let roleWhitelist = getId "ROLE_WHITELIST"
|
let roleWhitelist = getId "ROLE_WHITELIST"
|
||||||
let roleWhiteOG = getId "ROLE_WHITEOG"
|
let roleWhiteOG = getId "ROLE_WHITEOG"
|
||||||
let roleAdmin = getId "ROLE_ADMIN"
|
let roleAdmin = getId "ROLE_ADMIN"
|
||||||
|
@ -201,6 +201,20 @@ let getWalletAddress (userId : uint64) =
|
|||||||
|> Sql.executeRowAsync (fun reader -> reader.stringOrNone "wallet_address")
|
|> Sql.executeRowAsync (fun reader -> reader.stringOrNone "wallet_address")
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let walletAddressExists (address : string) =
|
||||||
|
async {
|
||||||
|
let! result =
|
||||||
|
connStr
|
||||||
|
|> Sql.connect
|
||||||
|
|> Sql.parameters [ "address" , Sql.string address ]
|
||||||
|
|> Sql.query """
|
||||||
|
SELECT wallet_address FROM "user" WHERE wallet_address = @address;
|
||||||
|
"""
|
||||||
|
|> Sql.executeAsync (fun reader -> reader.stringOrNone "wallet_address")
|
||||||
|
|> Async.AwaitTask
|
||||||
|
return List.isEmpty result |> not
|
||||||
|
}
|
||||||
|
|
||||||
let private listServerInvites (ctx : IDiscordContext) = task {
|
let private listServerInvites (ctx : IDiscordContext) = task {
|
||||||
let! invites = ctx.GetGuild().GetInvitesAsync()
|
let! invites = ctx.GetGuild().GetInvitesAsync()
|
||||||
let sb = StringBuilder()
|
let sb = StringBuilder()
|
||||||
@ -451,7 +465,7 @@ let handleGuildMemberAdded _ (eventArgs : GuildMemberAddEventArgs) =
|
|||||||
do! processNewUser eventArgs
|
do! processNewUser eventArgs
|
||||||
} :> Task
|
} :> Task
|
||||||
|
|
||||||
let submitWhitelist (address : string) (ctx : IDiscordContext) =
|
let submitAddress (address : string) (ctx : IDiscordContext) =
|
||||||
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
||||||
let pubkey = PublicKey(address)
|
let pubkey = PublicKey(address)
|
||||||
try
|
try
|
||||||
@ -463,6 +477,20 @@ let submitWhitelist (address : string) (ctx : IDiscordContext) =
|
|||||||
| Some _ -> "We successfully updated your wallet address:"
|
| Some _ -> "We successfully updated your wallet address:"
|
||||||
| None -> "We have successfully received your wallet address"
|
| None -> "We have successfully received your wallet address"
|
||||||
do! addWalletAddress (ctx.GetDiscordMember().Id) address
|
do! addWalletAddress (ctx.GetDiscordMember().Id) address
|
||||||
|
|
||||||
|
let user = ctx.GetDiscordMember()
|
||||||
|
if ctx.GetDiscordMember().Roles |> Seq.exists (fun role -> role.Id = GuildEnvironment.roleWhitelistPending) then
|
||||||
|
let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelist)
|
||||||
|
do! user.GrantRoleAsync(role) |> Async.AwaitTask
|
||||||
|
let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhitelistPending)
|
||||||
|
do! user.RevokeRoleAsync(role) |> Async.AwaitTask
|
||||||
|
if ctx.GetDiscordMember().Roles |> Seq.exists (fun role -> role.Id = GuildEnvironment.roleWhiteOGPending) then
|
||||||
|
let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhiteOG)
|
||||||
|
do! user.GrantRoleAsync(role) |> Async.AwaitTask
|
||||||
|
let role = ctx.GetGuild().GetRole(GuildEnvironment.roleWhiteOGPending)
|
||||||
|
do! user.RevokeRoleAsync(role) |> Async.AwaitTask
|
||||||
|
|
||||||
|
|
||||||
do! Messaging.sendFollowUpMessage ctx $"""
|
do! Messaging.sendFollowUpMessage ctx $"""
|
||||||
🚀 __Mint Date:__ 31st May 18:00 UTC
|
🚀 __Mint Date:__ 31st May 18:00 UTC
|
||||||
✅ {msg} {address}
|
✅ {msg} {address}
|
||||||
@ -498,8 +526,11 @@ type Inviter() =
|
|||||||
|
|
||||||
[<SlashCommand("submit", "Submit your public wallet address")>]
|
[<SlashCommand("submit", "Submit your public wallet address")>]
|
||||||
member this.SubmitAddress (ctx : InteractionContext, [<Option("address", "Wallet address")>] address : string) =
|
member this.SubmitAddress (ctx : InteractionContext, [<Option("address", "Wallet address")>] address : string) =
|
||||||
if ctx.Member.Roles |> Seq.exists (fun role -> role.Id = GuildEnvironment.roleWhitelist || role.Id = GuildEnvironment.roleWhiteOG) then
|
let isWhitelist (role : DiscordRole) =
|
||||||
enforceChannel (DiscordInteractionContext ctx) (submitWhitelist address)
|
role.Id = GuildEnvironment.roleWhitelistPending || role.Id = GuildEnvironment.roleWhiteOGPending ||
|
||||||
|
role.Id = GuildEnvironment.roleWhitelist || role.Id = GuildEnvironment.roleWhiteOG
|
||||||
|
if ctx.Member.Roles |> Seq.exists isWhitelist then
|
||||||
|
enforceChannel (DiscordInteractionContext ctx) (submitAddress address)
|
||||||
else
|
else
|
||||||
let msg = $"You currently are not Whitelisted, go to <#{GuildEnvironment.channelWhitelist}> to purchase the role!"
|
let msg = $"You currently are not Whitelisted, go to <#{GuildEnvironment.channelWhitelist}> to purchase the role!"
|
||||||
Messaging.sendSimpleResponse (DiscordInteractionContext ctx) msg
|
Messaging.sendSimpleResponse (DiscordInteractionContext ctx) msg
|
||||||
|
@ -44,9 +44,10 @@ You need to **BUY** Whitelist with 💰 $GBT...
|
|||||||
|
|
||||||
let grantWhitelistRole isOg (ctx : IDiscordContext) =
|
let grantWhitelistRole isOg (ctx : IDiscordContext) =
|
||||||
task {
|
task {
|
||||||
let roleId = if isOg then GuildEnvironment.roleWhiteOG else GuildEnvironment.roleWhitelist
|
let roleId = if isOg then GuildEnvironment.roleWhiteOGPending else GuildEnvironment.roleWhitelistPending
|
||||||
let role = ctx.GetGuild().GetRole(roleId)
|
let role = ctx.GetGuild().GetRole(roleId)
|
||||||
do! ctx.GetDiscordMember().GrantRoleAsync(role)
|
let user = ctx.GetDiscordMember()
|
||||||
|
do! user.GrantRoleAsync(role)
|
||||||
} :> Task
|
} :> Task
|
||||||
|
|
||||||
let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) =
|
let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user