use of org.javacord.core.entity.emoji.CustomEmojiImpl in project Javacord by BtoBastian.
the class DiscordApiImpl method getKnownCustomEmojiOrCreateCustomEmoji.
/**
* Gets a known custom emoji or creates a new (unknown) custom emoji object.
*
* @param data The data of the emoji.
* @return The emoji for the given json object.
*/
public CustomEmoji getKnownCustomEmojiOrCreateCustomEmoji(JsonNode data) {
long id = Long.parseLong(data.get("id").asText());
CustomEmoji emoji = customEmojis.get(id);
return emoji == null ? new CustomEmojiImpl(this, data) : emoji;
}
use of org.javacord.core.entity.emoji.CustomEmojiImpl in project Javacord by BtoBastian.
the class SelectMenuOptionImpl method toJson.
/**
* Gets the select menu option as a {@link ObjectNode}. This is what is sent to Discord.
*
* @return The select menu option as a ObjectNode.
*/
public ObjectNode toJson() {
ObjectNode object = JsonNodeFactory.instance.objectNode();
if (emoji != null) {
ObjectNode emojiObj = JsonNodeFactory.instance.objectNode();
if (emoji instanceof CustomEmojiImpl) {
emojiObj.put("id", ((CustomEmojiImpl) emoji).getId());
emojiObj.put("name", ((CustomEmojiImpl) emoji).getName());
} else {
emojiObj.put("name", emoji.asUnicodeEmoji().get());
}
object.set("emoji", emojiObj);
}
object.put("label", label);
object.put("value", value);
object.put("default", isDefault);
if (description != null) {
object.put("description", description);
}
return object;
}
Aggregations