Guild owners can now run permission commands without permission role
This commit is contained in:
		@@ -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."));
 | 
			
		||||
                        }
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user