Files
Bat/src/main/java/cc/fascinated/bat/common/EmbedUtils.java

58 lines
1.5 KiB
Java
Raw Normal View History

2024-06-24 13:56:01 +01:00
package cc.fascinated.bat.common;
2024-06-25 11:14:12 +01:00
import lombok.experimental.UtilityClass;
2024-06-24 13:56:01 +01:00
import net.dv8tion.jda.api.EmbedBuilder;
import java.time.LocalDateTime;
/**
* @author Fascinated (fascinated7)
*/
2024-06-25 11:14:12 +01:00
@UtilityClass
2024-06-24 13:56:01 +01:00
public class EmbedUtils {
/**
* Builds a generic embed
*
* @return the embed builder
*/
2024-06-25 13:59:02 +01:00
public static EmbedBuilder genericEmbed() {
2024-06-24 13:56:01 +01:00
return new EmbedBuilder()
.setTimestamp(LocalDateTime.now())
.setColor(Colors.DEFAULT);
2024-06-24 13:56:01 +01:00
}
/**
* Builds an error embed
*
* @return the embed builder
*/
2024-06-25 13:59:02 +01:00
public static EmbedBuilder errorEmbed() {
2024-06-24 13:56:01 +01:00
return new EmbedBuilder()
.setTimestamp(LocalDateTime.now())
.setColor(Colors.ERROR);
2024-06-24 13:56:01 +01:00
}
/**
* Builds a success embed
*
* @return the embed builder
*/
2024-06-25 13:59:02 +01:00
public static EmbedBuilder successEmbed() {
2024-06-24 13:56:01 +01:00
return new EmbedBuilder()
.setTimestamp(LocalDateTime.now())
.setColor(Colors.SUCCESS);
2024-06-24 13:56:01 +01:00
}
/**
* Builds a generic interaction error embed
*
* @param ex the exception
* @return the embed builder
*/
public static EmbedBuilder genericInteractionError(Exception ex) {
return EmbedUtils.errorEmbed()
.setDescription("An error occurred while processing your interaction. Please try again later.\n" +
"**Error:** ```java\n%s\n```" + ex.getLocalizedMessage());
}
2024-06-24 13:56:01 +01:00
}