|
| 1 | +[//]: # (This file is not a README, it is for GitHub Copilot not for contributors.) |
| 2 | + |
| 3 | +# Copilot Instructions |
| 4 | + |
| 5 | +## Overview |
| 6 | +This project is a [Discord](https://discord.com/) Bot developed in Java, utilizing [JDA (Java Discord API)](https://jda.wiki/introduction/jda/) library for diverse interactions on Together Java server. The project is built with Gradle. |
| 7 | + |
| 8 | +## Project Structure |
| 9 | + |
| 10 | +## Complex Aspects |
| 11 | + |
| 12 | +## Security |
| 13 | + |
| 14 | +## Coding Style |
| 15 | +- Use meaningful variable and method names. |
| 16 | +- Use `@Override` annotation for overridden methods. |
| 17 | +- Use `final` for constants and method parameters that should not be modified. |
| 18 | +- Use `this` keyword to refer to the current instance of a class. |
| 19 | +- No magic numbers or strings; use constants instead. |
| 20 | +- No unnecessary comments; code should be self-explanatory. |
| 21 | +- Use Javadoc for public classes and methods. |
| 22 | +- No wildcard imports; import only the necessary classes. |
| 23 | +- Adhere to the [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html). |
| 24 | +- Use Spotless for code formatting. Run `gradlew spotlessApply` to format code. |
| 25 | + |
| 26 | +## Commands |
| 27 | +1. Create a new class extending `SlashCommandAdapter`. |
| 28 | +2. If the command requires dependencies (e.g., `Database`), accept them in the constructor. |
| 29 | +3. Override methods such as `onSlashCommand`, `onButtonClick`, etc., as needed. |
| 30 | +4. Add the command to the list in `Features.createFeatures`, passing any required dependencies. |
| 31 | + |
| 32 | +Example: |
| 33 | +```java |
| 34 | +public class FooCommand extends SlashCommandAdapter { |
| 35 | + |
| 36 | + private static final String COMMAND_NAME = "foo"; |
| 37 | + |
| 38 | + private final Database database; |
| 39 | + private final Config config; |
| 40 | + |
| 41 | + public FooCommand(Database database, Config config) { |
| 42 | + super(COMMAND_NAME, "Foo command using database and config", CommandVisibility.GUILD); |
| 43 | + this.database = database; |
| 44 | + this.config = config; |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + public void onSlashCommand(SlashCommandInteractionEvent event) { |
| 49 | + event.reply("Foo !").queue(); |
| 50 | + } |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +Commands are registered as features in `org.togetherjava.tjbot.features.Features.createFeatures.java`: |
| 55 | +```java |
| 56 | +public static Collection<Feature> createFeatures(JDA jda, Database database, Config config) { |
| 57 | + // ... some features |
| 58 | + |
| 59 | + features.add(new FooCommand(database, config)); |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +## Database |
| 64 | + |
| 65 | +## Error Handling |
| 66 | + |
| 67 | +## Logging |
| 68 | + |
| 69 | +## Testing |
| 70 | + |
| 71 | +## Documentation |
0 commit comments