From 2924a41646365e6e9afa3e0bc707c53f17f443d4 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sun, 19 Sep 2021 04:14:19 +0100 Subject: [PATCH] Add more methods --- .../java/me/goudham/service/EmbedGenerator.java | 2 ++ .../me/goudham/service/EnsoEmbedGenerator.java | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) 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()); + } }