From 70bbecbc8fb475cdcf7026dc4b2c229ded009f73 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 12 Jan 2017 23:49:17 +0100 Subject: [PATCH] Guild owners can now run permission commands without permission role --- src/NadekoBot/Services/CommandHandler.cs | 3 ++- .../Services/Database/Models/CommandPrice.cs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Services/CommandHandler.cs b/src/NadekoBot/Services/CommandHandler.cs index e4e30c4d..98665bf0 100644 --- a/src/NadekoBot/Services/CommandHandler.cs +++ b/src/NadekoBot/Services/CommandHandler.cs @@ -348,7 +348,8 @@ namespace NadekoBot.Services if (module.Name == typeof(Permissions).Name) { - if (!((IGuildUser)context.User).GetRoles().Any(r => r.Name.Trim().ToLowerInvariant() == pc.PermRole.Trim().ToLowerInvariant())) + var guildUser = (IGuildUser)context.User; + if (!guildUser.GetRoles().Any(r => r.Name.Trim().ToLowerInvariant() == pc.PermRole.Trim().ToLowerInvariant()) && guildUser.Id != guildUser.Guild.OwnerId) { return new ExecuteCommandResult(cmd, pc, SearchResult.FromError(CommandError.Exception, $"You need the **{pc.PermRole}** role in order to use permission commands.")); } diff --git a/src/NadekoBot/Services/Database/Models/CommandPrice.cs b/src/NadekoBot/Services/Database/Models/CommandPrice.cs index 6bc10439..d8b21d76 100644 --- a/src/NadekoBot/Services/Database/Models/CommandPrice.cs +++ b/src/NadekoBot/Services/Database/Models/CommandPrice.cs @@ -9,6 +9,20 @@ namespace NadekoBot.Services.Database.Models public class CommandPrice : DbEntity { public int Price { get; set; } + //this is unique public string CommandName { get; set; } + + public override int GetHashCode() => + CommandName.GetHashCode(); + + public override bool Equals(object obj) + { + var instance = obj as CommandPrice; + + if (instance == null) + return false; + + return instance.CommandName == CommandName; + } } }