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 e96fd06
Browse filesBrowse the repository at this point in the historyBrowse files
General utility bot for the [JavaDiscord Community](https://join.javadiscord.net/)
3
+
General utility bot for the [Java Community on Discord.](https://join.javadiscord.net/)
4
4
5
5
# Usage
6
6
7
7
To start up, run the bot once, and it will generate a `config` directory. Stop the bot, and set the up **all of the following values**:
8
8
- in `systems.json`
9
9
-`jdaBotToken` to your bot's token
10
+
- (some `adminUsers` which, e.g., can manipulate the database)
10
11
- in `{guildId}.json`
11
12
-`moderation.logChannelId` to a channelId
12
13
-`moderation.staffRoleId` to a roleId
@@ -15,65 +16,12 @@ To start up, run the bot once, and it will generate a `config` directory. Stop t
15
16
16
17
Note that this is just what is required for the bot to start. Certain features may require other values to be set.
17
18
18
-
19
-
# Commands
20
-
Commands are defined in this bot using a `.yaml` configuration file located in `src/main/resources/commands`. The data in this file is transformed at startup time into an array of `net.javadiscord.javabot.command.data.slash_commands.SlashCommandConfig` objects using JSON deserialization.
21
-
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
-
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
-
26
-
### Privileges
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:
28
-
```yaml
29
-
- name: jam-admin
30
-
description: Administrator actions for configuring the Java Jam.
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
-
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
-
73
-
74
19
# Configuration
75
20
The bot's configuration consists of a collection of simple JSON files:
76
21
-`systems.json` contains global settings for the bot's core systems.
77
22
- For every guild, a `{guildId}.json` file exists, which contains any guild-specific configuration settings.
78
23
79
24
At startup, the bot will initially start by loading just the global settings, and then when the Discord ready event is received, the bot will add configuration for each guild it's in, loading it from the matching JSON file, or creating a new file if needed.
0 commit comments