Sitelet https://github.com/Java-Discord/JavaBot/commit/e96fd06229d686e795cfa8a8792574ab7532b387
Skip to content

Commit e96fd06

Browse files
Updated README.md
1 parent 4b292b1 commit e96fd06

1 file changed

Lines changed: 5 additions & 57 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# JavaBot
22

3-
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/)
44

55
# Usage
66

77
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**:
88
- in `systems.json`
99
- `jdaBotToken` to your bot's token
10+
- (some `adminUsers` which, e.g., can manipulate the database)
1011
- in `{guildId}.json`
1112
- `moderation.logChannelId` to a channelId
1213
- `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
1516

1617
Note that this is just what is required for the bot to start. Certain features may require other values to be set.
1718

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.
31-
handler: net.javadiscord.javabot.systems.jam.JamAdminCommandHandler
32-
enabledByDefault: false
33-
privileges:
34-
- type: ROLE
35-
id: jam.adminRoleId
36-
- type: USER
37-
id: 235439851263098880
38-
```
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-
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-
7419
# Configuration
7520
The bot's configuration consists of a collection of simple JSON files:
7621
- `systems.json` contains global settings for the bot's core systems.
7722
- For every guild, a `{guildId}.json` file exists, which contains any guild-specific configuration settings.
7823

7924
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.
25+
26+
# Commands
27+
_Work in Progress_

0 commit comments

Comments
 (0)