Updated dir structure
This commit is contained in:
@@ -3,16 +3,13 @@ import color from "utils/functions/colors"
|
||||
import { Redis } from "ioredis"
|
||||
import env from "utils/Env"
|
||||
import { connect } from "mongoose"
|
||||
import init from "utils/Init"
|
||||
import { loadCronEvents } from "utils/eventHandlers"
|
||||
const client = new Client()
|
||||
const redis = new Redis(env.prod.redisURI!)
|
||||
|
||||
class Bot {
|
||||
async start() {
|
||||
init()
|
||||
this.init()
|
||||
client.start()
|
||||
loadCronEvents()
|
||||
redis.on("ready", () => {
|
||||
console.log(color("Connected to Redis", "green"))
|
||||
})
|
||||
@@ -20,6 +17,24 @@ class Bot {
|
||||
console.log(color("Connected to MongoDB", "green"))
|
||||
})
|
||||
}
|
||||
|
||||
private async init() {
|
||||
const prodValues = env.prod
|
||||
const devValues = env.dev
|
||||
|
||||
if (process.env.NODE_ENV === "dev") {
|
||||
for (const [key, value] of Object.entries(devValues)) {
|
||||
if (!value) throw new Error(`No ${key} specified`)
|
||||
}
|
||||
for (const [key, value] of Object.entries(prodValues)) {
|
||||
if (!value) throw new Error(`No ${key} specified`)
|
||||
}
|
||||
} else {
|
||||
for (const [key, value] of Object.entries(prodValues)) {
|
||||
if (!value) throw new Error(`No ${key} specified`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default { Bot, client, redis }
|
||||
|
||||
Reference in New Issue
Block a user