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

Réécriture complète de la structure du projet #178

Merged
merged 106 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
90f79c3
Refactoring all projet
Unarray Feb 25, 2023
0e45d57
Change file name & .gitignore
Unarray Feb 25, 2023
b90099d
Update loader
Unarray Feb 25, 2023
8224217
Add `main` command with new structure
Unarray Feb 27, 2023
71cbd6e
Move functions/types
Unarray Feb 28, 2023
ff05e5c
Create handler for events
Unarray Feb 28, 2023
84f33a4
Create handler for tasks
Unarray Feb 28, 2023
7a3ddab
Update paths
Unarray Feb 28, 2023
35b881b
Fix TS error with generic `EventExecute` in loader
Unarray Feb 28, 2023
0f5bfd4
Renaming all files to `kebab-case`
Unarray Feb 28, 2023
3173409
Convert `regular function` to `arrow function`
Unarray Feb 28, 2023
4821c02
Remove `export default`
Unarray Feb 28, 2023
614c913
update message system
Unarray Feb 28, 2023
2f9ecbb
Add `anniversaire` command
Unarray Feb 28, 2023
56e38c7
Update `main` command to new message system
Unarray Feb 28, 2023
2c53cc0
Add `clean` command
Unarray Mar 1, 2023
80cbcd4
Add `emoji` command
Unarray Mar 1, 2023
f7ebaa4
Remove `deffered reply` used for tests
Unarray Mar 1, 2023
c4407ce
Add `forum` command
Unarray Mar 1, 2023
823ce69
Remove `ephemeral` from `form` succes message
Unarray Mar 1, 2023
2824533
Create new config file
Unarray Mar 16, 2023
a06a26f
Use satisfies
Unarray Mar 16, 2023
54067bd
Loader now support guild commands
Unarray Mar 16, 2023
40bd079
Remove `$resources` typescript path
Unarray Mar 16, 2023
d35385c
Remove useless `console.log`
Unarray Mar 16, 2023
dfef8e4
Remove crown
Unarray Mar 16, 2023
480609d
update configs
Unarray Mar 17, 2023
b8da72b
Update utils to new configs
Unarray Mar 17, 2023
1ccba94
Update `anniversaire` to new configs
Unarray Mar 17, 2023
1d44733
Update `clean` to new configs
Unarray Mar 17, 2023
a5a8bad
Configs update
Unarray Mar 18, 2023
b80d355
Typing of Object.keys methode
Unarray Mar 18, 2023
13c71ab
Update `emoji` command
Unarray Mar 19, 2023
05f12f8
Remove `enableInDev` from `emoji`
Unarray Mar 19, 2023
2216e35
Update `forum` command
Unarray Mar 19, 2023
8606577
Fix command config/message
Unarray Mar 19, 2023
f958f87
Update `main` command
Unarray Mar 19, 2023
fe543fc
Remove `enableInDev` from `forum` command
Unarray Mar 19, 2023
29cb22b
Update `interaction` command
Unarray Mar 19, 2023
849595a
Add `member` command support
Unarray Mar 20, 2023
3fd5c46
Support `member` command
Unarray Mar 20, 2023
6f127e4
Support `role` command
Unarray Mar 20, 2023
d52f73e
Support `roles-selector` interaction
Unarray Mar 20, 2023
e8baeb0
Support `roulette` command
Unarray Mar 20, 2023
09509bc
Support `roulette` event
Unarray Mar 20, 2023
5b58164
Support `stats` command
Unarray Mar 20, 2023
3e211b7
Add mising `execute` test to the command loader
Unarray Mar 21, 2023
e4282f8
Support `top-message` command
Unarray Mar 21, 2023
f756da5
Remove `enableInDev` in `top-message` command
Unarray Mar 21, 2023
92e1be2
Support `top-voice` command
Unarray Mar 21, 2023
8744514
Support `ChannelDelete` event
Unarray Mar 21, 2023
7fa47ee
Support `github-link-reaction` event
Unarray Mar 22, 2023
8b74f1b
Support `guild-member-add` event
Unarray Mar 22, 2023
f9b9904
Delete useless file
Unarray Mar 22, 2023
a419155
Remove `enableInDev` from `guild-member-add` event
Unarray Mar 22, 2023
3af19e2
Support `guild-member-remove` event
Unarray Mar 22, 2023
c3723b0
Support `guild-member-update` event
Unarray Mar 22, 2023
559d988
Support `message-create` event
Unarray Mar 22, 2023
90175f0
Update `discord.js` package
Unarray Mar 23, 2023
6546de2
Support `message-link-reaction` event
Unarray Mar 23, 2023
9d8b941
Remove `enableInDev` from `msg-create`, `msg-link`
Unarray Mar 23, 2023
08f10a3
Support `role-delete.event.ts` event
Unarray Mar 23, 2023
fc98d69
Support `user-update` event
Unarray Mar 23, 2023
434bfeb
Remove `enableInDev` from `user-update`
Unarray Mar 23, 2023
ef80f41
Load loaders
Unarray Mar 23, 2023
612f83b
Support `verif-message-reaction-add` event
Unarray Mar 23, 2023
c68e99d
Support `verif-modal` event
Unarray Mar 23, 2023
3bcaad9
Add cron to project
Unarray Mar 23, 2023
7be1419
Support `activity-update` task
Unarray Mar 23, 2023
4e83f14
Support `birthday-checker` task
Unarray Mar 23, 2023
77ea8e1
Support `tier-update`, `tier-update-game` tasks
Unarray Mar 23, 2023
639bffa
Support `verify-members` task
Unarray Mar 23, 2023
10753a0
Update `readme.md` ❤
Unarray Mar 23, 2023
e2b1b56
Add warning
Unarray Mar 23, 2023
7b054ae
lisibility ?
Unarray Mar 23, 2023
7a1a4dc
code-check (action): add type check
Bluzzi Mar 23, 2023
0a3e1d1
Add `guild` export to `README.MD`
Unarray Mar 24, 2023
6f54550
Update logger
Unarray Mar 24, 2023
83136dd
Improve `command loader`
Unarray Mar 27, 2023
cf03c6e
Init commit
Unarray Mar 27, 2023
fec3ef7
Inactive command work
Unarray Mar 28, 2023
4edd1ae
Add messages
Unarray Mar 29, 2023
4ae662c
Use messages
Unarray Mar 29, 2023
abcd332
Add createdAt field & username in modal title
Unarray Mar 29, 2023
094fc16
Remove useless file
Unarray Mar 29, 2023
95d09bd
Remove `enableInDev`
Unarray Mar 29, 2023
3f203ce
Add a little bit of comments
Unarray Mar 29, 2023
64afece
Improve `command loader`
Unarray Mar 29, 2023
ea5c7a7
Merge branch 'big-refactor' of https://github.com/Virtual-Royaume/Roy…
Unarray Mar 29, 2023
de7fa1b
Remove useless code
Unarray Mar 29, 2023
9e53cc8
Update discord-bot version to `3.0.0`
Unarray Mar 29, 2023
becd914
Update `package.json`
Unarray Mar 29, 2023
df249d2
Add `file.const.ts` file
Unarray Mar 30, 2023
b4818b5
Remove `forum-search` event
Unarray Mar 30, 2023
9f923b5
Update to `file.const.ts`
Unarray Mar 30, 2023
6562e7e
Update to `file.const.ts`
Unarray Mar 30, 2023
22b2b68
Update `file.const.ts`
Unarray Mar 30, 2023
3881ffe
Fix message
Unarray Mar 30, 2023
5632f2a
Fix wrong import
Unarray Mar 30, 2023
9923d43
fix `birthday.cmd.ts` *(missing query)*
Unarray Mar 31, 2023
b3ef6cd
Fix `emoji.cmd.ts`
Unarray Mar 31, 2023
89811cc
Fix `github-link-reaction`
Unarray Mar 31, 2023
00af91f
Add multi-guild command support
Unarray Mar 31, 2023
c0eafc0
Merge branch 'main' into big-refactor
Bluzzi Apr 3, 2023
cbc4814
fix merge conflicts
Bluzzi Apr 3, 2023
005fc21
client: restore
Bluzzi Apr 3, 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
29 changes: 29 additions & 0 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Code check

