diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java index b821246c8d..aa64f10dcc 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java @@ -1,6 +1,5 @@ package org.togetherjava.tjbot.features.help; -import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer; import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel; @@ -8,7 +7,6 @@ import net.dv8tion.jda.api.entities.channel.forums.ForumTag; import net.dv8tion.jda.api.entities.channel.forums.ForumTagSnowflake; import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; -import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel; import net.dv8tion.jda.api.interactions.components.buttons.Button; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.MessageCreateAction; @@ -104,19 +102,6 @@ public HelpSystemHelper(Config config, Database database, ChatGptService chatGpt .collect(Collectors.toSet()); } - RestAction sendExplanationMessage(GuildMessageChannel threadChannel) { - MessageEmbed helpEmbed = new EmbedBuilder() - .setDescription( - """ - If nobody is calling back, that usually means that your question was **not well asked** and \ - hence nobody feels confident enough answering. Try to use your time to elaborate, \ - **provide details**, context, more code, examples and maybe some screenshots. \ - With enough info, someone knows the answer for sure.""") - .build(); - - return threadChannel.sendMessageEmbeds(helpEmbed); - } - /** * Determine between the title of the thread and the first message which to send to the AI. It * uses a simple heuristic of length to determine if enough context exists in a question. If the diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java index a0f5121495..658bd6da3f 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java @@ -3,6 +3,7 @@ import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.MessageEmbed; import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel; import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel; @@ -65,28 +66,52 @@ private void autoArchiveForGuild(Guild guild) { logger.debug("Found {} active questions", activeThreads.size()); Instant archiveAfterMoment = computeArchiveAfterMoment(); - activeThreads - .forEach(activeThread -> autoArchiveForThread(activeThread, archiveAfterMoment)); + activeThreads.forEach(activeThread -> autoArchiveForThread(activeThread, archiveAfterMoment, + activeThread.getOwner())); } private Instant computeArchiveAfterMoment() { return Instant.now().minus(ARCHIVE_AFTER_INACTIVITY_OF); } - private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAfterMoment) { + private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAfterMoment, + Member author) { if (shouldBeArchived(threadChannel, archiveAfterMoment)) { logger.debug("Auto archiving help thread {}", threadChannel.getId()); - MessageEmbed embed = new EmbedBuilder().setDescription(""" - Closed the thread due to inactivity. + String linkHowToAsk = "https://stackoverflow.com/help/how-to-ask"; - If your question was not resolved yet, feel free to just post a message \ - to reopen it, or create a new thread. But try to improve the quality of \ - your question to make it easier to help you 👍""") + MessageEmbed embed = new EmbedBuilder() + .setDescription( + """ + Your question has been closed due to inactivity. + + If it was not resolved yet, feel free to just post a message below + to reopen it, or create a new thread. + + Note that usually the reason for nobody calling back is that your + question may have been not well asked and hence no one felt confident + enough answering. + + When you reopen the thread, try to use your time to **improve the quality** + of the question by elaborating, providing **details**, context, all relevant code + snippets, any **errors** you are getting, concrete **examples** and perhaps also some + screenshots. Share your **attempt**, explain the **expected results** and compare + them to the current results. + + Also try to make the information **easily accessible** by sharing code + or assignment descriptions directly on Discord, not behind a link or + PDF-file; provide some guidance for long code snippets and ensure + the **code is well formatted** and has syntax highlighting. Kindly read through + %s for more. + + With enough info, someone knows the answer for sure 👍""" + .formatted(linkHowToAsk)) .setColor(HelpSystemHelper.AMBIENT_COLOR) .build(); - threadChannel.sendMessageEmbeds(embed) + threadChannel.sendMessage(author.getAsMention()) + .addEmbeds(embed) .flatMap(any -> threadChannel.getManager().setArchived(true)) .queue(); } diff --git a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java index a5127d9ac2..9b528bd860 100644 --- a/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java +++ b/application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java @@ -102,9 +102,7 @@ private RestAction pinOriginalQuestion(ThreadChannel threadChannel) { } private RestAction createMessages(ThreadChannel threadChannel) { - return sendHelperHeadsUp(threadChannel) - .flatMap(any -> helper.sendExplanationMessage(threadChannel)) - .flatMap(any -> createAIResponse(threadChannel)); + return sendHelperHeadsUp(threadChannel).flatMap(any -> createAIResponse(threadChannel)); } private RestAction sendHelperHeadsUp(ThreadChannel threadChannel) {