Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 @@ -25,8 +25,8 @@
import org.togetherjava.tjbot.features.CommandVisibility;
import org.togetherjava.tjbot.features.SlashCommandAdapter;
import org.togetherjava.tjbot.features.componentids.Lifespan;
import org.togetherjava.tjbot.features.utils.AmbientColors;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -62,8 +62,6 @@ public final class RoleSelectCommand extends SlashCommandAdapter {
private static final String DESCRIPTION_OPTION = "description";
private static final String ROLE_OPTION = "selectable-role";

private static final Color AMBIENT_COLOR = new Color(24, 221, 136, 255);

private static final int OPTIONAL_ROLES_AMOUNT = 22;

/**
Expand Down Expand Up @@ -275,7 +273,7 @@ private static void modifyRoles(IReplyCallback event, Member target, Guild guild
private static MessageEmbed createEmbed(String title, CharSequence description) {
return new EmbedBuilder().setTitle(title)
.setDescription(description)
.setColor(AMBIENT_COLOR)
.setColor(AmbientColors.ROLE_MANAGEMENT)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu;

import org.togetherjava.tjbot.db.generated.tables.records.BookmarksRecord;
import org.togetherjava.tjbot.features.utils.AmbientColors;
import org.togetherjava.tjbot.features.utils.MessageUtils;

import java.awt.Color;
Expand Down Expand Up @@ -95,11 +96,11 @@ private static MessageEmbed generatePageEmbed(List<BookmarksRecord> bookmarks,
switch (requestType) {
case LIST -> {
title = "Bookmarks List";
color = BookmarksSystem.COLOR_SUCCESS;
color = AmbientColors.BOOKMARK_SUCCESS;
}
case REMOVE -> {
title = "Remove Bookmarks";
color = BookmarksSystem.COLOR_WARNING;
color = AmbientColors.BOOKMARK_WARNING;
}
default -> throw new IllegalArgumentException("Unknown request type: " + requestType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.db.Database;
import org.togetherjava.tjbot.db.generated.tables.records.BookmarksRecord;
import org.togetherjava.tjbot.features.utils.AmbientColors;

import javax.annotation.Nullable;

Expand All @@ -34,10 +35,6 @@ public final class BookmarksSystem {
static final int MAX_NOTE_LENGTH = 150;
private static final Duration REMOVE_BOOKMARKS_AFTER_LEAVE_DELAY = Duration.ofDays(7);

static final Color COLOR_SUCCESS = new Color(166, 218, 149);
static final Color COLOR_WARNING = new Color(245, 169, 127);
static final Color COLOR_FAILURE = new Color(238, 153, 160);

private final Database database;
private final Predicate<String> isHelpForumName;

Expand Down Expand Up @@ -131,15 +128,15 @@ private static MessageEmbed createColoredEmbed(String content, Color color) {
}

static MessageEmbed createSuccessEmbed(String content) {
return createColoredEmbed(content, COLOR_SUCCESS);
return createColoredEmbed(content, AmbientColors.BOOKMARK_SUCCESS);
}

static MessageEmbed createWarningEmbed(String content) {
return createColoredEmbed(content, COLOR_WARNING);
return createColoredEmbed(content, AmbientColors.BOOKMARK_WARNING);
}

static MessageEmbed createFailureEmbed(String content) {
return createColoredEmbed(content, COLOR_FAILURE);
return createColoredEmbed(content, AmbientColors.BOOKMARK_FAILURE);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import net.dv8tion.jda.api.entities.SelfUser;
import net.dv8tion.jda.api.interactions.InteractionHook;

import java.awt.Color;
import org.togetherjava.tjbot.features.utils.AmbientColors;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -104,7 +105,7 @@ private MessageEmbed buildEmbed(List<String> currentLines) {
.setAuthor(selfUser.getName(), null, selfUser.getEffectiveAvatarUrl())
.setTitle(title)
.setDescription(String.join("\n", currentLines))
.setColor(Color.gray)
.setColor(AmbientColors.CHAT_GPT_PROGRESS)
.setFooter("One moment, putting an answer together for you.")
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import javax.annotation.Nullable;

import java.awt.Color;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
Expand All @@ -50,8 +49,6 @@ public final class CodeMessageHandler extends MessageReceiverAdapter implements

private static final String DELETE_CUE = "delete";

static final Color AMBIENT_COLOR = Color.decode("#FDFD96");

private final ComponentIdInteractor componentIdInteractor;
private final Metrics metrics;
private final Map<String, CodeAction> labelToCodeAction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;

import org.togetherjava.tjbot.features.utils.AmbientColors;
import org.togetherjava.tjbot.features.utils.CodeFence;
import org.togetherjava.tjbot.formatter.Formatter;

Expand All @@ -29,7 +30,7 @@ public MessageEmbed apply(CodeFence codeFence) {

return new EmbedBuilder().setTitle("Formatted code")
.setDescription(formattedCodeFence.toMarkdown())
.setColor(CodeMessageHandler.AMBIENT_COLOR)
.setColor(AmbientColors.CODE)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.features.EventReceiver;
import org.togetherjava.tjbot.features.analytics.Metrics;
import org.togetherjava.tjbot.features.utils.AmbientColors;

/**
* Remove all thread channels associated to a user when they leave the guild.
Expand All @@ -31,7 +32,7 @@ public GuildLeaveCloseThreadListener(Config config, Metrics metrics) {
public void onGuildMemberRemove(GuildMemberRemoveEvent event) {
MessageEmbed embed = new EmbedBuilder().setTitle("OP left")
.setDescription("Closing thread...")
.setColor(HelpSystemHelper.AMBIENT_COLOR)
.setColor(AmbientColors.HELP)
.build();

event.getGuild()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import org.togetherjava.tjbot.features.chatgpt.ChatGptModel;
import org.togetherjava.tjbot.features.chatgpt.ChatGptService;
import org.togetherjava.tjbot.features.componentids.ComponentIdInteractor;
import org.togetherjava.tjbot.features.utils.AmbientColors;
import org.togetherjava.tjbot.features.utils.Guilds;

import java.awt.Color;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -58,8 +58,6 @@ public final class HelpSystemHelper {
private static final Logger logger = LoggerFactory.getLogger(HelpSystemHelper.class);
private static final ChatGptModel CHAT_GPT_MODEL = ChatGptModel.FAST;

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

private final Predicate<String> isTagManageRole;
private final Predicate<String> isHelpForumName;
private final String helpForumPattern;
Expand Down Expand Up @@ -200,7 +198,7 @@ public MessageEmbed generateGptResponseEmbed(String answer, SelfUser selfUser, S
.setAuthor(selfUser.getName(), null, selfUser.getEffectiveAvatarUrl())
.setTitle(titleForEmbed)
.setDescription(answer)
.setColor(Color.pink)
.setColor(AmbientColors.HELP_CHAT_GPT_RESPONSE)
.setFooter(responseByGptFooter)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.togetherjava.tjbot.features.UserInteractor;
import org.togetherjava.tjbot.features.componentids.ComponentIdGenerator;
import org.togetherjava.tjbot.features.componentids.ComponentIdInteractor;
import org.togetherjava.tjbot.features.utils.AmbientColors;

import java.time.Duration;
import java.time.Instant;
Expand Down Expand Up @@ -154,7 +155,7 @@ private void autoArchiveForThread(ThreadChannel threadChannel) {

With enough info, someone knows the answer for sure 👍"""
.formatted(linkHowToAsk))
.setColor(HelpSystemHelper.AMBIENT_COLOR)
.setColor(AmbientColors.HELP)
.build();

handleArchiveFlow(threadChannel, embed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.togetherjava.tjbot.features.CommandVisibility;
import org.togetherjava.tjbot.features.SlashCommandAdapter;
import org.togetherjava.tjbot.features.analytics.Metrics;
import org.togetherjava.tjbot.features.utils.AmbientColors;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
Expand Down Expand Up @@ -209,7 +210,7 @@ private void closeThread(SlashCommandInteractionEvent event, ThreadChannel helpT
refreshCooldownFor(Subcommand.CLOSE, helpThread);

MessageEmbed embed = new EmbedBuilder().setDescription("Closed the thread.")
.setColor(HelpSystemHelper.AMBIENT_COLOR)
.setColor(AmbientColors.HELP)
.build();

event.replyEmbeds(embed).flatMap(_ -> helpThread.getManager().setArchived(true)).queue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
import org.slf4j.LoggerFactory;

import org.togetherjava.tjbot.features.jshell.backend.dto.JShellResult;
import org.togetherjava.tjbot.features.utils.AmbientColors;

import javax.annotation.Nullable;

import java.awt.Color;

/**
* Allows to render JShell results.
*/
Expand Down Expand Up @@ -44,7 +43,7 @@ private MessageEmbed renderFailure(JShellResult result) {
logger.error("Couldn't render JShell result {} ", result);
return new EmbedBuilder()
.setTitle("Couldn't render the result, please contact a moderator.")
.setColor(Color.RED)
.setColor(AmbientColors.JSHELL_RENDER_FAILURE)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.SubPod;
import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.Tip;
import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.Tips;
import org.togetherjava.tjbot.features.utils.AmbientColors;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.HttpURLConnection;
Expand All @@ -42,7 +42,6 @@
final class WolframAlphaHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(WolframAlphaHandler.class);
private static final XmlMapper XML = new XmlMapper();
private static final Color AMBIENT_COLOR = Color.decode("#4290F5");
private static final String SERVICE_NAME = "Wolfram|Alpha";
/**
* WolframAlpha API endpoint for regular users (web frontend).
Expand Down Expand Up @@ -210,7 +209,7 @@ private HandlerResponse handleSuccessfulResponse(QueryResult queryResult) {
private HandlerResponse responseOf(CharSequence text) {
MessageEmbed embed = new EmbedBuilder().setTitle(buildTitle(), userApiQuery)
.setDescription(text)
.setColor(AMBIENT_COLOR)
.setColor(AmbientColors.WOLFRAM_ALPHA)
.build();

return new HandlerResponse(List.of(embed), List.of());
Expand All @@ -221,7 +220,7 @@ private HandlerResponse responseOf(CharSequence text,
List<MessageEmbed> embeds = new ArrayList<>();
embeds.add(new EmbedBuilder().setTitle(buildTitle(), userApiQuery)
.setDescription(text)
.setColor(AMBIENT_COLOR)
.setColor(AmbientColors.WOLFRAM_ALPHA)
.build());

List<Attachment> attachments = new ArrayList<>(tiles.size());
Expand All @@ -231,7 +230,7 @@ private HandlerResponse responseOf(CharSequence text,
String tileTitle = "result%d.%s".formatted(i, WolframAlphaImages.IMAGE_FORMAT);

attachments.add(new Attachment(tileTitle, WolframAlphaImages.imageToBytes(tile)));
embeds.add(new EmbedBuilder().setColor(AMBIENT_COLOR)
embeds.add(new EmbedBuilder().setColor(AmbientColors.WOLFRAM_ALPHA)
.setImage("attachment://" + tileTitle)
.build());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.features.MessageReceiverAdapter;
import org.togetherjava.tjbot.features.analytics.Metrics;
import org.togetherjava.tjbot.features.utils.AmbientColors;

import java.awt.Color;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -112,7 +112,7 @@ private MessageCreateData createNotificationMessage(Message message) {

MessageEmbed originalMessageEmbed =
new EmbedBuilder().setDescription(originalMessageContent)
.setColor(Color.ORANGE)
.setColor(AmbientColors.MEDIA_WARNING)
.build();

return new MessageCreateBuilder().setContent(message.getAuthor().getAsMention()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import org.togetherjava.tjbot.features.CommandVisibility;
import org.togetherjava.tjbot.features.SlashCommandAdapter;
import org.togetherjava.tjbot.features.utils.AmbientColors;

import java.awt.Color;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -52,8 +52,6 @@ public final class MessageCommand extends SlashCommandAdapter {
static final String EDIT_MESSAGE_ID_OPTION = "edit-message-id";
private static final String EDIT_MESSAGE_ID_DESCRIPTION = "the id of the message to edit";

private static final Color AMBIENT_COLOR = new Color(24, 109, 221, 255);

private static final String CONTENT_FILE_NAME = "content.md";

/**
Expand Down Expand Up @@ -180,7 +178,7 @@ private static void sendSuccessMessage(IDeferrableCallback event, Subcommand act
event.getHook()
.editOriginalEmbeds(new EmbedBuilder().setTitle("Success")
.setDescription("Successfully %s message.".formatted(action.getActionVerbPast()))
.setColor(MessageCommand.AMBIENT_COLOR)
.setColor(AmbientColors.MESSAGE_MANAGEMENT)
.build())
.queue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

import org.togetherjava.tjbot.config.Config;
import org.togetherjava.tjbot.features.moderation.modmail.ModMailCommand;
import org.togetherjava.tjbot.features.utils.AmbientColors;
import org.togetherjava.tjbot.features.utils.Guilds;
import org.togetherjava.tjbot.features.utils.MessageUtils;

import javax.annotation.Nullable;

import java.awt.Color;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
Expand All @@ -50,11 +50,6 @@ private ModerationUtils() {
* user as option for selection.
*/
static final String PERMANENT_DURATION = "permanent";
/**
* The ambient color used by moderation actions, often used to streamline the color theme of
* embeds.
*/
public static final Color AMBIENT_COLOR = Color.decode("#895FE8");

/**
* Checks whether the given reason is valid. If not, it will handle the situation and respond to
Expand Down Expand Up @@ -299,7 +294,7 @@ static MessageEmbed createActionResponse(User author, ModerationAction action, U
return new EmbedBuilder().setAuthor(author.getName(), null, avatarOrDefaultUrl)
.setDescription(description)
.setTimestamp(Instant.now())
.setColor(AMBIENT_COLOR)
.setColor(AmbientColors.MODERATION)
.build();
}

Expand Down Expand Up @@ -391,7 +386,7 @@ static RestAction<EmbedBuilder> getModActionEmbed(Guild guild, String actionTitl
.setTitle(actionTitle)
.setDescription(description)
.addField("Reason", reason, false)
.setColor(ModerationUtils.AMBIENT_COLOR);
.setColor(AmbientColors.MODERATION);

if (!showModmailAdvice) {
return new CompletedRestAction<>(guild.getJDA(), modActionEmbed);
Expand Down
Loading