Skip to content
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,7 +28,6 @@
import javax.annotation.Nullable;

import java.awt.*;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -57,8 +55,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<String> hasTagManageRole;
private final Predicate<String> isHelpForumName;
private final String helpForumPattern;
Expand Down Expand Up @@ -111,42 +107,17 @@ public HelpSystemHelper(Config config, Database database, ChatGptService chatGpt
}

RestAction<Message> sendExplanationMessage(GuildMessageChannel threadChannel) {
return mentionGuildSlashCommand(threadChannel.getGuild(), HelpThreadCommand.COMMAND_NAME,
HelpThreadCommand.Subcommand.CLOSE.getCommandName())
.flatMap(closeCommandMention -> sendExplanationMessage(threadChannel,
closeCommandMention));
}

private RestAction<Message> sendExplanationMessage(GuildMessageChannel threadChannel,
String closeCommandMention) {
boolean useCodeSyntaxExampleImage = true;
InputStream codeSyntaxExampleData =
HelpSystemHelper.class.getResourceAsStream("/" + CODE_SYNTAX_EXAMPLE_PATH);
if (codeSyntaxExampleData == null) {
useCodeSyntaxExampleImage = false;
}

String message =
"While you are waiting for getting help, here are some tips to improve your experience:";

List<MessageEmbed> 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)));
"""
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."""));

MessageCreateAction action = threadChannel.sendMessage(message);
if (useCodeSyntaxExampleImage) {
action = action
.addFiles(FileUpload.fromData(codeSyntaxExampleData, CODE_SYNTAX_EXAMPLE_PATH));
}
return action.setEmbeds(embeds);
}

Expand Down