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

Command Option Autocomplete Functionality #48

Merged
merged 4 commits into from Dec 26, 2022

Conversation

acikek
Copy link
Contributor

@acikek acikek commented Dec 25, 2022

Additions

  • New event: discord command autocomplete
    • Determination controls option suggestions for the Discord client
  • discordcommand command options now have an optional autocomplete key for whether they can be autocompleted

Notes

  • discord command autocomplete and discord application command events shared the majority of their context and switches. They have been abstracted into DiscordCommandInteractionScriptEvent.
    • ...with, unfortunately, some dubious abstractions due to JDA's design.
    • Instead of creating a language entry covering data from both events, they both have their own meta entries with lots of repetition. However, I believe this is preferable due to how event meta entries are formatted into sections.

@acikek acikek changed the title Option Autocomplete Functionality Command Option Autocomplete Functionality Dec 25, 2022

@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determination) {
if (!determination.canBeType(ListTag.class)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a stable check - anything can be a ListTag.
The determination should probably just be prefixed (it's intended in the future for determinations with prefixes to have native handling, so those are preferable anyway)

// <context.focused_option> returns the name of the focused option.
//
// @Determine
// ListTag to suggest values to the Discord client. Each entry can be an ElementTag which controls both the value and display of the choice or a MapTag with "name" and "value" keys to control both separately.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should document the 25 max here

List<Command.Choice> choices = new ArrayList<>();
for (ObjectTag objectTag : list.objectForms) {
Command.Choice choice;
if (MapTag.matches(objectTag.toString())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use canBeType or shouldBeType

@mcmonkey4eva mcmonkey4eva merged commit 1c3a58e into DenizenScript:master Dec 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants