private async Task MessageReceivedAsync(SocketMessage message) { if (message.Author.Id == discordSocket.CurrentUser.Id) { return; } await messageHistory.Init(); await messageHistory.AddDatum(new History() { Message = message.Content, MsgID = message.Id, UsrID = message.Author.Id, UsrName = message.Author.Username, ChannelID = message.Channel.Id, Time = DateTimeOffset.Now, Channel_name = message.Channel.Name }); var context = new SocketCommandContext(discordSocket, message as SocketUserMessage); try { var result = await commands.ExecuteAsync( context : context, argPos : 0, services : null ); if (!result.IsSuccess) { switch (result.Error) { case CommandError.Exception: if (result is ExecuteResult execResult) { Exception ex = execResult.Exception; Console.Error.WriteLine(ex.Message + "\n" + ex.StackTrace); } break; } } } catch { } }