public async Task HandleMessage(SocketMessage message) { if (!(message.Author.IsBot || message.Author.IsWebhook)) { string content = message.Content.Trim(); if (content.StartsWith(CommandPrefix)) { try { string[] splitMsg = content.Split(null); string command = splitMsg[0].Substring(CommandPrefix.Length).ToLower(); Log.Enter($"Received command '{command}'!"); Commands.CommandInformation cmdinfo = new Commands.CommandInformation { SocketMessage = message, messages = new Messaging((ITextChannel)message.Channel), arguments = Util.SubArray(splitMsg, 1), ServerEntry = Database.Fetch(((SocketGuildChannel)message.Channel).Guild.Id) }; cmdinfo.AuthorEntry = cmdinfo.ServerEntry[message.Author.Id]; Commands.CommandRegistry.Run(command, cmdinfo); } catch (Exceptions.SaftException saftEx) { // A saftbot-internal exception technically shouldn't end up here, but it isn't a big enough deal to warn the user Log.Enter($"Saftbot-internal Exception caught while trying to execute command:\n\t{message.Content}\n" + $"Content:\n{saftEx}"); } catch (Exception ex) { // On the other hand, any other kind of exception indicates a fatal flaw in whatever command the user was calling await new Messaging((ITextChannel)message.Channel).Send($"The command you tried caused an error!\n" + $"If this has happend before, please report it at {Exceptions.SaftException.repoLink}\n"); Log.Enter($"Exception caught while trying to execute command:\n\t{message.Content}"); Log.Enter(ex); } } } }