package cc.fascinated.bat.common; import cc.fascinated.bat.config.Config; import lombok.experimental.UtilityClass; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import java.time.LocalDateTime; /** * @author Fascinated (fascinated7) */ @UtilityClass public class EmbedUtils { /** * Builds a generic embed * * @return the embed builder */ public static EmbedBuilder genericEmbed() { return new EmbedBuilder() .setTimestamp(LocalDateTime.now()) .setColor(Colors.DEFAULT); } /** * Builds an error embed * * @return the embed builder */ public static EmbedBuilder errorEmbed() { return new EmbedBuilder() .setTimestamp(LocalDateTime.now()) .setColor(Colors.ERROR); } /** * Builds a success embed * * @return the embed builder */ public static EmbedBuilder successEmbed() { return new EmbedBuilder() .setTimestamp(LocalDateTime.now()) .setColor(Colors.SUCCESS); } /** * Builds a generic interaction error embed * * @param ex the exception * @return the embed builder */ public static EmbedBuilder genericInteractionError(Exception ex) { TextChannel channel = ChannelUtils.getTextChannel(Config.INSTANCE.getLogsChannel()); if (channel != null) { channel.sendMessageEmbeds(EmbedUtils.errorEmbed() .setDescription(""" An error has occurred while processing an interaction. Please check the logs for more information. ```java %s ```""".formatted(ex.getLocalizedMessage())) .build()).queue(); } return EmbedUtils.errorEmbed() .setDescription(""" An error has occurred while processing your interaction. Please check the logs for more information. ```java %s ```""".formatted(ex.getLocalizedMessage())); } }