-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: Improve documentation for new users #85
base: master
Are you sure you want to change the base?
Changes from all commits
6e1ad1b
29da9a6
14b2a0f
6077dd1
f32fb8b
ea336aa
28491b6
fd38396
09fc4ca
9774856
34ced5d
c4601e1
a98f838
325427c
84e5ba9
3653452
d38e2dd
bae02d5
98dcf28
4e5c806
03e5dd4
96ee37e
97337fa
5917f5e
ff6742f
770a659
4b591b3
f341bec
c5ada12
52fd67c
21e8856
9339d3e
1c7fc96
ef17bbe
26f0f06
0644538
b9854c9
9221e88
211801d
79fb2e9
9b647eb
a2eea82
58ccddd
088f6f6
7713504
6fa4019
0ba058f
f5dbfcf
2ceed7c
b1d395a
b221abb
973161b
ceb5709
17c107d
9ec51b3
cfe2416
2a57c49
f25b530
ceaea24
26c3cb3
c47faa1
8129353
90a5f5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.gitignore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# SETUP | ||
DISCORD_TOKEN= | ||
|
||
# DB | ||
REDIS_URL= | ||
|
||
# CHANNELS | ||
COOL_LINKS_CHANNEL_ID= | ||
|
||
# API | ||
PAGE_SUMMARIZER_BASE_URL= |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.gitignore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
parser: '@typescript-eslint/parser' | ||
parserOptions: | ||
sourceType: module | ||
ecmaVersion: 2022 | ||
project: ./tsconfig.json | ||
|
||
extends: | ||
- plugin:@typescript-eslint/recommended | ||
- plugin:@typescript-eslint/recommended-requiring-type-checking | ||
- plugin:sonarjs/recommended | ||
- plugin:import/typescript | ||
|
||
plugins: | ||
- simple-import-sort | ||
- import | ||
- only-error | ||
- unused-imports | ||
|
||
settings: | ||
import/resolver: | ||
|
||
rules: | ||
import/exports-last: error | ||
import/first: error | ||
import/no-duplicates: error | ||
import/order: off | ||
|
||
simple-import-sort/imports: error | ||
simple-import-sort/exports: error | ||
|
||
unused-imports/no-unused-imports: error | ||
|
||
import/no-extraneous-dependencies: | ||
- error | ||
- devDependencies: false | ||
|
||
overrides: | ||
- files: | ||
- '*.spec.ts' | ||
rules: | ||
import/no-extraneous-dependencies: | ||
- error | ||
- devDependencies: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,15 @@ concurrency: | |
jobs: | ||
deployment: | ||
runs-on: ubuntu-22.04 | ||
|
||
permissions: read-all | ||
|
||
environment: | ||
name: production | ||
url: http://discord.gg/7Guzz9e | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
|
@@ -33,7 +36,7 @@ jobs: | |
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to Heroku | ||
uses: akhileshns/[email protected].13 | ||
uses: akhileshns/[email protected].14 | ||
with: | ||
heroku_api_key: ${{secrets.HEROKU_API_KEY}} | ||
heroku_app_name: '' | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
name: Check Integration | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
|
@@ -11,25 +13,33 @@ on: | |
- '**deployment.yaml' | ||
|
||
jobs: | ||
validate-pr-title: | ||
name: Validate PR title | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: amannn/action-semantic-pull-request@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
integration: | ||
name: Continuous integration | ||
name: Continuous integration checks | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/[email protected] | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/[email protected] | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
|
@@ -39,14 +49,17 @@ jobs: | |
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Format project | ||
run: pnpm format | ||
|
||
- name: Type-check project | ||
run: pnpm typecheck | ||
|
||
- name: Lint project | ||
run: pnpm affected:lint | ||
run: pnpm lint | ||
|
||
- name: Build project | ||
run: pnpm affected:build | ||
- name: Test project | ||
run: pnpm test | ||
|
||
- name: Build Docker image for project | ||
uses: docker/build-push-action@v4 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
save-exact=true | ||
prefer-offline=true | ||
engines-strict=true | ||
strict-peer-dependencies=true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20.6.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.gitignore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<h1 align="center">Contributing to our Discord bot</h1> | ||
|
||
## Table of contents | ||
|
||
- [Table of contents](#table-of-contents) | ||
- [Installation](#installation) | ||
- [Running](#running) | ||
- [Minimal setup](#minimal-setup) | ||
- [Persistence](#persistence) | ||
- [Custom test discord server](#custom-test-discord-server) | ||
- [Tooling](#tooling) | ||
- [Making Pull Requests](#making-pull-requests) | ||
|
||
## Installation | ||
|
||
We use [pnpm](https://pnpm.io) to manage our dependencies. | ||
You can [install it](https://pnpm.io/installation) using your preferred | ||
method, but we recommend using [Corepack](https://nodejs.org/api/corepack.html#supported-package-managers) so that you keep your package manager version in sync with ours. | ||
|
||
Make sure you run **Node 20** or the dependencies' installation will fail. | ||
We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage your Node version. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
Finally, run `pnpm install`. | ||
|
||
## Running | ||
|
||
### Minimal setup | ||
|
||
Copy [`.env.example`](./.env.example) to `.env` and fill you discord token. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when i git clone, .env.example already exist. |
||
|
||
If you don't have a token, create a discord application on [their developer portal](https://discord.com/developers/applications). Make sure to get your bot token and paste it in the .env file. | ||
|
||
If you're part of Codinglab, we do have a test discord server ready for you, contact Moderators on discord to gain access. After that you shoud be ready to go, and start the bot with `pnpm dev`. | ||
|
||
### Persistence | ||
|
||
By default, the bot stores it's data in-memory. | ||
Altough this is great for fast setup and quick bootstraping of features, you most likely want to run a persistent storage on your machine. | ||
|
||
To enable persistence, set `REDIS_URL` env var to `"redis://localhost:6379"` and start the local redis server with `docker-compose up`. (see [Tooling](#tooling) to setup docker) | ||
|
||
### Custom test discord server | ||
|
||
If you aren't part of Codinglab [(?)](https://prout.dev), you can create a test discord-server similar to Codinglab's by using [our template](https://discord.new/E2RjGshcThgx). | ||
|
||
Get your invitation link from the [the developer portal](https://discord.com/developers/applications) in `Your App > OAuth2 > URL Generator`, and invite the bot in your discord-server. | ||
|
||
## Tooling | ||
|
||
We use [Prettier](https://prettier.io/) and [ESLint](https://eslint.org/) to maintain | ||
consistency in our code. | ||
You should set your editor up so that those tools are properly integrated. Our integration pipeline will run pnpm scripts to lint, format, typecheck, and test in order to merge. | ||
|
||
[OPTIONNAL]: To enable persistance, install [Docker](https://www.docker.com/) & [docker-compose](https://github.com/docker/compose) installed on your machine as you will need it to create your development environment. | ||
If needed, you can install it following [its documentation](https://docs.docker.com/get-docker/). | ||
|
||
## Making Pull Requests | ||
|
||
In order to contribute to the project, you will need to fork the repository first. | ||
Then, create a **Draft pull request** to let us known that you are working on it. | ||
Make sure your title follows the [conventional commits naming scheme](https://conventionalcommits.org/) | ||
as it helps us to sort pull requests (you can view examples searching throughout our git history). | ||
When, you think that your work is ready, mark your PR as **Ready for review**. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FROM node:20.6.0-alpine as base | ||
|
||
WORKDIR /app | ||
|
||
RUN corepack enable | ||
RUN apk add --no-cache python3 make g++ | ||
|
||
COPY pnpm-lock.yaml package.json ./ | ||
|
||
RUN pnpm fetch | ||
|
||
FROM base as build | ||
|
||
WORKDIR /app | ||
|
||
COPY tsup.config.ts ./ | ||
COPY src ./src | ||
|
||
RUN pnpm install --frozen-lockfile --offline && \ | ||
pnpm run build | ||
|
||
FROM base as production-dependencies | ||
|
||
WORKDIR /app | ||
|
||
RUN pnpm install --production --frozen-lockfile --offline | ||
|
||
FROM node:20.6.0-alpine as application | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=production-dependencies --chown=node /app/node_modules ./node_modules | ||
COPY --from=build --chown=node /app/dist ./ | ||
|
||
RUN echo '{"type":"module"}' > package.json | ||
|
||
USER node | ||
|
||
CMD node --enable-source-maps main.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Codinglab | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<h1 align="center">Discord bot</h1> | ||
|
||
<p align="center"> | ||
Discord bot used in <a href="https://discord.gg/7Guzz9e">Codinglab server</a>. | ||
</p> | ||
|
||
<br/> | ||
|
||
## Current Features | ||
|
||
- [Create audio channels on demand by joining a Lobby.](./src/modules/voiceOnDemand) | ||
- [Ping to test availability with `/fart`.](./src/modules/fart) | ||
- [Reply with "feur" when a sentence ends by "quoi"](./src/modules/quoiFeur/). | ||
- [Replace a message containing a pattern by another one.](./src/modules/recurringMessage/) | ||
- [Add voting reactions and summarize every message in a channel.](./src/modules/coolLinksManagement/) | ||
- [Can send a message for the interval of your choice. (eg: every day)](./src/modules/recurringMessage/) | ||
|
||
## Core concept | ||
|
||
The bot is using a modular approach, each feature is created in it's own dedicated folder inside [modules](./src/modules/). | ||
|
||
To create a new feature, create a new folder, call `createModule()` and fill in your slashCommands, event-handlers, environments and storage, the [core](./src/core/) handles the rest. | ||
|
||
Altough the bot is really dedicated to the codinglab community, it's possible to run it for you with minimum configuration, and remove/add modules at will. It's also possible to invite it to multiple discord servers. | ||
|
||
## Contributing | ||
|
||
To contribute or self-host the bot, see our [contributing guide](./CONTRIBUTING.md). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: '3' | ||
|
||
volumes: | ||
redis-data: | ||
|
||
services: | ||
redis: | ||
image: redis:7.2.1-alpine | ||
ports: | ||
- '6379:6379' | ||
volumes: | ||
- redis-data:/data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we must use node 20.8.1.
Latest version of node don't work.