Guild owners can now run permission commands without permission role

This commit is contained in:
Kwoth 2017-01-12 23:49:17 +01:00
parent 09691adcc6
commit 70bbecbc8f
2 changed files with 16 additions and 1 deletions

View File

@ -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."));
}

View File

@ -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;
}
}
}