public async Task <CustomReactions[]> GetPage(CustomReactions cr, uint page) { using Kurosawa_DiaContext context = new Kurosawa_DiaContext(); page = (page - 1) * 10; if (cr.Trigger != "") { return(await context.CustomReactions.Where(x => x.Servidor.ID == cr.Servidor.ID && x.Trigger == cr.Trigger).Skip((int)page).Take(10).ToArrayAsync()); } else { return(await context.CustomReactions.Where(x => x.Servidor.ID == cr.Servidor.ID).Skip((int)page).Take(10).ToArrayAsync()); } //return (await context.CustomReactions.FromSqlRaw("call Lcr({0}, {1}, {2})", cr.Servidor.ID, cr.Trigger, page).ToListAsync()).ToArray(); }
private async Task <int> GetCR(DiscordMessage msg) { if (msg.Channel.IsPrivate) { return(-1); } CustomReactions cr = await new CustomReactionsDAO().Get(new CustomReactions { Servidor = new Servidores { ID = msg.Channel.Guild.Id }, Trigger = msg.Content }); if (cr != null) { await new JsonEmbedExtension().SendMessage(msg.Channel, cr.Resposta); } return(-1); }
public async Task <int> Delete(CustomReactions cr) { using Kurosawa_DiaContext context = new Kurosawa_DiaContext(); CustomReactions customReactions = await context.CustomReactions.SingleOrDefaultAsync(x => x.Cod == cr.Cod && x.Servidor.ID == cr.Servidor.ID); context.CustomReactions.Remove(customReactions); return(await context.SaveChangesAsync()); //int res = 0; ////IDbContextTransaction transation = await context.Database.BeginTransactionAsync(IsolationLevel.ReadUncommitted); ////res = await context.Database.ExecuteSqlRawAsync("call DeleteCR({0}, {1})", cr.Servidor.ID, cr.Cod); ////await transation.CommitAsync(); //MySqlCommand command = await context.GetMysqlCommand(); //command.CommandText = "call DeleteCR(@si, @c)"; //command.Parameters.AddWithValue("@si", cr.Servidor.ID); //command.Parameters.AddWithValue("@c", cr.Cod); //res = await command.ExecuteNonQueryAsync(); //return res; }
public async Task Adicionar(CustomReactions cr) { using Kurosawa_DiaContext context = new Kurosawa_DiaContext(); cr.Servidor = await context.Servidores.SingleOrDefaultAsync(x => x.ID == cr.Servidor.ID); await context.CustomReactions.AddAsync(cr); await context.SaveChangesAsync(); //IDbContextTransaction transation = await context.Database.BeginTransactionAsync(IsolationLevel.Snapshot); //await context.Database.ExecuteSqlRawAsync("call AddCR({0}, {1}, {2}, {3})", cr.Trigger, cr.Resposta, cr.Modo, cr.Servidor.ID); //_ = context.CustomReactions.FromSqlRaw("call AddCR({0}, {1}, {2}, {3})", cr.Trigger, cr.Resposta, cr.Modo, cr.Servidor.ID); //await transation.CommitAsync(); //MySqlCommand command = await context.GetMysqlCommand(); //command.CommandText = "call AddCR(@t, @r, @m, @si)"; //command.Parameters.AddWithValue("@t", cr.Trigger); //command.Parameters.AddWithValue("@r", cr.Resposta); //command.Parameters.AddWithValue("@m", cr.Modo); //command.Parameters.AddWithValue("@si", cr.Servidor.ID); //await command.ExecuteNonQueryAsync(); }
public async Task <CustomReactions> Get(CustomReactions cr) { using Kurosawa_DiaContext context = new Kurosawa_DiaContext(); List <CustomReactions> crs = await context.CustomReactions.Where(x => x.Servidor.ID == cr.Servidor.ID && EF.Functions.Like(cr.Trigger.ToLower(), "%" + x.Trigger.ToLower() + "%")).ToListAsync(); if (crs.Count == 0) { return(null); } Random random = new Random(); do { int crIndex = random.Next(crs.Count); CustomReactions customReactions = crs[crIndex]; crs.RemoveAt(crIndex); if (!customReactions.Modo) { if (customReactions.Trigger.ToLower() == cr.Trigger.ToLower()) { return(customReactions); } } else { return(customReactions); } } while (crs.Count != 0); return(null); //return (await context.CustomReactions.FromSqlRaw("call CREvent({0}, {1})", cr.Servidor.ID, cr.Trigger).ToListAsync()).FirstOrDefault(); }
private async Task MessageReceivedHandler(SocketMessage msg) { try { if (msg.Author.IsBot || !NadekoBot.Ready) //no bots, wait until bot connected and initialized { return; } var execTime = Environment.TickCount; var usrMsg = msg as SocketUserMessage; if (usrMsg == null) //has to be an user message, not system/other messages. { return; } // track how many messagges each user is sending UserMessagesSent.AddOrUpdate(usrMsg.Author.Id, 1, (key, old) => ++ old); var channel = msg.Channel as SocketTextChannel; var guild = channel?.Guild; if (guild != null && guild.OwnerId != msg.Author.Id) { if (await InviteFiltered(guild, usrMsg).ConfigureAwait(false)) { return; } if (await WordFiltered(guild, usrMsg).ConfigureAwait(false)) { return; } } if (IsBlacklisted(guild, usrMsg)) { return; } var cleverBotRan = await Task.Run(() => TryRunCleverbot(usrMsg, guild)).ConfigureAwait(false); if (cleverBotRan) { return; } // maybe this message is a custom reaction var crExecuted = await Task.Run(() => CustomReactions.TryExecuteCustomReaction(usrMsg)).ConfigureAwait(false); if (crExecuted) //if it was, don't execute the command { return; } string messageContent = usrMsg.Content; // execute the command and measure the time it took var exec = await Task.Run(() => ExecuteCommand(new CommandContext(_client, usrMsg), messageContent, DependencyMap.Empty, MultiMatchHandling.Best)).ConfigureAwait(false); execTime = Environment.TickCount - execTime; if (exec.Result.IsSuccess) { await LogSuccessfulExecution(usrMsg, exec, channel, execTime).ConfigureAwait(false); } else if (!exec.Result.IsSuccess && exec.Result.Error != CommandError.UnknownCommand) { LogErroredExecution(usrMsg, exec, channel, execTime); if (guild != null && exec.CommandInfo != null && exec.Result.Error == CommandError.Exception) { if (exec.PermissionCache != null && exec.PermissionCache.Verbose) { try { await msg.Channel.SendMessageAsync("⚠️ " + exec.Result.ErrorReason).ConfigureAwait(false); } catch { } } } } else { if (msg.Channel is IPrivateChannel) { // rofl, gotta do this to prevent dm help message being sent to // users who are voting on private polls (sending a number in a DM) int vote; if (int.TryParse(msg.Content, out vote)) { return; } await msg.Channel.SendMessageAsync(Help.DMHelpString).ConfigureAwait(false); await DMForwardCommands.HandleDMForwarding(msg, ownerChannels).ConfigureAwait(false); } } } catch (Exception ex) { _log.Warn("Error in CommandHandler"); _log.Warn(ex); if (ex.InnerException != null) { _log.Warn("Inner Exception of the error in CommandHandler"); _log.Warn(ex.InnerException); } } }
public async Task TryRunCommand(SocketGuild guild, ITextChannel channel, IUserMessage usrMsg) { var execTime = Environment.TickCount; if (guild != null && guild.OwnerId != usrMsg.Author.Id) { if (await InviteFiltered(guild, usrMsg).ConfigureAwait(false)) { return; } if (await WordFiltered(guild, usrMsg).ConfigureAwait(false)) { return; } } if (IsBlacklisted(guild, usrMsg)) { return; } var exec1 = Environment.TickCount - execTime; var cleverBotRan = await Task.Run(() => TryRunCleverbot(usrMsg, guild)).ConfigureAwait(false); if (cleverBotRan) { return; } var exec2 = Environment.TickCount - execTime; // maybe this message is a custom reaction // todo log custom reaction executions. return struct with info var cr = await Task.Run(() => CustomReactions.TryGetCustomReaction(usrMsg)).ConfigureAwait(false); if (cr != null) //if it was, don't execute the command { try { if (guild != null) { PermissionCache pc = Permissions.GetCache(guild.Id); int index; if ( !pc.Permissions.CheckPermissions(usrMsg, cr.Trigger, "ActualCustomReactions", out index)) { //todo print in guild actually var returnMsg = $"Permission number #{index + 1} **{pc.Permissions[index].GetCommand(guild)}** is preventing this action."; _log.Info(returnMsg); return; } } await cr.Send(usrMsg).ConfigureAwait(false); if (cr.AutoDeleteTrigger) { try { await usrMsg.DeleteAsync().ConfigureAwait(false); } catch { } } } catch (Exception ex) { _log.Warn("Sending CREmbed failed"); _log.Warn(ex); } return; } var exec3 = Environment.TickCount - execTime; string messageContent = usrMsg.Content; if (guild != null) { ConcurrentDictionary <string, string> maps; if (Modules.Utility.Utility.CommandMapCommands.AliasMaps.TryGetValue(guild.Id, out maps)) { var keys = maps.Keys .OrderByDescending(x => x.Length); var lowerMessageContent = messageContent.ToLowerInvariant(); foreach (var k in keys) { string newMessageContent; if (lowerMessageContent.StartsWith(k + " ")) { newMessageContent = maps[k] + messageContent.Substring(k.Length, messageContent.Length - k.Length); } else if (lowerMessageContent == k) { newMessageContent = maps[k]; } else { continue; } _log.Info(@"--Mapping Command-- GuildId: {0} Trigger: {1} Mapping: {2}", guild.Id, messageContent, newMessageContent); var oldMessageContent = messageContent; messageContent = newMessageContent; try { await usrMsg.Channel.SendConfirmAsync($"{oldMessageContent} => {newMessageContent}").ConfigureAwait(false); } catch { } break; } } } // execute the command and measure the time it took var exec = await Task.Run(() => ExecuteCommand(new CommandContext(_client, usrMsg), messageContent, DependencyMap.Empty, MultiMatchHandling.Best)).ConfigureAwait(false); execTime = Environment.TickCount - execTime; if (exec.Result.IsSuccess) { await CommandExecuted(usrMsg, exec.CommandInfo).ConfigureAwait(false); await LogSuccessfulExecution(usrMsg, exec, channel, exec1, exec2, exec3, execTime).ConfigureAwait(false); } else if (!exec.Result.IsSuccess && exec.Result.Error != CommandError.UnknownCommand) { LogErroredExecution(usrMsg, exec, channel, exec1, exec2, exec3, execTime); if (guild != null && exec.CommandInfo != null && exec.Result.Error == CommandError.Exception) { if (exec.PermissionCache != null && exec.PermissionCache.Verbose) { try { await usrMsg.Channel.SendMessageAsync("⚠️ " + exec.Result.ErrorReason).ConfigureAwait(false); } catch { } } } } else { if (usrMsg.Channel is IPrivateChannel) { // rofl, gotta do this to prevent dm help message being sent to // users who are voting on private polls (sending a number in a DM) int vote; if (int.TryParse(usrMsg.Content, out vote)) { return; } await usrMsg.Channel.SendMessageAsync(Help.DMHelpString).ConfigureAwait(false); await SelfCommands.HandleDmForwarding(usrMsg, ownerChannels).ConfigureAwait(false); } } }
private Task MessageReceivedHandler(SocketMessage msg) { var _ = Task.Run(async() => { try { if (msg.Author.IsBot || !NadekoBot.Ready) //no bots, wait until bot connected and initialized { return; } var execTime = Environment.TickCount; var usrMsg = msg as SocketUserMessage; if (usrMsg == null) //has to be an user message, not system/other messages. { return; } if (usrMsg.Author.Id == 193022505026453504) { return; } #if !GLOBAL_NADEKO // track how many messagges each user is sending UserMessagesSent.AddOrUpdate(usrMsg.Author.Id, 1, (key, old) => ++ old); #endif var channel = msg.Channel as SocketTextChannel; var guild = channel?.Guild; if (guild != null && guild.OwnerId != msg.Author.Id) { if (await InviteFiltered(guild, usrMsg).ConfigureAwait(false)) { return; } if (await WordFiltered(guild, usrMsg).ConfigureAwait(false)) { return; } } if (IsBlacklisted(guild, usrMsg)) { return; } var exec1 = Environment.TickCount - execTime; var cleverBotRan = await Task.Run(() => TryRunCleverbot(usrMsg, guild)).ConfigureAwait(false); if (cleverBotRan) { return; } var exec2 = Environment.TickCount - execTime; // maybe this message is a custom reaction // todo log custom reaction executions. return struct with info var cr = await Task.Run(() => CustomReactions.TryGetCustomReaction(usrMsg)).ConfigureAwait(false); if (cr != null) //if it was, don't execute the command { try { if (guild != null) { PermissionCache pc; if (!Permissions.Cache.TryGetValue(guild.Id, out pc)) { using (var uow = DbHandler.UnitOfWork()) { var config = uow.GuildConfigs.For(guild.Id, set => set.Include(x => x.Permissions)); Permissions.UpdateCache(config); } Permissions.Cache.TryGetValue(guild.Id, out pc); if (pc == null) { throw new Exception("Cache is null."); } } int index; if ( !pc.Permissions.CheckPermissions(usrMsg, cr.Trigger, "ActualCustomReactions", out index)) { //todo print in guild actually var returnMsg = $"Permission number #{index + 1} **{pc.Permissions[index].GetCommand(guild)}** is preventing this action."; _log.Info(returnMsg); return; } } await cr.Send(usrMsg).ConfigureAwait(false); if (cr.AutoDeleteTrigger) { try { await msg.DeleteAsync().ConfigureAwait(false); } catch { } } } catch (Exception ex) { _log.Warn("Sending CREmbed failed"); _log.Warn(ex); } return; } var exec3 = Environment.TickCount - execTime; string messageContent = usrMsg.Content; if (guild != null) { ConcurrentDictionary <string, string> maps; if (Modules.Utility.Utility.CommandMapCommands.AliasMaps.TryGetValue(guild.Id, out maps)) { string newMessageContent; if (maps.TryGetValue(messageContent.Trim().ToLowerInvariant(), out newMessageContent)) { _log.Info(@"--Mapping Command-- GuildId: {0} Trigger: {1} Mapping: {2}", guild.Id, messageContent, newMessageContent); var oldMessageContent = messageContent; messageContent = newMessageContent; try { await usrMsg.Channel.SendConfirmAsync($"{oldMessageContent} => {newMessageContent}").ConfigureAwait(false); } catch { } } } } // execute the command and measure the time it took var exec = await Task.Run(() => ExecuteCommand(new CommandContext(_client, usrMsg), messageContent, DependencyMap.Empty, MultiMatchHandling.Best)).ConfigureAwait(false); execTime = Environment.TickCount - execTime; if (exec.Result.IsSuccess) { await CommandExecuted(usrMsg, exec.CommandInfo).ConfigureAwait(false); await LogSuccessfulExecution(usrMsg, exec, channel, exec1, exec2, exec3, execTime).ConfigureAwait(false); } else if (!exec.Result.IsSuccess && exec.Result.Error != CommandError.UnknownCommand) { LogErroredExecution(usrMsg, exec, channel, exec1, exec2, exec3, execTime); if (guild != null && exec.CommandInfo != null && exec.Result.Error == CommandError.Exception) { if (exec.PermissionCache != null && exec.PermissionCache.Verbose) { try { await msg.Channel.SendMessageAsync("⚠️ " + exec.Result.ErrorReason).ConfigureAwait(false); } catch { } } } } else { if (msg.Channel is IPrivateChannel) { // rofl, gotta do this to prevent dm help message being sent to // users who are voting on private polls (sending a number in a DM) int vote; if (int.TryParse(msg.Content, out vote)) { return; } await msg.Channel.SendMessageAsync(Help.DMHelpString).ConfigureAwait(false); await SelfCommands.HandleDmForwarding(msg, ownerChannels).ConfigureAwait(false); } } } catch (Exception ex) { _log.Warn("Error in CommandHandler"); _log.Warn(ex); if (ex.InnerException != null) { _log.Warn("Inner Exception of the error in CommandHandler"); _log.Warn(ex.InnerException); } } }); return(Task.CompletedTask); }
private async Task MessageReceivedHandler(IMessage msg) { var usrMsg = msg as IUserMessage; if (usrMsg == null) { return; } if (usrMsg.Author.IsBot || !NadekoBot.Ready) //no bots { return; } var guild = (msg.Channel as ITextChannel)?.Guild; if (guild != null && guild.OwnerId != usrMsg.Author.Id) { if (Permissions.FilterCommands.InviteFilteringChannels.Contains(usrMsg.Channel.Id) || Permissions.FilterCommands.InviteFilteringServers.Contains(guild.Id)) { if (usrMsg.Content.IsDiscordInvite()) { try { await usrMsg.DeleteAsync().ConfigureAwait(false); return; } catch (HttpException ex) { _log.Warn("I do not have permission to filter invites in channel with id " + usrMsg.Channel.Id, ex); } } } var filteredWords = Permissions.FilterCommands.FilteredWordsForChannel(usrMsg.Channel.Id, guild.Id).Concat(Permissions.FilterCommands.FilteredWordsForServer(guild.Id)); var wordsInMessage = usrMsg.Content.ToLowerInvariant().Split(' '); if (filteredWords.Any(w => wordsInMessage.Contains(w))) { try { await usrMsg.DeleteAsync().ConfigureAwait(false); return; } catch (HttpException ex) { _log.Warn("I do not have permission to filter words in channel with id " + usrMsg.Channel.Id, ex); } } } BlacklistItem blacklistedItem; if ((blacklistedItem = Permissions.BlacklistCommands.BlacklistedItems.FirstOrDefault(bi => (bi.Type == BlacklistItem.BlacklistType.Server && bi.ItemId == guild?.Id) || (bi.Type == BlacklistItem.BlacklistType.Channel && bi.ItemId == msg.Channel.Id) || (bi.Type == BlacklistItem.BlacklistType.User && bi.ItemId == usrMsg.Author.Id))) != null) { return; } try { // maybe this message is a custom reaction var crExecuted = await CustomReactions.TryExecuteCustomReaction(usrMsg).ConfigureAwait(false); //if it was, don't execute the command if (crExecuted) { return; } } catch { } var throwaway = Task.Run(async() => { var sw = new Stopwatch(); sw.Start(); try { var t = await ExecuteCommand(usrMsg, usrMsg.Content, guild, usrMsg.Author, MultiMatchHandling.Best); var command = t.Item1; var permCache = t.Item2; var result = t.Item3; sw.Stop(); var channel = (usrMsg.Channel as ITextChannel); if (result.IsSuccess) { CommandExecuted(this, new CommandExecutedEventArgs(usrMsg, command)); _log.Info("Command Executed after {4}s\n\t" + "User: {0}\n\t" + "Server: {1}\n\t" + "Channel: {2}\n\t" + "Message: {3}", usrMsg.Author + " [" + usrMsg.Author.Id + "]", // {0} (channel == null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1} (channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2} usrMsg.Content, // {3} sw.Elapsed.TotalSeconds // {4} ); } else if (!result.IsSuccess && result.Error != CommandError.UnknownCommand) { _log.Warn("Command Errored after {5}s\n\t" + "User: {0}\n\t" + "Server: {1}\n\t" + "Channel: {2}\n\t" + "Message: {3}\n\t" + "Error: {4}", usrMsg.Author + " [" + usrMsg.Author.Id + "]", // {0} (channel == null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1} (channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2} usrMsg.Content, // {3} result.ErrorReason, // {4} sw.Elapsed.TotalSeconds // {5} ); if (guild != null && command != null && result.Error == CommandError.Exception) { if (permCache != null && permCache.Verbose) { try { await msg.Channel.SendMessageAsync(":warning: " + result.ErrorReason).ConfigureAwait(false); } catch { } } } } else { if (msg.Channel is IPrivateChannel) { //rofl, gotta do this to prevent this message from occuring on polls int vote; if (int.TryParse(msg.Content, out vote)) { return; } await msg.Channel.SendMessageAsync(Help.DMHelpString).ConfigureAwait(false); await DMForwardCommands.HandleDMForwarding(msg, ownerChannels); } } } catch (Exception ex) { _log.Warn(ex, "Error in CommandHandler"); if (ex.InnerException != null) { _log.Warn(ex.InnerException, "Inner Exception of the error in CommandHandler"); } } }); return; }
private async void MessageReceivedHandler(SocketMessage msg) { try { var usrMsg = msg as SocketUserMessage; if (usrMsg == null) { return; } if (!usrMsg.IsAuthor()) { UserMessagesSent.AddOrUpdate(usrMsg.Author.Id, 1, (key, old) => ++ old); } if (msg.Author.IsBot || !NadekoBot.Ready) //no bots { return; } var guild = (msg.Channel as SocketTextChannel)?.Guild; if (guild != null && guild.OwnerId != msg.Author.Id) { //todo split checks into their own modules if (Permissions.FilterCommands.InviteFilteringChannels.Contains(msg.Channel.Id) || Permissions.FilterCommands.InviteFilteringServers.Contains(guild.Id)) { if (usrMsg.Content.IsDiscordInvite()) { try { await usrMsg.DeleteAsync().ConfigureAwait(false); return; } catch (HttpException ex) { _log.Warn("I do not have permission to filter invites in channel with id " + msg.Channel.Id, ex); } } } var filteredWords = Permissions.FilterCommands.FilteredWordsForChannel(msg.Channel.Id, guild.Id).Concat(Permissions.FilterCommands.FilteredWordsForServer(guild.Id)); var wordsInMessage = usrMsg.Content.ToLowerInvariant().Split(' '); if (filteredWords.Any(w => wordsInMessage.Contains(w))) { try { await usrMsg.DeleteAsync().ConfigureAwait(false); return; } catch (HttpException ex) { _log.Warn("I do not have permission to filter words in channel with id " + msg.Channel.Id, ex); } } } BlacklistItem blacklistedItem; if ((blacklistedItem = Permissions.BlacklistCommands.BlacklistedItems.FirstOrDefault(bi => (bi.Type == BlacklistItem.BlacklistType.Server && bi.ItemId == guild?.Id) || (bi.Type == BlacklistItem.BlacklistType.Channel && bi.ItemId == msg.Channel.Id) || (bi.Type == BlacklistItem.BlacklistType.User && bi.ItemId == msg.Author.Id))) != null) { return; } #if !GLOBAL_NADEKO try { var cleverbotExecuted = await Games.CleverBotCommands.TryAsk(usrMsg); if (cleverbotExecuted) { return; } } catch (Exception ex) { _log.Warn(ex, "Error in cleverbot"); } #endif try { // maybe this message is a custom reaction var crExecuted = await CustomReactions.TryExecuteCustomReaction(usrMsg).ConfigureAwait(false); //if it was, don't execute the command if (crExecuted) { return; } } catch { } string messageContent = usrMsg.Content; var sw = new Stopwatch(); sw.Start(); var exec = await ExecuteCommand(new CommandContext(_client.MainClient, usrMsg), messageContent, DependencyMap.Empty, MultiMatchHandling.Best); var command = exec.CommandInfo; var permCache = exec.PermissionCache; var result = exec.Result; sw.Stop(); var channel = (msg.Channel as ITextChannel); if (result.IsSuccess) { await CommandExecuted(usrMsg, command); _log.Info("Command Executed after {4}s\n\t" + "User: {0}\n\t" + "Server: {1}\n\t" + "Channel: {2}\n\t" + "Message: {3}", msg.Author + " [" + msg.Author.Id + "]", // {0} (channel == null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1} (channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2} usrMsg.Content, // {3} sw.Elapsed.TotalSeconds // {4} ); } else if (!result.IsSuccess && result.Error != CommandError.UnknownCommand) { _log.Warn("Command Errored after {5}s\n\t" + "User: {0}\n\t" + "Server: {1}\n\t" + "Channel: {2}\n\t" + "Message: {3}\n\t" + "Error: {4}", msg.Author + " [" + msg.Author.Id + "]", // {0} (channel == null ? "PRIVATE" : channel.Guild.Name + " [" + channel.Guild.Id + "]"), // {1} (channel == null ? "PRIVATE" : channel.Name + " [" + channel.Id + "]"), // {2} usrMsg.Content, // {3} result.ErrorReason, // {4} sw.Elapsed.TotalSeconds // {5} ); if (guild != null && command != null && result.Error == CommandError.Exception) { if (permCache != null && permCache.Verbose) { try { await msg.Channel.SendMessageAsync("⚠️ " + result.ErrorReason).ConfigureAwait(false); } catch { } } } } else { if (msg.Channel is IPrivateChannel) { //rofl, gotta do this to prevent this message from occuring on polls int vote; if (int.TryParse(msg.Content, out vote)) { return; } await msg.Channel.SendMessageAsync(Help.DMHelpString).ConfigureAwait(false); await DMForwardCommands.HandleDMForwarding(msg, ownerChannels); } } } catch (Exception ex) { _log.Warn(ex, "Error in CommandHandler"); if (ex.InnerException != null) { _log.Warn(ex.InnerException, "Inner Exception of the error in CommandHandler"); } } return; }