private Embed CreateEmbedResponse(ModerationLogEntry logEntry) { EmbedBuilder builder = new EmbedBuilder(); StringBuilder author = new StringBuilder($"[{logEntry.ActionType.Humanize()}]"); List <string> footnotes = new List <string>(); if (logEntry.HasTarget) { if (logEntry.Target != null) { author.Append($" {logEntry.Target.Username}#{logEntry.Target.Discriminator}"); } else { author.Append($" {logEntry.TargetID}"); } footnotes.Add(logEntry.TargetID.ToString()); } if (logEntry.InfractionId > -1) { footnotes.Add($"Infraction ID: {logEntry.InfractionId}"); } // Split user and infraction ID by bullet point builder.WithFooter(string.Join(" \u2022 ", footnotes)); // First display the Reason, then any additional fields; looks better. builder.AddFieldConditional(!string.IsNullOrWhiteSpace(logEntry.Reason), "Reason", logEntry.Reason); // AddFieldConditional won't work because the logEntry.Duration.Value will be resolved first, which can be a NullReferenceException because // it is not guarantueed Duration will be non-null. if (logEntry.Duration.HasValue) { builder.AddField("Duration", logEntry.Duration.Value.Humanize(7)); } return(builder .WithAuthor(author.ToString(), logEntry.Target?.EnsureAvatarUrl()) .WithColor(GetColorForAction(logEntry.ActionType)) .Build()); }