Comments (15)
is there a way to make a commandautocompleteevent work properly?
Currently no, but there will be a way in the future. Choices have already been implemented because they are part of the command definition, but autocomplete events are a separate element.
Currently I don't have any time to code, but autocomplete will be added within the next release(s).
Closing this issue since this feature is already part of my internal roadmap
from jda-commands.
implemented with 4.0.0-alpha.4
from jda-commands.
am i doin somethin wrong?
from jda-commands.
you need to specify the command name and not the parameter name. for you exmaple this would be package list search
from jda-commands.
so would i need to do separate things for each of the commands that all have a community
param?;
from jda-commands.
You can specify multiple commands per AutoComplete, but yes
from jda-commands.
could you give an example?
from jda-commands.
@Interaction
public class AutoCompleteTest {
private final String[] words = new String[]{"apple", "apricot", "banana", "cherry", "coconut", "cranberry"};
@SlashCommand("fruit")
public void onFruitCommand(CommandEvent event, @Param("fruit to find") String name) {
event.reply("You selected %s", name);
}
@SlashCommand("food")
public void onFoodCommand(CommandEvent event, @Param("fruit to find") String name) {
event.reply("You selected %s", name);
}
@AutoComplete({"fruit", "food"})
public void onAutoComplete(AutoCompleteEvent event) {
event.replyChoices(Stream.of(words)
.filter(word -> word.startsWith(event.getValue()))
.map(word -> new Command.Choice(word, word))
.collect(Collectors.toList())
);
}
}
Also be aware of the AutoCompleteEvent#getName()
method to retrieve the name of the parameter, in case you have more than one parameter per command.
from jda-commands.
this following code doesnt seem to be workin?
@AutoComplete(value = {"package search", "package author", "package info"})
public void onAutocompleteCommunity(AutoCompleteEvent event) {
if (event.getName().equals("community"))
event.replyChoices(Stream.of(Bot.bot.tsja.getCommunities())
.filter(community -> community.getIdentifier().startsWith(event.getValue()))
.map(community -> new Command.Choice(community.getIdentifier(), community.getIdentifier()))
.collect(Collectors.toList())
);
}
any clue?
from jda-commands.
I've used the following code to test your use case on my machine and it worked fine:
@Interaction
public class AutoCompleteTest {
private final String[] words = new String[]{"apple", "apricot", "banana", "cherry", "coconut", "cranberry"};
@SlashCommand(value = "package search")
public void onCommand1(CommandEvent event, String community) {
event.reply("You selected %s", community);
}
@SlashCommand(value = "package author")
public void onCommand2(CommandEvent event, String community) {
event.reply("You selected %s", community);
}
@SlashCommand(value = "package info")
public void onCommand3(CommandEvent event, String community) {
event.reply("You selected %s", community);
}
@AutoComplete(value = {"package search", "package author", "package info"})
public void onAutoComplete(AutoCompleteEvent event) {
if (event.getName().equals("community")) {
event.replyChoiceStrings(Stream.of(words)
.filter(word -> word.startsWith(event.getValue()))
.collect(Collectors.toList())
);
}
}
}
Please provide your debug log file and also double check that the error is not caused by your getCommunities
method, because i have no influence on your bot code
from jda-commands.
While working on a feature that allows to only use the top level name, in this case "package" to register all sub commands I've encountered a bug, which sometimes leads to autocomplete not being registered correctly. This got fixed with commit adbdc41 and will be shipped with the next release.
Here is the maven snippet to use this commit as long as the release isn't ready:
<dependency>
<groupId>com.github.Kaktushose</groupId>
<artifactId>jda-commands</artifactId>
<version>adbdc4190e</version>
</dependency>
please let me know if this fixes your issue
from jda-commands.
using that version seems to disable the commands?
but also not?
(its not the apple profile picture, and its in the server)
but then,
with this at the end of my start
Bot.bot.jda.retrieveCommands().queue(commands -> {
commands.forEach(command -> {
System.out.println(command.getName());
});
});
from jda-commands.
will be fixed with the next commit
from jda-commands.
0199890 should fix this
from jda-commands.
Confirmed to be working, thank you!
from jda-commands.
Related Issues (20)
- [FEATURE] ReplyContext queue / reply consumer
- [BUG] Reply message always ephemeral HOT 1
- [FEATURE] make Dependency Injector an interface
- [FEATURE] add setErrorConsumer
- [BUG] reimplement CooldownFilter
- [QUESTION] How to handle expired buttons? HOT 10
- [FEATURE] Handle unknown interactions HOT 2
- Add support for command groups & Modals HOT 4
- No function to send modals HOT 1
- [BUG] Some commands are not registering HOT 13
- [BUG] Command execution fails with IndexOutOfBoundsException HOT 3
- [BUG] DefaultValues have no effect on SelectMenus
- Would be nice to have more documentation on buttons and modals
- Error in discord, but not in console. HOT 12
- [FEATURE] Ignore non-jda-commands interactions
- [FEATURE] Add components API for usage outside of commands
- [FEATURE] Implement static interactions
- [FEATURE] Add i18n for EmbedCache
- [BUG] Member parser does not work in other channels then default text HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jda-commands.