Fix bug and show total users
This commit is contained in:
		
							parent
							
								
									c3e5fafd59
								
							
						
					
					
						commit
						cc65b61e4a
					
				| @ -167,6 +167,20 @@ let private getInvitedUsers userId = | ||||
|     |> Sql.executeAsync (fun read -> read.string "discord_id" |> uint64) | ||||
|     |> Async.AwaitTask | ||||
| 
 | ||||
| let getInvitedUserCount userId = | ||||
|     connStr | ||||
|     |> Sql.connect | ||||
|     |> Sql.parameters [ "did" , Sql.string (string userId) ] | ||||
|     |> Sql.query """ | ||||
|             WITH invite AS (SELECT id FROM invite WHERE inviter = @did) | ||||
|             SELECT count(*) FROM invited_user, invite | ||||
|             WHERE invite.id = invited_user.invite_id AND invited_user.accepted = true | ||||
|         """ | ||||
|     |> Sql.executeRowAsync (fun read -> read.int "count") | ||||
|     |> Async.AwaitTask | ||||
| 
 | ||||
| getInvitedUserCount 822834227467780136uL |> Async.RunSynchronously | ||||
| 
 | ||||
| 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" + | ||||
| @ -231,6 +245,7 @@ let private getAttributions (ctx : IDiscordContext) userId = task { | ||||
| 
 | ||||
| let private getInvitedUsersForId (ctx : IDiscordContext) = task { | ||||
|     let! users = getInvitedUsers (ctx.GetDiscordMember().Id) | ||||
|     let! total = getInvitedUserCount (ctx.GetDiscordMember().Id) | ||||
|     let sb = StringBuilder() | ||||
|     let mutable count = 0 | ||||
|     for user in users do | ||||
| @ -239,7 +254,7 @@ let private getInvitedUsersForId (ctx : IDiscordContext) = task { | ||||
|     let msg = | ||||
|         let str = | ||||
|             if users.Length > 0 then | ||||
|                 $"**Total Recruited:** `{users.Length} Degenz`\n**Total Earned:** `{users.Length * InviteRewardAmount} 💰$GBT`\n\n**Last 10 users recruited:**\n{sb}" | ||||
|                 $"**Total Recruited:** `{total} Degenz`\n**Total Earned:** `{total * InviteRewardAmount} 💰$GBT`\n\n**Last 10 users recruited:**\n{sb}" | ||||
|             else | ||||
|                 $"You haven't recruited anyone yet, use the `/recruit` command to get the recruitment link" | ||||
|         DiscordInteractionResponseBuilder() | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user