public async Task Remove(string blocktype, IRole role) { var type = BlockModule.ParseBlockType(blocktype.ToLower()); var ignore = _unit.Ignores.Get(role).FirstOrDefault(ig => ig.BlockType == type); if (ignore != null) { _unit.Ignores.Remove(ignore); _unit.SaveChanges(); await ReplyAsync($":white_check_mark: Removed User {role}`(ID: {role.Id})` from whitelist for blocktype `{type}`"); } else { await ReplyAsync($":exclamation: User {role}`(ID: {role.Id})` is not whitelisted for blocktype `{type}`!"); } }
public async Task Add(string blocktype, IRole role) { var type = BlockModule.ParseBlockType(blocktype.ToLower()); var ignores = _unit.Ignores.Get(role); if (ignores.All(ignore => ignore.BlockType != type)) { var ignore = new Ignore(Context.Guild, role, type); await _unit.Ignores.AddAsync(ignore); _unit.SaveChanges(); await ReplyAsync($":white_check_mark: Added Role {role}`(ID: {role.Id})` to whitelist for blocktype `{type}`"); } else { await ReplyAsync($":exclamation: Role {role}`(ID: {role.Id})` is already whitelisted for blocktype `{type}`!"); } }