Task LogSetChange <T, TA>(GuildLog log, string change, T b, T a, Func <T, IEnumerable <TA> > check, Func <TA, string> toString) { var ia = check(a); var ib = check(b); var bIa = ib.Except(ia); var aIb = ia.Except(ib); if (bIa.Any() || aIb.Any()) { var roleLog = $"{change} changed:"; if (aIb.Any()) { roleLog += $" +[{aIb.Select(toString).Join(", ")}]"; } if (bIa.Any()) { roleLog += $" -[{bIa.Select(toString).Join(", ")}]"; } return(log.LogEvent(roleLog)); } return(Task.CompletedTask); }
public GuildLog GetGuild(IGuild guild) { ulong id = Check.NotNull(guild).Id; bool success = !_guilds.ContainsKey(id); if (success) { _guilds[id] = new GuildLog(guild); } return(_guilds[guild.Id]); }
Task LogChange <T, TA>(GuildLog log, string change, T b, T a, Func <T, TA> check) { var valA = check(a); var valB = check(b); if (!EqualityComparer <TA> .Default.Equals(valA, valB)) { return(log.LogEvent($"{change} changed: \"{valB}\" => \"{valA}\"")); } return(Task.CompletedTask); }