public async Task CreateProblemForUser(string message, ulong userId) { if (message.Length >= 1800) { return; } if (_problemBoardChannel is null) { InitializeResources(); } var account = _problemProvider.GetAccount(userId); if (performingCleanup) { await _generalChannel.SendMessageAsync("I am currently performing a cleanup. Please try submitting your problem again in about five minutes."); return; } var author = await GetTutorialUserById(userId); if (author is null) { Logger.Log($"Could not create a Problem in ProblemBoard for user with id {userId}. User not found."); return; } if (account.Problems.Count != 0) { var notice = $"{author.Mention}, {_lang.GetPooledResource("MULTIPLE_PROBLEMS_NOTICE")}"; await _generalChannel.SendMessageAsync(notice); } var msg = await _problemBoardChannel.SendMessageAsync("_A problem new is being created..._"); var problemObj = new UserProblem { CreatedAt = DateTime.Now, MessageId = msg.Id }; account.Problems.Add(problemObj); _problemProvider.SaveAccount(account); var problemId = account.Problems.Count - 1; var problemMessage = $"[Problem ID: {problemId}] [By: {author.Mention}]\n{message}"; await msg.ModifyAsync(m => m.Content = problemMessage); await _generalChannel.SendMessageAsync($":shield: {author.Mention}, your problem with ID ({problemId}) has been created."); }
public async Task AdminSolveProblem(IGuildUser user, int problemId) { try { await _pbService.SolveProblemForUser(problemId, user.Id); await ReplyAsync("Done"); } catch (Exception) { var acc = _problemProvider.GetAccount(user.Id); await ReplyAsync($"The Problem ID is most likely invalid. This might help you with debugging:\n\n```\nAccount has {acc.Problems.Count} active problems.\n```"); } }