Add more methods

java-rewrite
Hammy 3 years ago
parent 10f0823efc
commit 2924a41646

@ -1,7 +1,9 @@
package me.goudham.service; package me.goudham.service;
import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Member;
public interface EmbedGenerator { public interface EmbedGenerator {
EmbedBuilder getBaseEmbed(); EmbedBuilder getBaseEmbed();
EmbedBuilder getUserEmbed(Member member);
} }

@ -5,6 +5,7 @@ import java.awt.Color;
import java.time.Instant; import java.time.Instant;
import java.util.Random; import java.util.Random;
import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Member;
@Singleton @Singleton
public class EnsoEmbedGenerator implements EmbedGenerator { public class EnsoEmbedGenerator implements EmbedGenerator {
@ -12,11 +13,19 @@ public class EnsoEmbedGenerator implements EmbedGenerator {
@Override @Override
public EmbedBuilder getBaseEmbed() { public EmbedBuilder getBaseEmbed() {
Color randomColor = new Color(random.nextFloat(), random.nextFloat(), random.nextFloat());
return new EmbedBuilder() return new EmbedBuilder()
.setColor(randomColor) .setColor(getRandomColour())
.setTimestamp(Instant.now()) .setTimestamp(Instant.now())
.setFooter("\uD835\uDCE4\uD835\uDD00\uD835\uDCE4"); .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());
}
} }

Loading…
Cancel
Save