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

✨Native option autocomplete support #95

Merged

Conversation

Alejandro-AP00
Copy link
Contributor

This PR adds a better syntax and the possibility to handle autocomplete within Slash Commands
It provides 3 ways of syntax

Using a choice class

public function autocomplete(): array
    {
        return [
            'attribute' => fn ($interaction, $value) => [
                Choice::new($this->discord(), 'attribute', 'attribute'),
            ],
        ];
    }

Using key value pairs

public function autocomplete(): array
    {
        return [
            'attribute' => fn ($interaction, $value) => [
                'attribute' => 'attribute',
            ],
        ];
    }

Using just an array of strings, with this option the autocomplete handler takes the liberty of using the string to create a name for the choice slugified, this last option might be too opinionated but let me know your thoughts.

public function autocomplete(): array
    {
        return [
            'attribute' => fn ($interaction, $value) => [
                'attribute',
            ],
        ];
    }

@Alejandro-AP00 Alejandro-AP00 marked this pull request as ready for review June 15, 2024 21:18
@Log1x Log1x self-assigned this Jun 15, 2024
@Log1x Log1x added the enhancement New feature or request label Jun 15, 2024
@Alejandro-AP00 Alejandro-AP00 changed the title ✨Handle autocomplete of simple options ✨Native option autocomplete support Jun 16, 2024
@Log1x
Copy link
Member

Log1x commented Jun 16, 2024

Great work! Let me know when you're ready for me to merge.

@Alejandro-AP00
Copy link
Contributor Author

Thanks, Ready when you are!
Thanks for the support as well!

@Log1x Log1x merged commit f523836 into laracord:main Jun 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants