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 9d987954ac..b821246c8d 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 @@ -12,7 +12,6 @@ import net.dv8tion.jda.api.interactions.components.buttons.Button; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.MessageCreateAction; -import net.dv8tion.jda.api.utils.FileUpload; import net.dv8tion.jda.internal.requests.CompletedRestAction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,10 +25,7 @@ import org.togetherjava.tjbot.features.chatgpt.ChatGptService; import org.togetherjava.tjbot.features.componentids.ComponentIdInteractor; -import javax.annotation.Nullable; - import java.awt.*; -import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -57,8 +53,6 @@ public final class HelpSystemHelper { static final Color AMBIENT_COLOR = new Color(255, 255, 165); - private static final String CODE_SYNTAX_EXAMPLE_PATH = "codeSyntaxExample.png"; - private final Predicate hasTagManageRole; private final Predicate isHelpForumName; private final String helpForumPattern; @@ -111,43 +105,16 @@ public HelpSystemHelper(Config config, Database database, ChatGptService chatGpt } RestAction sendExplanationMessage(GuildMessageChannel threadChannel) { - return mentionGuildSlashCommand(threadChannel.getGuild(), HelpThreadCommand.COMMAND_NAME, - HelpThreadCommand.Subcommand.CLOSE.getCommandName()) - .flatMap(closeCommandMention -> sendExplanationMessage(threadChannel, - closeCommandMention)); - } - - private RestAction sendExplanationMessage(GuildMessageChannel threadChannel, - String closeCommandMention) { - boolean useCodeSyntaxExampleImage = true; - InputStream codeSyntaxExampleData = - HelpSystemHelper.class.getResourceAsStream("/" + CODE_SYNTAX_EXAMPLE_PATH); - if (codeSyntaxExampleData == null) { - useCodeSyntaxExampleImage = false; - } + 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(); - String message = - "While you are waiting for getting help, here are some tips to improve your experience:"; - - List embeds = List.of(HelpSystemHelper.embedWith( - "Code is much easier to read if posted with **syntax highlighting** and proper formatting.", - useCodeSyntaxExampleImage ? "attachment://" + CODE_SYNTAX_EXAMPLE_PATH : null), - HelpSystemHelper.embedWith( - """ - 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."""), - HelpSystemHelper.embedWith( - "Don't forget to close your thread using the command %s when your question has been answered, thanks." - .formatted(closeCommandMention))); - - MessageCreateAction action = threadChannel.sendMessage(message); - if (useCodeSyntaxExampleImage) { - action = action - .addFiles(FileUpload.fromData(codeSyntaxExampleData, CODE_SYNTAX_EXAMPLE_PATH)); - } - return action.setEmbeds(embeds); + return threadChannel.sendMessageEmbeds(helpEmbed); } /** @@ -261,17 +228,6 @@ void writeHelpThreadToDatabase(long authorId, ThreadChannel threadChannel) { }); } - private static MessageEmbed embedWith(CharSequence message) { - return embedWith(message, null); - } - - private static MessageEmbed embedWith(CharSequence message, @Nullable String imageUrl) { - return new EmbedBuilder().setColor(AMBIENT_COLOR) - .setDescription(message) - .setImage(imageUrl) - .build(); - } - Optional handleFindRoleForCategory(String category, Guild guild) { String roleName = category + categoryRoleSuffix; Optional maybeHelperRole = guild.getRolesByName(roleName, true).stream().findAny(); diff --git a/application/src/main/resources/codeSyntaxExample.png b/application/src/main/resources/codeSyntaxExample.png deleted file mode 100644 index 11eb793b1e..0000000000 Binary files a/application/src/main/resources/codeSyntaxExample.png and /dev/null differ