Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose method to get unknown custom emoji #830

Merged
merged 1 commit into from Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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