move admin check to ContextChecksExt, allow pk;debug proxy for staff in support server

This commit is contained in:
spiral
2021-09-26 20:42:08 -04:00
parent 94f4f970ea
commit fa66fbe247
3 changed files with 28 additions and 19 deletions

View File

@@ -1,3 +1,7 @@
using System.Linq;
using Autofac;
using Myriad.Types;
using PluralKit.Core;
@@ -52,5 +56,19 @@ namespace PluralKit.Bot
throw new PKError($"You must have the \"{permissionName}\" permission in this server to use this command.");
return ctx;
}
public static bool CheckBotAdmin(this Context ctx)
{
var botConfig = ctx.Services.Resolve<BotConfig>();
return botConfig.AdminRole != null && ctx.Member != null && ctx.Member.Roles.Contains(botConfig.AdminRole.Value);
}
public static Context AssertBotAdmin(this Context ctx)
{
if (!ctx.CheckBotAdmin())
throw new PKError("This command is only usable by bot admins.");
return ctx;
}
}
}