3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

ormconfig: load api or bot .env, whichever exists

This commit is contained in:
Dragory 2019-07-22 00:10:27 +03:00
parent 688249cbb8
commit 51a9b2bfa5

View file

@ -1,7 +1,18 @@
require('dotenv').config(); const fs = require('fs');
const path = require('path'); const path = require('path');
try {
fs.accessSync(path.resolve(__dirname, 'bot.env'));
require('dotenv').config({ path: path.resolve(__dirname, 'bot.env') });
} catch (e) {
try {
fs.accessSync(path.resolve(__dirname, 'api.env'));
require('dotenv').config({ path: path.resolve(__dirname, 'api.env') });
} catch (e) {
throw new Error("bot.env or api.env required");
}
}
const moment = require('moment-timezone'); const moment = require('moment-timezone');
moment.tz.setDefault('UTC'); moment.tz.setDefault('UTC');