BREAKING CHANGE: Config file is now .env file.
This commit is contained in:
parent
63864b073f
commit
0f664e97fb
11 changed files with 46 additions and 41 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -79,6 +79,7 @@ web_modules/
|
|||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
docker.env
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM node:18.20.3
|
||||
FROM node:18.20.4
|
||||
|
||||
ENV DOCKERIZE_VERSION v0.2.0
|
||||
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"bot": {
|
||||
"owner_ID": "",
|
||||
"token": "",
|
||||
"prefix": ""
|
||||
},
|
||||
"train": {
|
||||
"user_ID": ""
|
||||
},
|
||||
"mysql": {
|
||||
"user": "",
|
||||
"host": "",
|
||||
"password": "",
|
||||
"database": "",
|
||||
"port": 3306
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ services:
|
|||
ports:
|
||||
- "1502:3306"
|
||||
env_file:
|
||||
- "./.env"
|
||||
- "./docker.env"
|
||||
networks:
|
||||
- muffin_ai
|
||||
discord_bot:
|
||||
|
@ -19,6 +19,8 @@ services:
|
|||
- muffin_ai
|
||||
depends_on:
|
||||
- database
|
||||
env_file:
|
||||
- "./.env"
|
||||
|
||||
networks:
|
||||
muffin_ai:
|
||||
|
|
5
example-docker.env
Normal file
5
example-docker.env
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Docker configs
|
||||
MYSQL_USER=
|
||||
MYSQL_PASSWORD=
|
||||
MYSQL_DATABASE=
|
||||
MYSQL_ROOT_PASSWORD=
|
19
example.env
19
example.env
|
@ -1,8 +1,13 @@
|
|||
# docker (option)
|
||||
MYSQL_USER=
|
||||
MYSQL_PASSWORD=
|
||||
MYSQL_DATABASE=
|
||||
MYSQL_ROOT_PASSWORD=
|
||||
# Prisma configs
|
||||
# Environment variables declared in this file are automatically made available to Prisma.
|
||||
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
|
||||
|
||||
# prisma (require)
|
||||
DATABASE_URL=
|
||||
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
||||
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
||||
DATABASE_URL=
|
||||
|
||||
# Bot configs
|
||||
BOT_TOKEN=
|
||||
BOT_OWNER_ID=
|
||||
BOT_PREFIX=
|
||||
TRAIN_USER_ID=
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "muffinbot",
|
||||
"version": "4.0.0-pudding.e240922a",
|
||||
"version": "4.0.0-pudding.e240922b",
|
||||
"main": "dist/index.js",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
|
@ -13,6 +13,7 @@
|
|||
"discord-api-types": "^0.37.100",
|
||||
"discord.js": "^14.16.2",
|
||||
"dokdo": "^0.6.2",
|
||||
"dotenv": "^16.4.5",
|
||||
"mysql2": "^3.11.3",
|
||||
"semver": "^7.6.3",
|
||||
"undici": "^6.19.8"
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { SapphireClient, container, LogLevel } from '@sapphire/framework'
|
||||
import { GatewayIntentBits, Partials, type Snowflake } from 'discord.js'
|
||||
import { ChatBot, NODE_ENV } from './modules'
|
||||
import { GatewayIntentBits, Partials } from 'discord.js'
|
||||
import { ChatBot, Config, NODE_ENV } from './modules'
|
||||
import { version } from '../package.json'
|
||||
import { PrismaClient } from '../prisma'
|
||||
import config from '../config.json'
|
||||
import semver from 'semver'
|
||||
|
||||
const config = new Config()
|
||||
|
||||
// Load pieces
|
||||
import './interaction-handlers/_load'
|
||||
import './listeners/_load'
|
||||
|
@ -68,15 +69,7 @@ declare module '@sapphire/framework' {
|
|||
prefix: string
|
||||
version: string
|
||||
dokdoAliases: string[]
|
||||
config: {
|
||||
bot: {
|
||||
owner_ID: Snowflake
|
||||
token: string
|
||||
}
|
||||
train: {
|
||||
user_ID: Snowflake
|
||||
}
|
||||
}
|
||||
config: Config
|
||||
release: 'EXPERIMENTAL' | 'DEV' | 'PREVIEW' | 'RELEASE'
|
||||
}
|
||||
}
|
||||
|
|
13
src/modules/config.ts
Normal file
13
src/modules/config.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import 'dotenv/config'
|
||||
|
||||
export default class MAAConfig {
|
||||
public readonly bot = {
|
||||
token: process.env.BOT_TOKEN!,
|
||||
owner_ID: process.env.BOT_OWNER_ID!,
|
||||
prefix: process.env.BOT_PREFIX!,
|
||||
}
|
||||
|
||||
public readonly train = {
|
||||
user_id: process.env.TRAIN_USER_ID!,
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import { NODE_ENV } from './env'
|
||||
import ChatBot from './ChatBot'
|
||||
import Config from './config'
|
||||
import noPerm from './noPerm'
|
||||
|
||||
export { NODE_ENV, ChatBot, noPerm }
|
||||
export { NODE_ENV, ChatBot, noPerm, Config }
|
||||
|
|
|
@ -1823,7 +1823,7 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"dotenv@npm:^16.3.1":
|
||||
"dotenv@npm:^16.3.1, dotenv@npm:^16.4.5":
|
||||
version: 16.4.5
|
||||
resolution: "dotenv@npm:16.4.5"
|
||||
checksum: 10c0/48d92870076832af0418b13acd6e5a5a3e83bb00df690d9812e94b24aff62b88ade955ac99a05501305b8dc8f1b0ee7638b18493deb6fe93d680e5220936292f
|
||||
|
@ -3014,6 +3014,7 @@ __metadata:
|
|||
discord-api-types: "npm:^0.37.100"
|
||||
discord.js: "npm:^14.16.2"
|
||||
dokdo: "npm:^0.6.2"
|
||||
dotenv: "npm:^16.4.5"
|
||||
eslint: "npm:^9.11.0"
|
||||
eslint-config-prettier: "npm:^9.1.0"
|
||||
eslint-plugin-prettier: "npm:^5.2.1"
|
||||
|
|
Loading…
Reference in a new issue