Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #178 from Virtual-Royaume/big-refactor
Browse files Browse the repository at this point in the history
Refactoring all projet
  • Loading branch information
Bluzzi authored Apr 3, 2023
2 parents 4d9f382 + 005fc21 commit 326a850
Show file tree
Hide file tree
Showing 183 changed files with 4,376 additions and 3,951 deletions.
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

0 comments on commit 326a850

Please sign in to comment.