move admin check to ContextChecksExt, allow pk;debug proxy for staff in support server
This commit is contained in:
@@ -21,7 +21,7 @@ namespace PluralKit.Bot
|
||||
|
||||
public async Task UpdateSystemId(Context ctx)
|
||||
{
|
||||
AssertBotAdmin(ctx);
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
var target = await ctx.MatchSystem();
|
||||
if (target == null)
|
||||
@@ -44,7 +44,7 @@ namespace PluralKit.Bot
|
||||
|
||||
public async Task UpdateMemberId(Context ctx)
|
||||
{
|
||||
AssertBotAdmin(ctx);
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
var target = await ctx.MatchMember();
|
||||
if (target == null)
|
||||
@@ -67,7 +67,7 @@ namespace PluralKit.Bot
|
||||
|
||||
public async Task UpdateGroupId(Context ctx)
|
||||
{
|
||||
AssertBotAdmin(ctx);
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
var target = await ctx.MatchGroup();
|
||||
if (target == null)
|
||||
@@ -90,7 +90,7 @@ namespace PluralKit.Bot
|
||||
|
||||
public async Task SystemMemberLimit(Context ctx)
|
||||
{
|
||||
AssertBotAdmin(ctx);
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
var target = await ctx.MatchSystem();
|
||||
if (target == null)
|
||||
@@ -120,7 +120,7 @@ namespace PluralKit.Bot
|
||||
|
||||
public async Task SystemGroupLimit(Context ctx)
|
||||
{
|
||||
AssertBotAdmin(ctx);
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
var target = await ctx.MatchSystem();
|
||||
if (target == null)
|
||||
@@ -147,16 +147,5 @@ namespace PluralKit.Bot
|
||||
});
|
||||
await ctx.Reply($"{Emojis.Success} Group limit updated.");
|
||||
}
|
||||
|
||||
private void AssertBotAdmin(Context ctx)
|
||||
{
|
||||
if (!IsBotAdmin(ctx))
|
||||
throw new PKError("This command is only usable by bot admins.");
|
||||
}
|
||||
|
||||
private bool IsBotAdmin(Context ctx)
|
||||
{
|
||||
return _botConfig.AdminRole != null && ctx.Member.Roles.Contains(_botConfig.AdminRole.Value);
|
||||
}
|
||||
}
|
||||
}
|
@@ -263,10 +263,12 @@ namespace PluralKit.Bot
|
||||
|
||||
if ((_botConfig.Prefixes ?? BotConfig.DefaultPrefixes).Any(p => msg.Content.StartsWith(p)))
|
||||
await ctx.Reply("This message starts with the bot's prefix, and was parsed as a command.");
|
||||
if (msg.Author.Bot)
|
||||
throw new PKError("You cannot check messages sent by a bot.");
|
||||
if (msg.WebhookId != null)
|
||||
await ctx.Reply("You cannot check messages sent by a webhook.");
|
||||
if (msg.Author.Id != ctx.Author.Id)
|
||||
await ctx.Reply("You can only check your own messages.");
|
||||
throw new PKError("You cannot check messages sent by a webhook.");
|
||||
if (msg.Author.Id != ctx.Author.Id && !ctx.CheckBotAdmin())
|
||||
throw new PKError("You can only check your own messages.");
|
||||
|
||||
// get the channel info
|
||||
var channel = _cache.GetChannel(channelId.Value);
|
||||
|
Reference in New Issue
Block a user