Submit wallet stuff
This commit is contained in:
parent
a06d1ef383
commit
217935e146
@ -17,6 +17,7 @@ type InitEmbeds =
|
|||||||
| Slots = 3
|
| Slots = 3
|
||||||
| JpegStore = 4
|
| JpegStore = 4
|
||||||
| Armory = 5
|
| Armory = 5
|
||||||
|
| Wallet = 6
|
||||||
|
|
||||||
let handleGuildDownloadReady _ (event : GuildDownloadCompletedEventArgs) =
|
let handleGuildDownloadReady _ (event : GuildDownloadCompletedEventArgs) =
|
||||||
task {
|
task {
|
||||||
@ -39,6 +40,7 @@ let sendEmbed embed (ctx : IDiscordContext) =
|
|||||||
| 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
|
||||||
|
| InitEmbeds.Wallet -> InviteTracker.sendSubmitEmbed ctx
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
do! Messaging.sendSimpleResponse ctx "Sent!"
|
do! Messaging.sendSimpleResponse ctx "Sent!"
|
||||||
} :> Task
|
} :> Task
|
||||||
|
@ -41,6 +41,7 @@ let channelBackAlley = getId "CHANNEL_BACKALLEY"
|
|||||||
let channelMarket = getId "CHANNEL_MARKET"
|
let channelMarket = getId "CHANNEL_MARKET"
|
||||||
let channelAccessoryShop = getId "CHANNEL_ACCESSORIES"
|
let channelAccessoryShop = getId "CHANNEL_ACCESSORIES"
|
||||||
let channelGiveaway = getId "CHANNEL_GIVEAWAY"
|
let channelGiveaway = getId "CHANNEL_GIVEAWAY"
|
||||||
|
let channelSubmitWallet = getId "CHANNEL_SUBMIT_WALLET"
|
||||||
let channelAnnouncements = getId "CHANNEL_ANNOUNCEMENTS"
|
let channelAnnouncements = getId "CHANNEL_ANNOUNCEMENTS"
|
||||||
let channelGeneral = getId "CHANNEL_GENERAL"
|
let channelGeneral = getId "CHANNEL_GENERAL"
|
||||||
let channelQuests = getId "CHANNEL_QUESTS"
|
let channelQuests = getId "CHANNEL_QUESTS"
|
||||||
|
@ -181,6 +181,26 @@ let getInvitedUserCount userId =
|
|||||||
|> Sql.executeRowAsync (fun read -> read.int "count")
|
|> Sql.executeRowAsync (fun read -> read.int "count")
|
||||||
|> Async.AwaitTask
|
|> Async.AwaitTask
|
||||||
|
|
||||||
|
let addWalletAddress (userId : uint64) address =
|
||||||
|
connStr
|
||||||
|
|> Sql.connect
|
||||||
|
|> Sql.parameters [ "did" , Sql.string (string userId) ; "address" , Sql.string address ]
|
||||||
|
|> Sql.query """
|
||||||
|
UPDATE "user" SET wallet_address = @address WHERE id = @did;
|
||||||
|
"""
|
||||||
|
|> Sql.executeNonQueryAsync
|
||||||
|
|> Async.AwaitTask
|
||||||
|
|> Async.Ignore
|
||||||
|
|
||||||
|
let getWalletAddress (userId : uint64) =
|
||||||
|
connStr
|
||||||
|
|> Sql.connect
|
||||||
|
|> Sql.parameters [ "did" , Sql.string (string userId) ]
|
||||||
|
|> Sql.query """
|
||||||
|
SELECT wallet_address FROM "user" WHERE id = @did;
|
||||||
|
"""
|
||||||
|
|> Sql.executeRowAsync (fun reader -> reader.stringOrNone "wallet_address")
|
||||||
|
|> Async.AwaitTask
|
||||||
|
|
||||||
let private listServerInvites (ctx : IDiscordContext) = task {
|
let private listServerInvites (ctx : IDiscordContext) = task {
|
||||||
let! invites = ctx.GetGuild().GetInvitesAsync()
|
let! invites = ctx.GetGuild().GetInvitesAsync()
|
||||||
@ -317,6 +337,40 @@ let sendInitialEmbed (ctx : IDiscordContext) =
|
|||||||
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
|
||||||
|
|
||||||
|
let showWalletStatus (ctx : IDiscordContext) =
|
||||||
|
PlayerInteractions.executePlayerAction ctx (fun player -> async {
|
||||||
|
try
|
||||||
|
match! getWalletAddress player.DiscordId with
|
||||||
|
| Some address -> do! Messaging.sendFollowUpMessage ctx $"We have received your wallet address: {address}"
|
||||||
|
| None -> do! Messaging.sendFollowUpMessage ctx "You have not submitted your wallet yet"
|
||||||
|
with ex ->
|
||||||
|
printfn $"{ex.Message}"
|
||||||
|
do! Messaging.sendFollowUpMessage ctx "Something went wrong retrieving your wallet address"
|
||||||
|
})
|
||||||
|
|
||||||
|
let sendSubmitEmbed (ctx : IDiscordContext) =
|
||||||
|
async {
|
||||||
|
try
|
||||||
|
let channel = ctx.GetGuild().GetChannel(GuildEnvironment.channelSubmitWallet)
|
||||||
|
let rewardMsg = $"Instructions for submitting wallet"
|
||||||
|
let embed =
|
||||||
|
DiscordEmbedBuilder()
|
||||||
|
.WithColor(DiscordColor.White)
|
||||||
|
.WithDescription(rewardMsg)
|
||||||
|
.WithImageUrl("https://logowik.com/content/uploads/images/solana-sol9611.jpg")
|
||||||
|
.WithTitle("Submit Wallet")
|
||||||
|
|
||||||
|
let builder = DiscordMessageBuilder().AddEmbed(embed)
|
||||||
|
let btn = DiscordButtonComponent(ButtonStyle.Success, "WalletStatus", "Check Status") :> DiscordComponent
|
||||||
|
builder.AddComponents [| btn |] |> 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 handleCreateInvite (ctx : IDiscordContext) =
|
let handleCreateInvite (ctx : IDiscordContext) =
|
||||||
task {
|
task {
|
||||||
let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
|
let builder = DiscordInteractionResponseBuilder().AsEphemeral(true)
|
||||||
@ -377,8 +431,9 @@ let handleGuildMemberAdded _ (eventArgs : GuildMemberAddEventArgs) =
|
|||||||
let submitWhitelist (ctx : IDiscordContext) (address : string) =
|
let submitWhitelist (ctx : IDiscordContext) (address : string) =
|
||||||
task {
|
task {
|
||||||
// BtshZ7oNB5tk5pVbDpsRCziZ1qwV7SMCJq1Pe3YbHZuo
|
// BtshZ7oNB5tk5pVbDpsRCziZ1qwV7SMCJq1Pe3YbHZuo
|
||||||
let address = PublicKey(address)
|
let pubkey = PublicKey(address)
|
||||||
if address.IsValid() && address.IsOnCurve() then
|
if pubkey.IsValid() && pubkey.IsOnCurve() then
|
||||||
|
do! addWalletAddress (ctx.GetDiscordMember().Id) address
|
||||||
do! Messaging.sendSimpleResponse ctx "You provided a valid address"
|
do! Messaging.sendSimpleResponse ctx "You provided a valid address"
|
||||||
else
|
else
|
||||||
do! Messaging.sendSimpleResponse ctx "This address is not valid"
|
do! Messaging.sendSimpleResponse ctx "This address is not valid"
|
||||||
@ -388,7 +443,7 @@ let submitWhitelist (ctx : IDiscordContext) (address : string) =
|
|||||||
type Inviter() =
|
type Inviter() =
|
||||||
inherit ApplicationCommandModule ()
|
inherit ApplicationCommandModule ()
|
||||||
|
|
||||||
[<SlashCommand("submit", "Test something")>]
|
[<SlashCommand("submit1", "Test something")>]
|
||||||
member this.SubmitAddress (ctx : InteractionContext, [<Option("address", "Wallet address")>] address : string) =
|
member this.SubmitAddress (ctx : InteractionContext, [<Option("address", "Wallet address")>] address : string) =
|
||||||
submitWhitelist (DiscordInteractionContext ctx) address
|
submitWhitelist (DiscordInteractionContext ctx) address
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ let handleButtonEvent _ (event : ComponentInteractionCreateEventArgs) =
|
|||||||
} :> Task
|
} :> Task
|
||||||
| id when id.StartsWith("CreateGuildInvite") -> InviteTracker.handleCreateInvite ctx
|
| id when id.StartsWith("CreateGuildInvite") -> InviteTracker.handleCreateInvite ctx
|
||||||
| id when id.StartsWith("ShowRecruited") -> InviteTracker.getInvitedUsersForId (ctx.GetDiscordMember()) ctx
|
| id when id.StartsWith("ShowRecruited") -> InviteTracker.getInvitedUsersForId (ctx.GetDiscordMember()) ctx
|
||||||
|
| id when id.StartsWith("WalletStatus") -> InviteTracker.showWalletStatus ctx
|
||||||
| _ ->
|
| _ ->
|
||||||
task {
|
task {
|
||||||
let builder = DiscordInteractionResponseBuilder()
|
let builder = DiscordInteractionResponseBuilder()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user