private void ProcessCommand(string rawString, MessageCreateEventArgs e, CommandTrigger type) { // The first thing we do is get rid of the prefix string from the command. We take the message from looking like say this: // --say something // to // say something // that way we don't have any excess characters getting in the way. string rawCommand = rawString.Substring(config.Prefix.Length); // A try catch block for executing the command and catching various things and reporting on errors. try { if (type == CommandTrigger.MessageCreate) { commandManager.ExecuteOnMessageCommand(rawCommand, e.Channel, e.Author, e.Message, client); } else if (type == CommandTrigger.BotMentioned) { commandManager.ExecuteOnMentionCommand(rawCommand, e.Channel, e.Author, e.Message, client); } } catch (UnauthorizedAccessException ex) // Bad permission { e.Channel.SendMessageAsync(ex.Message); } catch (ModuleNotEnabledException x) // Module is disabled { e.Channel.SendMessageAsync($"{x.Message}"); } catch (Exception ex) // Any other error that could happen inside of the commands. { e.Channel.SendMessageAsync("Exception occurred while running command:\n```\n" + ex.Message + "\n```"); } }