You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1cbb581
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+33-2Lines changed: 33 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ Commands are defined in this bot using a `.yaml` configuration file located in `
21
21
22
22
These commands are then used by `net.javadiscord.javabot.command.InteractionHandler#registerSlashCommands(Guild)` to register the defined commands as Discord slash commands which become available to users in guilds and private messages with the bot.
23
23
24
-
**Each command MUST define a `handler` property, whose name is the fully-qualified class name of a `ISlashCommand`.** When registering commands, the bot will look for such a class, and attempt to create a new instance of it using a no-args constructor. Therefore, make sure that your handler class has a no-args constructor.
24
+
**Each command MUST define a `handler` property, whose name is the fully-qualified class name of a `SlashCommand`.** When registering commands, the bot will look for such a class, and attempt to create a new instance of it using a no-args constructor. Therefore, make sure that your handler class has a no-args constructor.
25
25
26
26
### Privileges
27
27
To specify that a command should only be allowed to be executed by certain people, you can specify a list of privileges. For example:
@@ -38,7 +38,38 @@ To specify that a command should only be allowed to be executed by certain peopl
38
38
```
39
39
In this example, we define that the `jam-admin` command is first of all, *not enabled by default*, and also we say that anyone from the `jam.adminRoleId` role (as found using `Bot.config.getJam().getAdminRoleId()`). Additionally, we also say that the user whose id is `235439851263098880` is allowed to use this command. See `BotConfig#resolve(String)` for more information about how role names are resolved at runtime.
40
40
41
-
*Context-Commands work in almost the same way, follow the steps above but replace `ISlashCommand` with `IMessageContextCommand` or `IUserContextCommand`.*
41
+
*Context-Commands work in almost the same way, follow the steps above but replace `SlashCommand` with `MessageContextCommand` or `UserContextCommand`.*
42
+
43
+
### Autocomplete
44
+
To enable Autocomplete for a certain Slash Command Option, head to the command's entry in the corresponding
45
+
YAML-File and set the `autocomplete` value.
46
+
47
+
```yaml
48
+
- name: remove
49
+
description: Removes a question from the queue.
50
+
options:
51
+
- name: id
52
+
description: The id of the question to remove.
53
+
required: true
54
+
autocomplete: true
55
+
type: INTEGER
56
+
```
57
+
58
+
Now, you just need to implement `Autocompletable` in your handler class.
59
+
60
+
```java
61
+
@Override
62
+
public AutoCompleteCallbackAction handleAutocomplete(CommandAutoCompleteInteractionEvent event) {
63
+
return switch (event.getSubcommandName()) {
64
+
case "remove" -> ListQuestionsSubcommand.replyQuestions(event);
65
+
default -> event.replyChoices();
66
+
};
67
+
}
68
+
```
69
+
70
+
The `handleAutocomplete` method of your handler class now gets fired once someone is focusing any Slash Command Option that has the `autocomplete`
71
+
property set to true.
72
+
42
73
43
74
# Configuration
44
75
The bot's configuration consists of a collection of simple JSON files:
0 commit comments