on:
push:
branches: ["main", "env/prod", "env/dev"]
pull_request:
types: [opened, synchronize]

jobs:
lint:
name: ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
- uses: actions/checkout@v3
- name: Install dependencies
run: npm install
- name: Run ESLint
run: npm run lint
typecheck:
name: TS Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
- uses: actions/checkout@v3
- name: Install dependencies
run: npm install
- name: Run typecheck
run: npx tsc --noEmit
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,7 @@ pnpm-lock.yaml
build/

# Ignore idea directory Jetbrain
.idea/
.idea/

# Ignore vscode directory VisualStudioCode
.vscode/
139 changes: 130 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
# Royaume Discord Bot
It is the bot of our Discord community, it offers various utility features. It is written in TypeScript and uses the DiscordJS package to interact with the Discord API.

## Invite link (only work for Royaume server)
- [INVITE LINK](https://discord.com/api/oauth2/authorize?client_id=831542935014867014&permissions=0&scope=applications.commands%20bot)
- [INVITE LINK (DEV BOT)](https://discord.com/api/oauth2/authorize?client_id=985837649048784917&permissions=0&scope=bot%20applications.commands)

## How to start
## Setup
### Node & NPM
You must have NodeJS and NPM installed on your PC with this versions :
| NodeJS | NPM |
| ------- | ----- |
| 18.X | 8.X |
| NodeJS | NPM |
| ------ | --- |
| 18.X | 8.X |

### Environment variables
You must set this environment variables in your .env file :
```
# Discord bot token :
BOT_TOKEN="get the Discord bot token in our Discord"
BOT_TOKEN="your token"

# GitHub token :
GITHUB_TOKEN="your GitHub PAT (personal access token)"
Expand All @@ -28,3 +24,128 @@ API_TOKEN="get the API token in our Discord"

### Recommended VSCode extensions
- [GraphQL](https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql-syntax)
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)

## Usage
### File strucure for auto-loading
```
📂src/
├── 📂commands/
│ └── 📂command-name/
│ ├── 📄command-name.builder.ts
│ ├── 📄command-name.cmd.ts
│ ├── 📄command-name.util.ts
│ ├── 📄command-name.type.ts
│ └── 📂[sub-commands]/
│ ├── 📂group-exemple/
│ │ └── 📄sub-cmd-name.cmd.ts
│ └── 📄sub-cmd-name.cmd.ts
```
<details>
<summary>Commands</summary>

⚠ All commands files, sub-commands files, groups folders and sub-command-group files should have the same name as defined in your `command-name.builder.ts`

---
#### `command-name.builder.ts`
Builder of our command
| export | type | required | description |
| :------------- | :----------------------- | :--------------------------- | :-------------------------------------------------------- |
| `slashCommand` | `SlashCommandDefinition` | `true` | SlashCommandBuilder of our command |
| `guilds` | `GuildsCommand` | `false` | If this is defined, command will only be on these servers |
| `enableInDev` | `EnableInDev` | `false` *(default: `false`)* | If bot is launch in dev-mode, command will not be loaded |

---
#### `command-name.cmd.ts`
Execution of our command
| export | type | required | description |
| :-------- | :--------------- | :------- | :------------------------------------------ |
| `execute` | `CommandExecute` | `true` | Will be executed when the command is called |

\--------------------------------------------------------------------------------------------------
<details>
<summary>SubCommands</summary>

`SubCommands` are located in `[sub-commands]/` folder of our command

#### `group-exemple/sub-cmd-name.cmd.ts`
Execution of our sub-command group
| export | type | required | description |
| :-------- | :--------------- | :------- | :---------------------------------------------------- |
| `execute` | `CommandExecute` | `true` | Will be executed when the sub command group is called |

#### `sub-cmd-name.cmd.ts`
Execution of our sub-command
| export | type | required | description |
| :-------- | :--------------- | :------- | :---------------------------------------------- |
| `execute` | `CommandExecute` | `true` | Will be executed when the sub command is called |
</details>

\--------------------------------------------------------------------------------------------------
#### `command-name.util.ts`
All utilities functions our command need

---
#### `command-name.type.ts`
All types our command need

---
</details>

```
├── 📂events/
│ └── 📂event-name/
│ ├── 📄event-name.event.ts
│ ├── 📄event-name.util.ts
│ └── 📄event-name.type.ts
```
<details>
<summary>Events</summary>

#### `event-name.event.ts`
Builder of our event
| export | type | required | description |
| :------------ | :------------- | :--------------------------- | :----------------------------------------------------- |
| `event` | `EventName` | `true` | Name of our targeted event |
| `execute` | `EventExecute` | `true` | Will be executed when our event will be called |
| `enableInDev` | `EnableInDev` | `false` *(default: `false`)* | If bot is launch in dev-mode, event will not be loaded |

---
#### `event-name.util.ts`
All utilities functions our event need

---
#### `event-name.type.ts`
All types our event need

---
</details>

```
└── 📂tasks/
└── 📂task-name/
├── 📄task-name.task.ts
├── 📄task-name.util.ts
└── 📄task-name.type.ts
```
<details>
<summary>Tasks</summary>

#### `task-name.task.ts`
Builder of our event
| export | type | required | description |
| :------------ | :------------- | :--------------------------- | :------------------------------------------------------------------------------------------- |
| `interval` | `TaskInterval` | `true` | Interval of our task *(write in cron syntaxe: "* * * * * *" => "sec min hour d month week")* |
| `execute` | `TaskExecute` | `true` | Will be executed when our task will be on his interval |
| `enableInDev` | `EnableInDev` | `false` *(default: `false`)* | If bot is launch in dev-mode, task will not be loaded |

---
#### `task-name.util.ts`
All utilities functions our task need

---
#### `task-name.type.ts`
All types our task need

---
</details>
2 changes: 1 addition & 1 deletion gql-codegen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CodegenConfig } from "@graphql-codegen/cli";
import { getStringEnv } from "./src/utils/EnvVariable";
import { getStringEnv } from "./src/utils/env-variable";

const apiLink = getStringEnv("API_LINK");
const apiToken = getStringEnv("API_TOKEN");
Expand Down
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"version": "2.7.0",
"main": "build/src/Client.js",
"name": "royaume-discord-bot",
"displayName": "Royaume-Discord-Bot",
"version": "3.0.0",
"main": "build/src/client.js",
"scripts": {
"dev": "nodemon --exec node -r @swc-node/register -r tsconfig-paths/register ./src/Client.ts dev",
"start": "node -r @swc-node/register -r tsconfig-paths/register ./src/Client.ts",
"dev": "npx nodemon --exec node -r @swc-node/register -r tsconfig-paths/register ./src/client.ts dev",
"start": "node -r @swc-node/register -r tsconfig-paths/register ./src/client.ts",
"lint": "eslint ./src",
"lint:fix": "eslint ./src --fix",
"gen:gql": "graphql-codegen --config gql-codegen.ts",
Expand All @@ -12,16 +14,18 @@
"dependencies": {
"chart.js": "^3.9.1",
"chartjs-node-canvas": "^4.1.6",
"cron": "^2.3.0",
"dayjs": "^1.11.7",
"discord.js": "^14.7.1"
"discord.js": "^14.8.0"
},
"devDependencies": {
"@bluzzi/eslint-config": "^0.8.2",
"@graphql-codegen/cli": "3.2.2",
"@graphql-codegen/client-preset": "2.1.1",
"@graphql-typed-document-node/core": "^3.1.1",
"@swc-node/register": "^1.5.4",
"@swc/core": "^1.3.39",
"@swc/core": "^1.3.24",
"@types/cron": "^2.0.1",
"@types/node": "^18.11.18",
"dotenv": "^16.0.3",
"eslint": "^8.36.0",
Expand Down
9 changes: 0 additions & 9 deletions resources/art/crown.txt

This file was deleted.

77 changes: 0 additions & 77 deletions resources/config/information.json

This file was deleted.

19 changes: 0 additions & 19 deletions resources/config/interaction-ids.json

This file was deleted.

Loading