Skip to content
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

Draft
wants to merge 63 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
6e1ad1b
feat: add voice-on-demand functionality (#2)
potb May 18, 2023
29da9a6
chore(deps): update all dependencies (#3)
renovate[bot] May 18, 2023
14b2a0f
refactor(handlers): move conditional logic into handler files (#4)
potb May 19, 2023
6077dd1
chore(deps): update all dependencies (#6)
renovate[bot] May 19, 2023
f32fb8b
ci: make deployment use the production environment (#7)
potb May 19, 2023
ea336aa
chore: remove unused dependency
potb May 19, 2023
28491b6
chore(deps): update all dependencies (#9)
renovate[bot] May 29, 2023
fd38396
chore(deps): update dependency type-fest to v3 (#8)
renovate[bot] May 29, 2023
09fc4ca
chore(deps): update all dependencies (#10)
renovate[bot] Jun 3, 2023
9774856
chore(deps): update all dependencies (#11)
renovate[bot] Jun 11, 2023
34ced5d
chore(deps): update dependency tsup to v7 (#13)
renovate[bot] Jun 18, 2023
c4601e1
chore(deps): update all dependencies (#12)
renovate[bot] Jun 18, 2023
a98f838
chore(deps): update all dependencies (#14)
renovate[bot] Jun 23, 2023
325427c
chore(deps): update all dependencies (#15)
renovate[bot] Jul 1, 2023
84e5ba9
chore(deps): update all dependencies (#16)
renovate[bot] Jul 3, 2023
3653452
chore(deps): update all dependencies (#17)
renovate[bot] Jul 13, 2023
d38e2dd
chore(deps): update all dependencies (major) (#18)
renovate[bot] Jul 14, 2023
bae02d5
chore(deps): update dependency eslint to v8.45.0 (#19)
renovate[bot] Jul 15, 2023
98dcf28
feat: replace twitter links with vxtwitter alternative (#5)
potb Jul 18, 2023
4e5c806
fix: better url mapping vxtwitter (#23)
Yanzi-dev Jul 18, 2023
03e5dd4
chore(deps): update all dependencies (#24)
renovate[bot] Aug 2, 2023
96ee37e
chore(deps): update dependency type-fest to v4 (#25)
renovate[bot] Aug 2, 2023
97337fa
feat: add 'fart' slash command (#26)
luca-montaigut Aug 2, 2023
5917f5e
feat: cool links voting system and autothread (#27)
luca-montaigut Aug 2, 2023
ff6742f
test: add tests to the project (#20)
potb Aug 5, 2023
770a659
chore(deps): update all dependencies (#32)
renovate[bot] Aug 9, 2023
4b591b3
chore(deps): update dependency eslint-config-prettier to v9 (#33)
renovate[bot] Aug 9, 2023
f341bec
chore(deps): update all dependencies (#37)
renovate[bot] Aug 12, 2023
c5ada12
feat: summarize cool links youtube videos (#40)
astahmer Aug 20, 2023
52fd67c
chore(deps): update all dependencies (#39)
renovate[bot] Aug 23, 2023
21e8856
chore(deps): update all dependencies (#42)
renovate[bot] Aug 26, 2023
9339d3e
chore(deps): update all dependencies (#43)
renovate[bot] Aug 29, 2023
1c7fc96
feat: summarize cool pages (#41)
djang0dev Aug 30, 2023
ef17bbe
fix: isASocialNetworkUrl() regex for summarize-cool-pages (#44)
djang0dev Aug 30, 2023
26f0f06
chore: fix linting and formatting (#47)
neolectron Sep 2, 2023
0644538
chore(deps): update all dependencies (#46)
renovate[bot] Sep 2, 2023
b9854c9
refactor: modularize commands and handlers (#48)
neolectron Sep 3, 2023
9221e88
fix: fire event 'ready' on modules (#50)
neolectron Sep 4, 2023
211801d
feat: quoi feur (#52)
luca-montaigut Sep 4, 2023
79fb2e9
feat: allow modules to export intents (#55)
neolectron Sep 5, 2023
9b647eb
feat: manage recurring messages (#53)
luca-montaigut Sep 6, 2023
a2eea82
fix: add intents to recurring message (#60)
luca-montaigut Sep 7, 2023
58ccddd
fix: muted on quoi-feur feature (#61)
luca-montaigut Sep 7, 2023
088f6f6
fix: remove cache entries on delete channel (#62)
luca-montaigut Sep 7, 2023
7713504
fix: change removeEmoji regex to include custom emojis (#63)
dilaouid Sep 8, 2023
6fa4019
feat: better display for recurring messages list (#64)
luca-montaigut Sep 8, 2023
0ba058f
fix: remove width hack (#66)
luca-montaigut Sep 8, 2023
f5dbfcf
fix: adjust coubeh probability (#65)
luca-montaigut Sep 8, 2023
2ceed7c
feat: add ephemeral to bot message (#67)
luca-montaigut Sep 8, 2023
b1d395a
chore(deps): update all dependencies (#70)
renovate[bot] Sep 10, 2023
b221abb
chore(deps): update actions/checkout action to v4 (#71)
renovate[bot] Sep 10, 2023
973161b
fix: remove useless env variables (#72)
luca-montaigut Sep 11, 2023
ceb5709
fix: wrong names of the handlers of quoifeur module (#74)
ayoubqrt Sep 11, 2023
17c107d
fix: use the quoifeurbot in public thread of allowed channels (#73)
dilaouid Sep 12, 2023
9ec51b3
chore(lint): use rule to disable usage of devDeps (#76)
potb Sep 12, 2023
cfe2416
fix: voice lobby now handles multiple guilds (#77)
neolectron Sep 12, 2023
2a57c49
fix(quoi-feur): check if the trigger word is formatted in md (#68)
dilaouid Sep 13, 2023
f25b530
fix: remove audio channel when last member leaves (#79)
neolectron Sep 13, 2023
ceaea24
fix(voice-on-demand): check old state when leaving
potb Sep 13, 2023
26c3cb3
ci: remove duplicated pipeline actions (#83)
neolectron Sep 13, 2023
c47faa1
docs: list features + precise contributing setup
neolectron Sep 14, 2023
8129353
style: fix typo
neolectron Sep 14, 2023
90a5f5b
chore: add summary
neolectron Sep 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
11 changes: 11 additions & 0 deletions .env.example
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=
1 change: 1 addition & 0 deletions .eslintignore
43 changes: 43 additions & 0 deletions .eslintrc.yaml
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
9 changes: 6 additions & 3 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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: ''
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/good-practices.yaml

This file was deleted.

29 changes: 21 additions & 8 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Check Integration

on:
pull_request:
branches:
Expand All @@ -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:
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .npmrc
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
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.6.1
1 change: 1 addition & 0 deletions .prettierignore
63 changes: 63 additions & 0 deletions CONTRIBUTING.md
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.

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.

We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage your Node version.

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when i git clone, .env.example already exist.
Just need to rename .env.example to .env and fill the discord token.


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**.
39 changes: 39 additions & 0 deletions Dockerfile
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
21 changes: 21 additions & 0 deletions LICENSE.md
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.
28 changes: 28 additions & 0 deletions README.md
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).
12 changes: 12 additions & 0 deletions docker-compose.yaml
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
Loading