Cache the current application on DiscordSocketClient

This commit is contained in:
Christopher F
2016-11-26 14:59:20 -05:00
parent defc8f1c4e
commit 1ed4f703bf
2 changed files with 6 additions and 6 deletions

View File

@@ -13,12 +13,9 @@ namespace Discord.Commands
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class RequireOwnerAttribute : PreconditionAttribute
{
private IApplication application;
public override async Task<PreconditionResult> CheckPermissions(CommandContext context, CommandInfo command, IDependencyMap map)
{
if (application == null)
application = await context.Client.GetApplicationInfoAsync();
var application = await context.Client.GetApplicationInfoAsync();
if (context.User.Id == application.Owner.Id) return PreconditionResult.FromSuccess();
return PreconditionResult.FromError("Command can only be run by the owner of the bot");
}