Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }