25 lines
1.1 KiB
Forth

module Degenz.Admin
open System.Threading.Tasks
open DSharpPlus.Entities
open DSharpPlus.SlashCommands
open Degenz.Messaging
type AdminBot() =
inherit ApplicationCommandModule ()
let enforceAdmin (ctx : IDiscordContext) (adminFn : IDiscordContext -> Task) =
let isAdmin = Seq.exists (fun (role : DiscordRole) -> role.Id = GuildEnvironment.roleAdmin) (ctx.GetDiscordMember().Roles)
if isAdmin then
adminFn ctx
else
Messaging.sendSimpleResponse ctx $"You are not admin" |> Async.StartAsTask :> Task
[<SlashCommand("admin-invites", "Get total invites from a specific user")>]
member this.GetAttributions (ctx : InteractionContext, [<Option("player", "The player you want to check")>] user : DiscordUser) =
enforceAdmin (DiscordInteractionContext ctx) (InviteTracker.getAttributions user.Id)
[<SlashCommand("admin-whitelist-stock", "Set whitelist stock")>]
member this.SetStock (ctx : InteractionContext, [<Option("amount", "Set the amount of WL available for purchase")>] amount : int64) =
enforceAdmin (DiscordInteractionContext ctx) (InviteTracker.setWhitelistStock (int amount))