Пример #1
0
        public async Task CommandResults(Task <IResult> resultTask, SocketCommandContextCustom context)
        {
            _global.TimeSpendOnLastMessage.Remove(context.User.Id, out var watch);

            var guildName = context.Guild == null ? "DM" : $"{context.Guild.Name}({context.Guild.Id})";

            if (!resultTask.Result.IsSuccess)
            {
                _log.Warning(
                    $"Command [{context.Message.Content}] by [{context.User}] [{guildName}] after {watch.Elapsed:m\\:ss\\.ffff}s.\n" +
                    $"Reason: {resultTask.Result.ErrorReason}", "CommandHandling");
                _log.Error(resultTask.Result.ErrorReason);


                if (!resultTask.Result.ErrorReason.Contains("Unknown command"))
                {
                    await SendMessAsync($"Error! {resultTask.Result.ErrorReason}", context);
                }
            }
            else
            {
                _global.TotalCommandsIssued++;

                _log.Info(
                    $"Command [{context.Message.Content}] by [{context.User}] [{guildName}] after {watch.Elapsed:m\\:ss\\.ffff}s.",
                    "CommandHandling");
            }



            await Task.CompletedTask;
        }