Skip to content

Commit 7123f8a

Browse files
committed
Store emojis directly as CustomEmoji
1 parent dbed2c1 commit 7123f8a

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

build.gradle.kts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ setupPublishing(
3333

3434
// Fix some tasks
3535
tasks {
36-
startScripts {
37-
dependsOn("shadowJar")
38-
}
39-
startShadowScripts {
40-
dependsOn("jar")
41-
}
36+
startScripts { dependsOn("shadowJar") }
37+
startShadowScripts { dependsOn("jar") }
4238
}

src/main/java/xyz/srnyx/lazylibrary/LazyEmoji.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.freya02.botcommands.api.utils.ButtonContent;
44

5+
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
56
import net.dv8tion.jda.api.entities.emoji.Emoji;
67

78
import org.jetbrains.annotations.NotNull;
@@ -285,30 +286,16 @@ public enum LazyEmoji {
285286
*/
286287
QUESTION_CLEAR_DARK(1298411642358337578L);
287288

288-
@NotNull private final String name;
289-
private final long id;
290-
private final boolean animated;
289+
@NotNull public final CustomEmoji emoji;
291290

292291
LazyEmoji(long id, boolean animated) {
293-
this.name = "vn" + name().toLowerCase().replace("_", "");
294-
this.id = id;
295-
this.animated = animated;
292+
this.emoji = Emoji.fromCustom("vn" + name().toLowerCase().replace("_", ""), id, animated);
296293
}
297294

298295
LazyEmoji(long id) {
299296
this(id, false);
300297
}
301298

302-
/**
303-
* Forms a {@link Emoji} from this {@link LazyEmoji}
304-
*
305-
* @return the {@link Emoji} formed
306-
*/
307-
@NotNull
308-
public Emoji getEmoji() {
309-
return Emoji.fromCustom(name, id, animated);
310-
}
311-
312299
/**
313300
* Construct a {@link ButtonContent} from this {@link LazyEmoji}
314301
*
@@ -318,7 +305,7 @@ public Emoji getEmoji() {
318305
*/
319306
@NotNull
320307
public ButtonContent getButtonContent(@Nullable String text) {
321-
return new ButtonContent(text, getEmoji());
308+
return new ButtonContent(text, emoji);
322309
}
323310

324311
/**
@@ -333,6 +320,6 @@ public ButtonContent getButtonContent() {
333320

334321
@Override @NotNull
335322
public String toString() {
336-
return getEmoji().getFormatted();
323+
return emoji.getFormatted();
337324
}
338325
}

0 commit comments

Comments
 (0)