mirror of
https://github.com/utmapp/BluBot.git
synced 2026-12-01 07:53:17 -10:00
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
const { resolveColor } = require('discord.js')
|
|
const fs = require('fs')
|
|
|
|
function checkConfig() {
|
|
if (!fs.existsSync('./config.json')) {
|
|
console.log("Looks like you haven't set up the bot yet! Please run 'npm run setup' and try again.")
|
|
process.exit()
|
|
}
|
|
try {
|
|
JSON.parse(fs.readFileSync('./config.json'))
|
|
} catch {
|
|
console.log("Looks like your config file has been corrupted. Please regenerate it with 'npm run setup' and try again.")
|
|
process.exit()
|
|
}
|
|
}
|
|
|
|
function getConfig() {
|
|
checkConfig()
|
|
return JSON.parse(fs.readFileSync('./config.json'))
|
|
}
|
|
|
|
module.exports = {
|
|
check: checkConfig,
|
|
getColor: color => {
|
|
checkConfig()
|
|
const { customization } = getConfig()
|
|
const colors = {
|
|
accent: customization.accent || '#0000FF',
|
|
good: customization.good || '#36c84b',
|
|
medium: customization.medium || '#fdbc40',
|
|
bad: customization.bad || '#f45450'
|
|
}
|
|
const found = colors[color]
|
|
if (!found) return null
|
|
return resolveColor(found)
|
|
},
|
|
get: getConfig
|
|
}
|