public static EmbedBuilder ToEmbed(this IExecutionState state, Action <EmbedBuilder>?pre = null) { var embed = new EmbedBuilder { Title = "Execution Finished", Color = Color.Purple, Footer = new EmbedFooterBuilder().WithText("A Cylon Project") }; embed.Description += $"{state.TotalLinesExecuted} lines executed. Next line: {state.ProgramCounter}"; pre?.Invoke(embed); var locals = state.Where(a => !a.Key.IsExternal).ToArray(); if (locals.Length > 0) { embed.AddField("Locals", string.Join("\n", locals.OrderBy(a => a.Key.Name).Select(a => $"`{a.Key}={a.Value.ToHumanString()}`"))); } var globals = state.Where(a => a.Key.IsExternal).ToArray(); if (globals.Length > 0) { embed.AddField("Globals", string.Join("\n", globals.OrderBy(a => a.Key.Name).Select(a => $"`{a.Key}={a.Value.ToHumanString()}`"))); } return(embed); }
public static EmbedBuilder ToEmbed(this IExecutionState state, Action <EmbedBuilder>?pre = null) { var embed = new EmbedBuilder { Title = "Execution Finished", Color = Color.Purple, Footer = new EmbedFooterBuilder().WithText("A Cylon Project") }; embed.Description += $"{state.TotalLinesExecuted} lines executed. Next line: {state.ProgramCounter}"; pre?.Invoke(embed); BuildFieldsList(embed, "Locals", state.Where(a => !a.Key.IsExternal).ToArray()); BuildFieldsList(embed, "Globals", state.Where(a => a.Key.IsExternal).ToArray()); return(embed); }