Enum List - RubbaBoy/EmojIDE GitHub Wiki

Enum lists are a very interactive piece of the IDE, though not actually part of the rendering of the IDE. They are a separate embeded message to select an enum (Or an item or any other collection) and save its ordinal in a config, while displaying the options and what are selected. A small demo of this feature is shown below.

Enum List Gif

Using It Yourself

Before I get into the technical details of this feature, here is how the actual IDE commands create these embeds, on a much more abstracted level. First, you must have an instance of a ChoosingList for each chooser. These can be created via

ChoosingList<Theme> themeChooser = ChoosingListManager#createChoosingList(emojIDE, themeManager::getActive, themeManager::setActive, Theme.class);

These parameters are the actions to do when it needs to get the active element, and when an item has been selected. Then, you can send this embed to a channel with

themeChooser.sendEmbed(member, channel, "Themes", "The following are the themes available in the IDE. Either click the " + StaticEmoji.UNSELECTED.getDisplay() + " to apply the theme, or type `!ide settheme \"name\"`");

Read the docs if you want to know more about it. If you want to manually select an element (Like with !ide settheme Default) you can do so by

themeChooser.manualChoose(channel, member, args.nextArg().getString(), "theme", themeManager::setActive, "Changed Theme", font -> "Changed active theme to " + font.getName());

How It Works

Incase you don't really give a shit about the abstracted part and just want to know how this thing works, here you go. When the embed is sent, it is of course rendered in emojis, with the leading emoji padded to the right being either the dot or the check. These are made links with the query parameters id, which is the hash code in the default implementation, ordinal, which is the ordinal of the selecte ditem, and originating, which is the message ID where this came from. The actual source of all this can be found here.

This is on the /c/apply endpoint, so the manager just listens to that, and serves out any listeners appropriately. The listeners run whatever code you put in as a Consumer to take a selected action, but also edits the originating message appropriately.

⚠️ **GitHub.com Fallback** ⚠️