diff --git a/src/main/java/me/goudham/service/EmbedGenerator.java b/src/main/java/me/goudham/service/EmbedGenerator.java index 16943051..74921bb7 100644 --- a/src/main/java/me/goudham/service/EmbedGenerator.java +++ b/src/main/java/me/goudham/service/EmbedGenerator.java @@ -1,7 +1,9 @@ package me.goudham.service; import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Member; public interface EmbedGenerator { EmbedBuilder getBaseEmbed(); + EmbedBuilder getUserEmbed(Member member); } diff --git a/src/main/java/me/goudham/service/EnsoEmbedGenerator.java b/src/main/java/me/goudham/service/EnsoEmbedGenerator.java index fdfdbacf..9b6a4845 100644 --- a/src/main/java/me/goudham/service/EnsoEmbedGenerator.java +++ b/src/main/java/me/goudham/service/EnsoEmbedGenerator.java @@ -5,6 +5,7 @@ import java.awt.Color; import java.time.Instant; import java.util.Random; import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Member; @Singleton public class EnsoEmbedGenerator implements EmbedGenerator { @@ -12,11 +13,19 @@ public class EnsoEmbedGenerator implements EmbedGenerator { @Override public EmbedBuilder getBaseEmbed() { - Color randomColor = new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()); - return new EmbedBuilder() - .setColor(randomColor) + .setColor(getRandomColour()) .setTimestamp(Instant.now()) .setFooter("\uD835\uDCE4\uD835\uDD00\uD835\uDCE4"); } + + @Override + public EmbedBuilder getUserEmbed(Member member) { + Color userColour = member.getColor() == null ? getRandomColour() : member.getColor(); + return getBaseEmbed().setColor(userColour); + } + + private Color getRandomColour() { + return new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()); + } }