diff --git a/Volte/Core/Commands/Modules/Owner/EvalCommand.cs b/Volte/Core/Commands/Modules/Owner/EvalCommand.cs index 95715e37..7c5f6052 100644 --- a/Volte/Core/Commands/Modules/Owner/EvalCommand.cs +++ b/Volte/Core/Commands/Modules/Owner/EvalCommand.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.IO; using System.Linq; using System.Threading.Tasks; using Discord; @@ -34,7 +35,7 @@ public async Task Eval([Remainder] string code) { } var objects = new EvalObjects { - Ctx = Context, + Context = Context, CommandService = VolteBot.CommandService, Config = Db.GetConfig(Context.Guild), DatabaseService = Db, @@ -50,7 +51,7 @@ public async Task Eval([Remainder] string code) { sopts = sopts.WithImports(imports).WithReferences(AppDomain.CurrentDomain.GetAssemblies() .Where(x => !x.IsDynamic && !string.IsNullOrWhiteSpace(x.Location))); - var msg = await embed.WithDescription("Evaluating...").SendTo(Context.Channel); + var msg = await embed.WithTitle("Evaluating...").SendTo(Context.Channel); var sw = new Stopwatch(); sw.Start(); try { @@ -58,14 +59,16 @@ public async Task Eval([Remainder] string code) { sw.Stop(); if (res != null) { await msg.DeleteAsync(); - await embed.WithDescription("**Eval**") + await embed.WithTitle("Eval") + .AddField("Elapsed Time", $"{sw.ElapsedMilliseconds}ms") .AddField("Input", Format.Code(code, "cs")) .AddField("Output", Format.Code(code, "cs")) .SendTo(Context.Channel); } else { await msg.DeleteAsync(); - await embed.WithDescription("**Eval**") + await embed.WithTitle("Eval") + .AddField("Elapsed Time", $"{sw.ElapsedMilliseconds}ms") .AddField("Input", Format.Code(code, "cs")) .AddField("Output", "No output.") .SendTo(Context.Channel); @@ -73,7 +76,13 @@ await embed.WithDescription("**Eval**") } catch (Exception e) { await msg.ModifyAsync(m => - m.Embed = embed.WithDescription($"Error! {e.Message}\n```{e.StackTrace}```").Build()); + m.Embed = embed + .WithDescription($"`{e.Message}`") + .WithTitle("Error") + .Build()); + File.WriteAllText("data/EvalError.log", $"{e.Message}\n{e.StackTrace}"); + await Context.Channel.SendFileAsync("data/EvalError.log"); + File.Delete("data/EvalError.log"); } finally { GC.Collect(); diff --git a/Volte/Core/Data/Objects/EvalObjects.cs b/Volte/Core/Data/Objects/EvalObjects.cs index dc84612a..7fa8d469 100644 --- a/Volte/Core/Data/Objects/EvalObjects.cs +++ b/Volte/Core/Data/Objects/EvalObjects.cs @@ -4,7 +4,7 @@ namespace Volte.Core.Data.Objects { public class EvalObjects { - public VolteContext Ctx { get; set; } + public VolteContext Context { get; set; } public Server Config { get; set; } public LoggingService Logger { get; set; } public CommandService CommandService { get; set; } diff --git a/Volte/Core/Services/LoggingService.cs b/Volte/Core/Services/LoggingService.cs index 5fc46bd1..87a98549 100644 --- a/Volte/Core/Services/LoggingService.cs +++ b/Volte/Core/Services/LoggingService.cs @@ -37,7 +37,8 @@ public void DoLog(LogSeverity s, string src, string message, Exception e) { Append(message, Color.White); if (e != null) - Append(e.Message, Color.IndianRed); + Append($"{e.Message}\n{e.StackTrace}", Color.IndianRed); + Write(Environment.NewLine); }