Skip to content

Commit

Permalink
expose getKnownCustomEmojiOrCreateCustomEmoji
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
bassner authored and felldo committed Aug 2, 2021
1 parent 69c9197 commit 96bed14
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions javacord-api/src/main/java/org/javacord/api/DiscordApi.java
Expand Up @@ -1222,6 +1222,20 @@ default Collection<KnownCustomEmoji> getCustomEmojisByNameIgnoreCase(String name
.collect(Collectors.toList()));
}

/**
* Creates or gets a custom emoji to be used in other Javacord APIs. Use this if the custom emoji you're looking
* for is hosted on a different shard, and can't be accessed through {@code getCustomEmojiById()}.
* If the custom emoji is known, the method will return the known custom emoji instead of creating a new one.
* The method will always return a non-null value, even if the emoji does not exist which will lead to a non
* functional custom emoji for further usage.
*
* @param id the ID of the custom emoji
* @param name the name of the custom emoji
* @param animated true if the emoji is animated; false otherwise
* @return the new (unknown) custom emoji instance
*/
CustomEmoji getKnownCustomEmojiOrCreateCustomEmoji(long id, String name, boolean animated);

/**
* Gets a collection with all roles the bot knows.
*
Expand Down
Expand Up @@ -1084,6 +1084,7 @@ public CustomEmoji getKnownCustomEmojiOrCreateCustomEmoji(JsonNode data) {
* @param animated Whether the emoji is animated or not.
* @return The emoji for the given json object.
*/
@Override
public CustomEmoji getKnownCustomEmojiOrCreateCustomEmoji(long id, String name, boolean animated) {
CustomEmoji emoji = customEmojis.get(id);
return emoji == null ? new CustomEmojiImpl(this, id, name, animated) : emoji;
Expand Down

0 comments on commit 96bed14

Please sign in to comment.