Skip to content

Commit a659d32

Browse files
AdityaM2205Taz03
andauthored
Removing some hints in helps-thread (#934)
Co-authored-by: Tanish <[email protected]>
1 parent 21c7f62 commit a659d32

File tree

2 files changed

+9
-53
lines changed

2 files changed

+9
-53
lines changed

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

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import net.dv8tion.jda.api.interactions.components.buttons.Button;
1313
import net.dv8tion.jda.api.requests.RestAction;
1414
import net.dv8tion.jda.api.requests.restaction.MessageCreateAction;
15-
import net.dv8tion.jda.api.utils.FileUpload;
1615
import net.dv8tion.jda.internal.requests.CompletedRestAction;
1716
import org.slf4j.Logger;
1817
import org.slf4j.LoggerFactory;
@@ -26,10 +25,7 @@
2625
import org.togetherjava.tjbot.features.chatgpt.ChatGptService;
2726
import org.togetherjava.tjbot.features.componentids.ComponentIdInteractor;
2827

29-
import javax.annotation.Nullable;
30-
3128
import java.awt.*;
32-
import java.io.InputStream;
3329
import java.util.ArrayList;
3430
import java.util.Arrays;
3531
import java.util.Collection;
@@ -57,8 +53,6 @@ public final class HelpSystemHelper {
5753

5854
static final Color AMBIENT_COLOR = new Color(255, 255, 165);
5955

60-
private static final String CODE_SYNTAX_EXAMPLE_PATH = "codeSyntaxExample.png";
61-
6256
private final Predicate<String> hasTagManageRole;
6357
private final Predicate<String> isHelpForumName;
6458
private final String helpForumPattern;
@@ -111,43 +105,16 @@ public HelpSystemHelper(Config config, Database database, ChatGptService chatGpt
111105
}
112106

113107
RestAction<Message> sendExplanationMessage(GuildMessageChannel threadChannel) {
114-
return mentionGuildSlashCommand(threadChannel.getGuild(), HelpThreadCommand.COMMAND_NAME,
115-
HelpThreadCommand.Subcommand.CLOSE.getCommandName())
116-
.flatMap(closeCommandMention -> sendExplanationMessage(threadChannel,
117-
closeCommandMention));
118-
}
119-
120-
private RestAction<Message> sendExplanationMessage(GuildMessageChannel threadChannel,
121-
String closeCommandMention) {
122-
boolean useCodeSyntaxExampleImage = true;
123-
InputStream codeSyntaxExampleData =
124-
HelpSystemHelper.class.getResourceAsStream("/" + CODE_SYNTAX_EXAMPLE_PATH);
125-
if (codeSyntaxExampleData == null) {
126-
useCodeSyntaxExampleImage = false;
127-
}
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();
128116

129-
String message =
130-
"While you are waiting for getting help, here are some tips to improve your experience:";
131-
132-
List<MessageEmbed> embeds = List.of(HelpSystemHelper.embedWith(
133-
"Code is much easier to read if posted with **syntax highlighting** and proper formatting.",
134-
useCodeSyntaxExampleImage ? "attachment://" + CODE_SYNTAX_EXAMPLE_PATH : null),
135-
HelpSystemHelper.embedWith(
136-
"""
137-
If nobody is calling back, that usually means that your question was **not well asked** and \
138-
hence nobody feels confident enough answering. Try to use your time to elaborate, \
139-
**provide details**, context, more code, examples and maybe some screenshots. \
140-
With enough info, someone knows the answer for sure."""),
141-
HelpSystemHelper.embedWith(
142-
"Don't forget to close your thread using the command %s when your question has been answered, thanks."
143-
.formatted(closeCommandMention)));
144-
145-
MessageCreateAction action = threadChannel.sendMessage(message);
146-
if (useCodeSyntaxExampleImage) {
147-
action = action
148-
.addFiles(FileUpload.fromData(codeSyntaxExampleData, CODE_SYNTAX_EXAMPLE_PATH));
149-
}
150-
return action.setEmbeds(embeds);
117+
return threadChannel.sendMessageEmbeds(helpEmbed);
151118
}
152119

153120
/**
@@ -261,17 +228,6 @@ void writeHelpThreadToDatabase(long authorId, ThreadChannel threadChannel) {
261228
});
262229
}
263230

264-
private static MessageEmbed embedWith(CharSequence message) {
265-
return embedWith(message, null);
266-
}
267-
268-
private static MessageEmbed embedWith(CharSequence message, @Nullable String imageUrl) {
269-
return new EmbedBuilder().setColor(AMBIENT_COLOR)
270-
.setDescription(message)
271-
.setImage(imageUrl)
272-
.build();
273-
}
274-
275231
Optional<Role> handleFindRoleForCategory(String category, Guild guild) {
276232
String roleName = category + categoryRoleSuffix;
277233
Optional<Role> maybeHelperRole = guild.getRolesByName(roleName, true).stream().findAny();
Binary file not shown.

0 commit comments

Comments
 (0)