From 0e77c26b82d9203aa50268643610b1875176651c Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Tue, 5 Apr 2022 12:52:00 +0700 Subject: [PATCH] Use same recruited embed --- Bot/Admin.fs | 2 +- Bot/InviteTracker.fs | 45 ++++++++++++++++++++++---------------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Bot/Admin.fs b/Bot/Admin.fs index 05fabf3..69c85fc 100644 --- a/Bot/Admin.fs +++ b/Bot/Admin.fs @@ -17,7 +17,7 @@ type AdminBot() = [] member this.GetAttributions (ctx : InteractionContext, [] user : DiscordUser) = - enforceAdmin (DiscordInteractionContext ctx) (InviteTracker.getAttributions user.Id) + enforceAdmin (DiscordInteractionContext ctx) (InviteTracker.getInvitedUsersForId) [] member this.SetStock (ctx : InteractionContext, [] amount : int64) = diff --git a/Bot/InviteTracker.fs b/Bot/InviteTracker.fs index 02356f8..8297df7 100644 --- a/Bot/InviteTracker.fs +++ b/Bot/InviteTracker.fs @@ -242,28 +242,29 @@ let getAttributions userId (ctx : IDiscordContext) = do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, msg) } :> 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 - count <- count + 1 - sb.AppendLine($"{count}.) <@{user}>") |> ignore - let msg = - let str = - if users.Length > 0 then - $"**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() - .AsEphemeral(true) - .WithContent(str) - do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, msg) - let user = ctx.GetDiscordMember() - let channel = ctx.GetChannel() - do! Analytics.recruitedCommand total user.Id user.Username channel -} +let 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 + count <- count + 1 + sb.AppendLine($"{count}.) <@{user}>") |> ignore + let msg = + let str = + if users.Length > 0 then + $"**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() + .AsEphemeral(true) + .WithContent(str) + do! ctx.Respond(InteractionResponseType.ChannelMessageWithSource, msg) + let user = ctx.GetDiscordMember() + let channel = ctx.GetChannel() + do! Analytics.recruitedCommand total user.Id user.Username channel + } :> Task let clearInvites (ctx : IDiscordContext) = task { let! invites = ctx.GetGuild().GetInvitesAsync()