mirror of
https://github.com/xHyroM/roles-bot.git
synced 2024-11-23 16:51:06 +01:00
refactor: init codebase
This commit is contained in:
parent
6afd498fb5
commit
79dcde2f86
18 changed files with 1247 additions and 1034 deletions
49
.gitignore
vendored
49
.gitignore
vendored
|
@ -1,9 +1,5 @@
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,node
|
||||||
# Created by https://www.toptal.com/developers/gitignore/api/node
|
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,node
|
||||||
# Edit at https://www.toptal.com/developers/gitignore?templates=node
|
|
||||||
|
|
||||||
# My
|
|
||||||
wrangler.toml
|
|
||||||
|
|
||||||
### Node ###
|
### Node ###
|
||||||
# Logs
|
# Logs
|
||||||
|
@ -62,6 +58,9 @@ web_modules/
|
||||||
# Optional eslint cache
|
# Optional eslint cache
|
||||||
.eslintcache
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
# Microbundle cache
|
# Microbundle cache
|
||||||
.rpt2_cache/
|
.rpt2_cache/
|
||||||
.rts2_cache_cjs/
|
.rts2_cache_cjs/
|
||||||
|
@ -77,10 +76,12 @@ web_modules/
|
||||||
# Yarn Integrity file
|
# Yarn Integrity file
|
||||||
.yarn-integrity
|
.yarn-integrity
|
||||||
|
|
||||||
# dotenv environment variables file
|
# dotenv environment variable files
|
||||||
.env
|
.env
|
||||||
.env.test
|
.env.development.local
|
||||||
.env.production
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
.cache
|
.cache
|
||||||
|
@ -103,6 +104,12 @@ dist
|
||||||
# vuepress build output
|
# vuepress build output
|
||||||
.vuepress/dist
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
# Serverless directories
|
# Serverless directories
|
||||||
.serverless/
|
.serverless/
|
||||||
|
|
||||||
|
@ -130,9 +137,29 @@ dist
|
||||||
.webpack/
|
.webpack/
|
||||||
|
|
||||||
# Optional stylelint cache
|
# Optional stylelint cache
|
||||||
.stylelintcache
|
|
||||||
|
|
||||||
# SvelteKit build / generate output
|
# SvelteKit build / generate output
|
||||||
.svelte-kit
|
.svelte-kit
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/node
|
### VisualStudioCode ###
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
!.vscode/*.code-snippets
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Built Visual Studio Code Extensions
|
||||||
|
*.vsix
|
||||||
|
|
||||||
|
### VisualStudioCode Patch ###
|
||||||
|
# Ignore all local history of files
|
||||||
|
.history
|
||||||
|
.ionide
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,node
|
||||||
|
|
||||||
|
.turbo
|
12
.vscode/settings.json
vendored
12
.vscode/settings.json
vendored
|
@ -1,10 +1,8 @@
|
||||||
{
|
{
|
||||||
"liveServer.settings.port": 5501,
|
"[typescript]": {
|
||||||
"liveSassCompile.settings.formats": [
|
"editor.defaultFormatter": "rome.rome"
|
||||||
{
|
},
|
||||||
"format": "expanded",
|
"[javascript]": {
|
||||||
"extensionName": ".css",
|
"editor.defaultFormatter": "rome.rome"
|
||||||
"savePath": "/packages/website/styles/css"
|
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
45
README.md
45
README.md
|
@ -1,7 +1,46 @@
|
||||||
<div align="center">
|
<h1 align="center">
|
||||||
<h1>Discord Roles Bot</h1>
|
<br>
|
||||||
</div>
|
<img src="https://github.com/xHyroM/website/blob/main/src/assets/logo.png?raw=true" alt="Hyro" width="256">
|
||||||
|
<br>
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<h4 align="center">Source code for Roles Bot, a discord bot.</h4>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://discord.gg/kFPKmEKeMS/" alt="Discord">
|
||||||
|
<img src="https://img.shields.io/discord/1046534628577640528?label=discord&style=for-the-badge&color=2fbfc4"/>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## Informations
|
||||||
|
|
||||||
Discord bot for reaction roles that works with [Cloudflare Workers](https://workers.cloudflare.com/).
|
Discord bot for reaction roles that works with [Cloudflare Workers](https://workers.cloudflare.com/).
|
||||||
|
|
||||||
You can add the bot to your server, just click [here](https://discord.com/api/oauth2/authorize?client_id=923267906941370368&permissions=268435456&scope=bot%20applications.commands).
|
You can add the bot to your server, just click [here](https://discord.com/api/oauth2/authorize?client_id=923267906941370368&permissions=268435456&scope=bot%20applications.commands).
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
1. Clone this repository: `git clone https://github.com/xHyroM/roles-bot.git`
|
||||||
|
2. Navigate to the project directory: `cd roles-bot`
|
||||||
|
3. Install the dependencies: `pnpm install`
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
- To run the development server: `pnpm run dev`
|
||||||
|
- To build the project for production: `pnpm run build`
|
||||||
|
- To preview the production build of website: `pnpm run preview`
|
||||||
|
- To deploy bot to CF workers: `pnpm run deploy`
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
To contribute to this project, please follow the [standard Git workflow](https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository#The-Standard-Git-Workflow) and [CONTRIBUTING](./CONTRIBUTING.md).
|
||||||
|
|
||||||
|
1. Fork this repository
|
||||||
|
2. Create a new branch for your changes: `git checkout -b my-feature`
|
||||||
|
3. Commit your changes: `git commit -am "Add my feature"`
|
||||||
|
4. Push the branch: `git push origin my-feature`
|
||||||
|
5. Open a pull request
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the [MIT License](./LICENSE).
|
||||||
|
|
24
package.json
24
package.json
|
@ -1,24 +1,22 @@
|
||||||
{
|
{
|
||||||
"name": "roles-bot",
|
"name": "roles-bot",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "dist/worker.mjs",
|
"description": "",
|
||||||
"type": "module",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node scripts/build.mjs",
|
"build": "turbo run build",
|
||||||
"dev": "miniflare --watch --debug --port 8787",
|
"dev": "turbo run dev",
|
||||||
"publish": "cross-env NODE_ENV=production wrangler publish"
|
"preview": "turbo run preview",
|
||||||
|
"deploy": "turbo run deploy",
|
||||||
|
"test": "turbo run test",
|
||||||
|
"lint": "rome check .",
|
||||||
|
"format": "rome format --write ."
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "xHyroM",
|
"author": "xHyroM",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"packageManager": "pnpm@8.1.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@cloudflare/workers-types": "^3.17.0",
|
"rome": "^12.0.0"
|
||||||
"@types/jest": "^29.1.2",
|
|
||||||
"discord-api-types": "^0.37.14",
|
|
||||||
"esbuild": "^0.15.11",
|
|
||||||
"eslint": "^8.25.0",
|
|
||||||
"jest": "^29.2.0",
|
|
||||||
"miniflare": "^2.10.0",
|
|
||||||
"typescript": "^4.8.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
21
packages/bot/LICENSE
Normal file
21
packages/bot/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021 Jozef Steinhübl
|
||||||
|
|
||||||
|
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.
|
7
packages/bot/README.md
Normal file
7
packages/bot/README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<div align="center">
|
||||||
|
<h1>Discord Roles Bot</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Discord bot for reaction roles that works with [Cloudflare Workers](https://workers.cloudflare.com/).
|
||||||
|
|
||||||
|
You can add the bot to your server, just click [here](https://discord.com/api/oauth2/authorize?client_id=923267906941370368&permissions=268435456&scope=bot%20applications.commands).
|
24
packages/bot/package.json
Normal file
24
packages/bot/package.json
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"name": "roles-bot",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "dist/worker.mjs",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "node scripts/build.mjs",
|
||||||
|
"dev": "miniflare --watch --debug --port 8787",
|
||||||
|
"deploy": "cross-env NODE_ENV=production wrangler publish"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "xHyroM",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"@cloudflare/workers-types": "^3.17.0",
|
||||||
|
"@types/jest": "^29.1.2",
|
||||||
|
"discord-api-types": "^0.37.14",
|
||||||
|
"esbuild": "^0.15.11",
|
||||||
|
"eslint": "^8.25.0",
|
||||||
|
"jest": "^29.2.0",
|
||||||
|
"miniflare": "^2.10.0",
|
||||||
|
"typescript": "^4.8.4"
|
||||||
|
}
|
||||||
|
}
|
38
packages/bot/scripts/build.mjs
Normal file
38
packages/bot/scripts/build.mjs
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import esbuild from "esbuild";
|
||||||
|
import { rmSync, existsSync } from "node:fs";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
||||||
|
|
||||||
|
if (existsSync(join(__dirname, "..", "dist")))
|
||||||
|
rmSync(join(__dirname, "..", "dist"), { recursive: true });
|
||||||
|
|
||||||
|
const watch = process.argv.includes("--watch");
|
||||||
|
const dev = process.argv.includes("--dev");
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
esbuild.build({
|
||||||
|
bundle: true,
|
||||||
|
logLevel: "info",
|
||||||
|
format: "esm",
|
||||||
|
mainFields: ["browser", "module", "main"],
|
||||||
|
platform: "neutral",
|
||||||
|
target: "es2020",
|
||||||
|
entryPoints: ["./src/index.ts"],
|
||||||
|
outfile: "./dist/worker.mjs",
|
||||||
|
sourcemap: dev,
|
||||||
|
charset: "utf8",
|
||||||
|
minify: !dev,
|
||||||
|
watch: watch,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
.catch((err) => {
|
||||||
|
console.error("Roles Bot failed to build");
|
||||||
|
console.error(err.message);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
console.log(
|
||||||
|
watch ? "Waiting for your changes..." : "Roles Bot has been built",
|
||||||
|
);
|
||||||
|
});
|
6
packages/bot/src/index.ts
Normal file
6
packages/bot/src/index.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
export default {
|
||||||
|
fetch: (request: Request) => {
|
||||||
|
console.log(request);
|
||||||
|
return new Response("asda");
|
||||||
|
},
|
||||||
|
};
|
|
@ -1,7 +1,7 @@
|
||||||
name = "roles-bot"
|
name = "roles-bot"
|
||||||
type = "javascript"
|
type = "javascript"
|
||||||
account_id = ""
|
account_id = "294bee38d448e390dab3757215c63f03"
|
||||||
workers_dev = true
|
compatibility_date = "2022-07-12"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
command = "pnpm build"
|
command = "pnpm build"
|
1966
pnpm-lock.yaml
1966
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
2
pnpm-workspace.yaml
Normal file
2
pnpm-workspace.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
packages:
|
||||||
|
- "packages/*"
|
12
rome.json
Normal file
12
rome.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"$schema": "./node_modules/rome/configuration_schema.json",
|
||||||
|
"organizeImports": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"linter": {
|
||||||
|
"enabled": true,
|
||||||
|
"rules": {
|
||||||
|
"recommended": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,34 +0,0 @@
|
||||||
import esbuild from 'esbuild';
|
|
||||||
import { rmSync, existsSync } from 'node:fs';
|
|
||||||
import { join } from 'node:path';
|
|
||||||
import { fileURLToPath } from 'node:url';
|
|
||||||
|
|
||||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
||||||
|
|
||||||
if (existsSync(join(__dirname, '..', 'dist')))
|
|
||||||
rmSync(join(__dirname, '..', 'dist'), { recursive: true });
|
|
||||||
|
|
||||||
const watch = process.argv.includes('--watch');
|
|
||||||
const dev = process.argv.includes('--dev');
|
|
||||||
|
|
||||||
Promise.all([
|
|
||||||
esbuild.build({
|
|
||||||
bundle: true,
|
|
||||||
logLevel: 'info',
|
|
||||||
format: 'esm',
|
|
||||||
mainFields: ['browser', 'module', 'main'],
|
|
||||||
platform: 'neutral',
|
|
||||||
target: 'es2020',
|
|
||||||
entryPoints: ['./src/index.ts'],
|
|
||||||
outfile: './dist/worker.mjs',
|
|
||||||
sourcemap: dev,
|
|
||||||
charset: 'utf8',
|
|
||||||
minify: !dev,
|
|
||||||
watch: watch
|
|
||||||
})
|
|
||||||
]).catch(err => {
|
|
||||||
console.error('Roles Bot failed to build');
|
|
||||||
console.error(err.message);
|
|
||||||
}).then(() =>{
|
|
||||||
console.log(watch ? 'Waiting for your changes...' : 'Roles Bot has been built');
|
|
||||||
});
|
|
|
@ -1,6 +0,0 @@
|
||||||
export default {
|
|
||||||
fetch: (request: Request) => {
|
|
||||||
console.log(request);
|
|
||||||
return new Response('asda');
|
|
||||||
}
|
|
||||||
}
|
|
21
turbo.json
Normal file
21
turbo.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://turbo.build/schema.json",
|
||||||
|
"pipeline": {
|
||||||
|
"build": {
|
||||||
|
"dependsOn": ["^build"],
|
||||||
|
"outputs": ["dist"]
|
||||||
|
},
|
||||||
|
"dev": {
|
||||||
|
"outputs": ["dist"]
|
||||||
|
},
|
||||||
|
"preview": {
|
||||||
|
"outputs": ["dist"]
|
||||||
|
},
|
||||||
|
"deploy": {
|
||||||
|
"dependsOn": ["build", "test", "lint"]
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"dependsOn": ["^build"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue