Skip to content

Commit a3b10d9

Browse files
committed
refactor help-thread suggestions
* remove suggestion on thread creation * improve message on thread inactivity
1 parent b2863f7 commit a3b10d9

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

application/src/main/java/org/togetherjava/tjbot/features/help/HelpSystemHelper.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package org.togetherjava.tjbot.features.help;
22

3-
import net.dv8tion.jda.api.EmbedBuilder;
43
import net.dv8tion.jda.api.entities.*;
54
import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer;
65
import net.dv8tion.jda.api.entities.channel.concrete.ForumChannel;
76
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
87
import net.dv8tion.jda.api.entities.channel.forums.ForumTag;
98
import net.dv8tion.jda.api.entities.channel.forums.ForumTagSnowflake;
109
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
11-
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
1210
import net.dv8tion.jda.api.interactions.components.buttons.Button;
1311
import net.dv8tion.jda.api.requests.RestAction;
1412
import net.dv8tion.jda.api.requests.restaction.MessageCreateAction;
@@ -104,19 +102,6 @@ public HelpSystemHelper(Config config, Database database, ChatGptService chatGpt
104102
.collect(Collectors.toSet());
105103
}
106104

107-
RestAction<Message> sendExplanationMessage(GuildMessageChannel threadChannel) {
108-
MessageEmbed helpEmbed = new EmbedBuilder()
109-
.setDescription(
110-
"""
111-
If nobody is calling back, that usually means that your question was **not well asked** and \
112-
hence nobody feels confident enough answering. Try to use your time to elaborate, \
113-
**provide details**, context, more code, examples and maybe some screenshots. \
114-
With enough info, someone knows the answer for sure.""")
115-
.build();
116-
117-
return threadChannel.sendMessageEmbeds(helpEmbed);
118-
}
119-
120105
/**
121106
* Determine between the title of the thread and the first message which to send to the AI. It
122107
* uses a simple heuristic of length to determine if enough context exists in a question. If the

application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,34 @@ private void autoArchiveForThread(ThreadChannel threadChannel, Instant archiveAf
7777
if (shouldBeArchived(threadChannel, archiveAfterMoment)) {
7878
logger.debug("Auto archiving help thread {}", threadChannel.getId());
7979

80-
MessageEmbed embed = new EmbedBuilder().setDescription(
81-
"""
82-
Closed the thread due to inactivity.
83-
84-
If your question was not resolved yet, feel free to just post a message \
85-
to reopen it, or create a new thread. But try to **improve the quality** of \
86-
your question by adding more information such as relevant **code snippets**, **errors**, \
87-
expected **results**, if required steps to reproduce the error for more precise help 👍""")
80+
String linkHowToAsk = "https://stackoverflow.com/help/how-to-ask";
81+
82+
MessageEmbed embed = new EmbedBuilder()
83+
.setDescription(
84+
"""
85+
Your question has been closed due to inactivity.
86+
87+
If it was not resolved yet, feel free to just post a message below
88+
to reopen it, or create a new thread.
89+
90+
Note that usually the reason for nobody calling back is that your
91+
question may have been not well asked and hence no one felt confident
92+
enough answering.
93+
94+
When you reopen the thread, try to use your time to **improve the quality**
95+
of the question by elaborating, providing **details**, context, all relevant code
96+
snippets, any **errors** you are getting, concrete **examples** and perhaps also some
97+
screenshots. Share your **attempt**, explain the **expected results** and compare
98+
them to the current results.
99+
100+
Also try to make the information **easily accessible** by sharing code
101+
or assignment descriptions directly on Discord, not behind a link or
102+
pdf file; provide some guidance for long code snippets and ensure
103+
the **code is well formatted** and has syntax highlighting. Kindly read through
104+
%s for more.
105+
106+
With enough info, someone knows the answer for sure 👍"""
107+
.formatted(linkHowToAsk))
88108
.setColor(HelpSystemHelper.AMBIENT_COLOR)
89109
.build();
90110

application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadCreatedListener.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ private RestAction<Void> pinOriginalQuestion(ThreadChannel threadChannel) {
102102
}
103103

104104
private RestAction<Message> createMessages(ThreadChannel threadChannel) {
105-
return sendHelperHeadsUp(threadChannel)
106-
.flatMap(any -> helper.sendExplanationMessage(threadChannel))
107-
.flatMap(any -> createAIResponse(threadChannel));
105+
return sendHelperHeadsUp(threadChannel).flatMap(any -> createAIResponse(threadChannel));
108106
}
109107

110108
private RestAction<Message> sendHelperHeadsUp(ThreadChannel threadChannel) {

0 commit comments

Comments
 (0)