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
[//]: #(This file is not a README, it is for GitHub Copilot not for contributors.)
1
+
[//]: # (This file is not a README, it is for [GitHub Copilot](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions) to help the AI tool to understand the project and provide better completions and code generations.)
2
2
3
3
# Copilot Instructions
4
4
@@ -7,15 +7,15 @@ This project is a [Discord](https://discord.com/) Bot developed in Java, utilizi
7
7
8
8
## Tech Stack
9
9
10
-
The project uses a variety of technologies and libraries to achieve its functionality. Below is a comprehensive list of the main technologies used:
10
+
The project uses a variety of technologies and libraries to achieve its functionality. Below is a comprehensive list of the main technologies used:
11
11
12
12
**Languages**
13
13
- Java: the primary language for the project.
14
14
- SQL: for database creation and management.
15
15
- Groovy: for build-tool's configurations.
16
16
17
17
**Build & Dependency Management**
18
-
- Gradle v8: the build tool used for managing dependencies and building the project.
18
+
- Gradle: Be aware of the Gradle version in use, it is written in `/gradle/wrapper/gradle-wrapper.properties`.
19
19
- Shadow plugin: for creating a fat JAR with all dependencies included.
20
20
- Jib plugin: for building Docker images directly from Gradle.
21
21
@@ -59,111 +59,33 @@ The project uses a variety of technologies and libraries to achieve its function
59
59
- Jib (for container image building)
60
60
61
61
**Version Control & CI/CD**
62
-
- Git v2
62
+
- Git
63
63
- GitHub Actions (for CI/CD, under `.github/workflows`)
64
64
- Dependabot (for dependency updates, under `.github/dependabot.yml`)
65
65
- Docker
66
66
67
67
**IDE/Editor Support**
68
-
- IntelliJ IDEA
69
-
- Eclipse
70
-
- GitHub Codespaces
68
+
69
+
The project is designed to be compatible with various IDEs.
71
70
72
71
## Repository Structure
73
72
74
-
A **multi-module** Gradle project composed of 5 modules :
75
-
```txt
76
-
TJ-Bot
77
-
├── application (Application module)
78
-
├── buildSrc (Custom Gradle plugin)
79
-
├── database
80
-
├── formatter
81
-
├── utils
82
-
```
73
+
A **multi-module** Gradle project composed of 5 modules:
74
+
75
+
1.**Application:** This is the main module. It contains the entry point, core logic, feature implementations, configuration management, and logging utilities for the bot.
76
+
2.**BuildSrc:** Doesn't contain any Java files, it contains a build process to the SQLite database using Flyway and JOOQ. It contains exactly one [Groovy](https://groovy-lang.org/) file `database-settings.gradle`, which is a custom Gradle plugin that handles the database schema generation and migration.
77
+
3.**Database:** about creating the connection to the SQLite database and providing a way to interact with it using JOOQ.
78
+
4.**Formatter:** about formatting code snippets in any text messages, using [JDA](https://github.com/discord-jda/JDA?tab=readme-ov-file#jda-java-discord-api). It's built in a way that its robust and works even for code that doesn't compile, snippets and the like
79
+
5.**Utils:** contains utility classes and methods that are used across the application. It includes exactly one class `MethodsReturnNonnullByDefault`: an annotation used in most packages as a validation mechanism to ensure that methods return non-null values by default, unless explicitly annotated otherwise.
83
80
84
-
The repository has other directories that are not modules:
81
+
The repository has other directories that are not modules:
85
82
86
-
-`.devcontainer` and `.vscode` directories are only about giving support to coding on [GitHub's Codespaces](https://github.com/features/codespaces).
87
-
The project is not intended necessarily to be run in a container or a specific IDE_.
83
+
-`.devcontainer` and `.vscode` directories are about giving support to coding on [GitHub's Codespaces](https://github.com/features/codespaces). The `.vscode` can also be used to support developers on [VS Code](https://code.visualstudio.com/) IDE. A local setup does not require running the project from a container like Docker or the use of a specific IDE.
88
84
-`.github` directory contains configuration files for GitHub Actions, Dependabot, and other GitHub features.
89
85
-`.gradle` directory contains the Gradle wrapper files, allowing the project to be built with a specific version of Gradle without requiring users to install it manually, ignore it.
90
-
-`meta` directory currently contains 3 [draw.io](https://www.drawio.com/) diagram files about the project, and a `google-style-eclipse.xml` file used in Spotless configuration.
91
-
-`scripts` directory currently contains only one file which is a git pre-commit hook that runs Spotless to format the code before committing.
92
-
93
-
### Module 1: Application
94
-
95
-
This is the main module. It contains the entry point, core logic, feature implementations, configuration management, and logging utilities for the bot.
96
-
97
-
Most packages are equipped with a `package-info.java` file, which contains a brief description and 2 annotations
98
-
-`@MethodsReturnNonnullByDefault`: defined in the `/utils` module, indicating that all methods in the package return non-null values by default.
99
-
-`@ParametersAreNonnullByDefault`: from `javax.annotation` package, indicating that all parameters in the package are non-null by default.
100
-
101
-
NOTE: _We recommend to all contributors to only focus on this module. The other ones are handling some aspects behind the scenes, and are not meant to be modified by contributors._
102
-
103
-
#### 1. `config`:
104
-
105
-
Purpose: Handles all configuration aspects of the bot, including loading, validating, and providing access to configuration values.
106
-
107
-
Contents:
108
-
- Classes for parsing and representing configuration files (e.g., `config.json.template`).
109
-
- Utilities for environment variable overrides and runtime configuration changes.
110
-
- Central access point for configuration values used throughout the application.
111
-
112
-
#### 2. `features`
113
-
114
-
Purpose: Implements the bot’s features, including commands, event listeners, and integrations.
115
-
116
-
Contents:
117
-
- Command classes extending `SlashCommandAdapter` for Discord slash commands.
118
-
- Event listeners for handling Discord events (e.g., user asked a question, question answered).
119
-
- Feature registration and lifecycle management (e.g., Features.createFeatures).
120
-
- Sub-packages for organizing features by domain (e.g., basic, chatgpt (openai), code, projects, and others).
121
-
122
-
#### 3. `logging`
123
-
124
-
Purpose: Provides logging configuration and utilities for the application.
- Integration with `SLF4J` for consistent logging across dependencies.
130
-
131
-
### Module 2: BuildSrc
132
-
133
-
This module doesn't contain any Java files, it contains a build process to the SQLite database using Flyway and JOOQ.
134
-
135
-
It contains exactly one groovy file database-settings.gradle, which is a custom Gradle plugin that handles the database schema generation and migration.
136
-
137
-
### Module 3: Database
138
-
139
-
This module is about creating the connection to the SQLite database and providing a way to interact with it using JOOQ.
140
-
141
-
### Module 4: Formatter
142
-
143
-
This module is about formatting code snippets in Discord messages, using the JDA library.
144
-
145
-
It's a sort of support for the `features.code` package in the `application` module.
146
-
147
-
> formatter... is a really complex project. it was created as its own module. probably also bc it was originally intended to be run outside the bots context - Zabuzard
148
-
149
-
### Module 5: Utils
150
-
151
-
This module contains utility classes and methods that are used across the application. It includes exactly one class `MethodsReturnNonnullByDefault` which is an annotation used in most packages in the `application` module.
152
-
153
-
## Complex Aspects
154
-
155
-
This section is about some important aspects in the `application` module. Some of these aspects are complex and may require additional attention when they get modified :
156
-
157
-
-`BotCore` a class/component defined under a subpackage `features.system`.
158
-
-`ComponentIdStore` under a subpackage `features.componentids`.
159
-
-`ComponentIdGenerator` under a subpackage `features.componentids`.
160
-
-`ComponentIdInteractor` under a subpackage `features.componentids`.
161
-
-`ComponentIdParser` under a subpackage `features.componentids`.
162
-
-`Lifespan` under a subpackage `features.componentids`.
163
-
- The corresponding database table and how it hooks into the actions, i.e. `UserInteractor#acceptComponmentIdGenerator` and the like.
164
-
- the unit testing setup around discord mocking: the `JdaTester` class and the files next to it (.e.g the `jda.payloads` package)
165
-
166
-
NOTE: _These aspects are not meant to be modified by contributors, but they are important to understand how the bot works._
86
+
-`meta` directory contains 3 [draw.io](https://www.drawio.com/) diagram files about the project, and a `google-style-eclipse.xml` file used in Spotless configuration.
87
+
-`scripts` directory contains only one file which is a git pre-commit hook that runs Spotless to format the code before committing.
88
+
-`wiki` directory contains the project's wiki pages, which are used to document the project and its features. The wiki is an important reference to understanding core logic and coding style.
167
89
168
90
## Coding Style
169
91
@@ -174,49 +96,11 @@ Know that the organization uses [Sonar](https://sonarcloud.io/project/overview?i
174
96
Try to use the [Together-Java Sonar's Quality Profile](https://sonarcloud.io/organizations/togetherjava/quality_profiles) when you write code or help with completions.
175
97
176
98
In addition, the following conventions should be followed:
177
-
- Use meaningful variable and method names.
178
-
- Use `@Override` annotation for overridden methods.
179
-
- Use `final` for fields and classes whenever is better.
99
+
- Use meaningful class, method and variable names.
100
+
- Use `final` for fields and classes as default. Only make them non-final when modification and extension becomes necessary. In which case it is important to document its interface and intended use with Javadoc.
180
101
- Enforce using `this` keyword to refer to the current instance of a class.
181
-
- No magic numbers or strings; use constants instead.
182
-
- No unnecessary comments; code should be self-explanatory.
102
+
- It's generally preferred to use well named constants over magic values.
0 commit comments