Browse Source

fix: Account for team in RequireOwnerAttribute

pull/1838/head
Theodoor 4 years ago
parent
commit
2dc4283a8e
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs

+ 4
- 1
src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;


namespace Discord.Commands namespace Discord.Commands
@@ -44,8 +45,10 @@ namespace Discord.Commands
{ {
case TokenType.Bot: case TokenType.Bot:
var application = await context.Client.GetApplicationInfoAsync().ConfigureAwait(false); var application = await context.Client.GetApplicationInfoAsync().ConfigureAwait(false);
if (context.User.Id != application.Owner.Id)

if (application.Team?.TeamMembers.All(t => t.User.Id != context.User.Id) ?? context.User.Id != application.Owner.Id)
return PreconditionResult.FromError(ErrorMessage ?? "Command can only be run by the owner of the bot."); return PreconditionResult.FromError(ErrorMessage ?? "Command can only be run by the owner of the bot.");

return PreconditionResult.FromSuccess(); return PreconditionResult.FromSuccess();
default: default:
return PreconditionResult.FromError($"{nameof(RequireOwnerAttribute)} is not supported by this {nameof(TokenType)}."); return PreconditionResult.FromError($"{nameof(RequireOwnerAttribute)} is not supported by this {nameof(TokenType)}.");


Loading…
Cancel
Save