From 2dc4283a8e1aaeb68f87ed146224f53dae080e7a Mon Sep 17 00:00:00 2001 From: Theodoor Date: Wed, 12 May 2021 18:42:50 +0200 Subject: [PATCH] fix: Account for team in RequireOwnerAttribute --- .../Attributes/Preconditions/RequireOwnerAttribute.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs b/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs index c08e1e9da..8e1062cc4 100644 --- a/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/Preconditions/RequireOwnerAttribute.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Threading.Tasks; namespace Discord.Commands @@ -44,8 +45,10 @@ namespace Discord.Commands { case TokenType.Bot: 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.FromSuccess(); default: return PreconditionResult.FromError($"{nameof(RequireOwnerAttribute)} is not supported by this {nameof(TokenType)}.");