use of net.dv8tion.jda.api.entities.Emoji in project dDiscordBot by DenizenScript.
the class DiscordSelectionTag method build.
public SelectMenu.Builder build(TagContext context) {
ObjectTag id = menuData.getObject("id");
ObjectTag placeholder = menuData.getObject("placeholder");
if (id == null) {
return null;
}
SelectMenu.Builder menu = SelectMenu.create(id.toString());
if (placeholder != null) {
menu.setPlaceholder(placeholder.toString());
}
MapTag options = (MapTag) menuData.getObject("options");
if (options != null) {
for (ObjectTag optionObj : options.map.values()) {
MapTag option = optionObj.asType(MapTag.class, context);
ElementTag label = (ElementTag) option.getObject("label");
ElementTag value = (ElementTag) option.getObject("value");
ElementTag description = (ElementTag) option.getObject("description");
ElementTag emoji = (ElementTag) option.getObject("emoji");
Emoji emojiData = null;
if (emoji != null) {
emojiData = Emoji.fromMarkdown(emoji.toString());
}
if (label == null || value == null) {
return null;
}
if (description == null && emoji == null) {
menu.addOption(label.toString(), value.toString());
} else if (emoji == null) {
menu.addOption(label.toString(), value.toString(), description.toString());
} else if (description == null) {
menu.addOption(label.toString(), value.toString(), emojiData);
} else {
menu.addOption(label.toString(), value.toString(), description.toString(), emojiData);
}
}
}
return menu;
}
Aggregations