Skip to content

Commit

Permalink
Minor Rewrite
Browse files Browse the repository at this point in the history
- Move from json config to .env
- Update packages
- Add Prettier
- Cleanup tsconfig
- index.ts -> main.ts
- Use Discord attachments
- Add maximum upload size
- Formatting
  • Loading branch information
SomeAspy committed Aug 3, 2024
1 parent ea972b1 commit fbcbbc6
Show file tree
Hide file tree
Showing 27 changed files with 969 additions and 1,015 deletions.
17 changes: 17 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
DISCORD_TOKEN=""
MONGO_DB="mongodb://localhost:27017"
CLIENT_ID=""
DATABASE_NAME=""
COLLECTION_NAME=""
MAX_BADGES="5"
EXTRA_BOOST_BADGES="5"
MAX_BADGE_SIZE="5242880"
PROMPT_CHANNEL=""
VERIFIER_ROLE=""
BUCKET_ENDPOINT=""
BUCKET_PORT="443"
BUCKET_SSL="true"
BUCKET_ACCESS_KEY=""
BUCKET_SECRET_KEY=""
BUCKET_NAME=""
BUCKET_DOMAIN="https://s3.example.com"
35 changes: 18 additions & 17 deletions .github/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,24 @@
- `application.commands` (To create commands)
2. Add the bot to your server
3. Clone this repository (`git clone https://github.com/WolfPlugs/GiBBy`)
4. Set configs in `config/config.json` (copy `config.example.json` and rename the copy to `config.json`)
- `DiscordToken`: The bot's Discord token
- `MongoDB`: The MongoDB connection string (default: `mongodb://localhost:27017`)
- `ClientId`: The bot's Discord ID
- `DatabaseName`: The name of the MongoDB database
- `CollectionName`: The collection name of the MongoDB database
- `MaxBadges`: The maximum badges a user can have (default: `5`)
- `ExtraBoostBadges`: The amount of badges added to booster's allowance (default: `5`)
- `PromptChannel`: The channel to send the badge requests to
- `VerifierRole`: The role ID of people who can approve requests
- `Domains`: An array of whitelisted domains for badges
- `BucketEndpoint`: The URL to upload to the bucket
- `BucketPort`: The port to upload to the bucket. (default: `443`)
- `BucketAccessKey`: The bucket's access key
- `BucketSecretKey`: The bucket's secret key
- `BucketName`: The bucket's name
- `BucketDomain`: The bucket's public facing URL
4. Set configs in `.env` (copy `.env.example` and rename the copy to `.env`)
- `DISCORD_TOKEN`: The bot's Discord token
- `MONGO_DB`: The MongoDB connection string (default: `mongodb://localhost:27017`)
- `CLIENT_ID`: The bot's Discord ID
- `DATABASE_NAME`: The name of the MongoDB database
- `COLLECTION_NAME`: The collection name of the MongoDB database
- `MAX_BADGES`: The maximum badges a user can have (default: `5`)
- `EXTRA_BOOST_BADGES`: The amount of badges added to booster's allowance (default: `5`)
- `MAX_BADGE_SIZE`: The maximum badge size, in binary bytes. (default: `5242880` 5mb)
- `PROMPT_CHANNEL`: The channel to send the badge requests to
- `VERIFIER_ROLE`: The role ID of people who can approve requests
- `BUCKET_ENDPOINT`: The URL to upload to the bucket
- `BUCKET_PORT`: The port to upload to the bucket. (default: `443`)
- `BUCKET_SSL`: Whether or not to use SSL. (default: `true`)
- `BUCKET_ACCESS_KEY`: The bucket's access key
- `BUCKET_SECRET_KEY`: The bucket's secret key
- `BUCKET_NAME`: The bucket's name
- `BUCKET_DOMAIN`: The bucket's public facing URL. (default: `https://s3.example.com`)
5. Install packages using a node package manager (I suggest [PNPM](https://pnpm.io/)): `pnpm i`
6. Build: `pnpm build`
7. Run: `pnpm start`
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
dist
config/config.json
.env
23 changes: 0 additions & 23 deletions config/config.example.json

This file was deleted.

14 changes: 6 additions & 8 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config(
eslint.configs.recommended,
{ignores:["dist/"]},
{ ignores: ["dist/", "*.config.js"] },
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{

languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules:{
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/prefer-for-of": "off"
}
},
},
);
);
28 changes: 13 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
{
"type": "module",
"scripts": {
"dev": "tsx src/index.ts",
"start": "node dist/src/index.js",
"dev": "tsx --env-file=.env src/main.ts",
"start": "node --env-file=.env dist/main.js",
"build": "tsc",
"lint": "eslint \"**/*.ts\" ."
"lint": "eslint"
},
"devDependencies": {
"@eslint/js": "^9.4.0",
"@eslint/js": "^9.8.0",
"@types/eslint__js": "^8.42.3",
"@types/node": "^20.14.2",
"eslint": "^9.4.0",
"@types/node": "^22.1.0",
"eslint": "^9.8.0",
"prettier": "^3.3.3",
"tsx": "^4.16.5",
"typescript": "^5.4.5",
"typescript-eslint": "^7.13.0"
"typescript-eslint": "^8.0.0"
},
"dependencies": {
"@discordjs/rest": "^2.3.0",
"discord.js": "^14.15.3",
"minio": "^8.0.0",
"mongodb": "^6.7.0"
"minio": "^8.0.1",
"mongodb": "^6.8.0"
},
"optionalDependencies": {
"tsx": "^4.15.4"
},
"packageManager": "pnpm@9.1.4"
}
"packageManager": "pnpm@9.6.0+sha512.38dc6fba8dba35b39340b9700112c2fe1e12f10b17134715a4aa98ccf7bb035e76fd981cf0bb384dfa98f8d6af5481c2bef2f4266a24bfa20c34eb7147ce0b5e"
}
Loading

0 comments on commit fbcbbc6

Please sign in to comment.