From 2c3f17a2ded4229e2a6d3ae67772fe978a41b71b Mon Sep 17 00:00:00 2001 From: Taken Date: Mon, 11 Sep 2023 19:18:28 +0200 Subject: [PATCH] Updating env management --- .env.example | 2 +- index.js | 9 ++++++++- nodemon.json | 12 ++++++++++++ package.json | 6 ++++-- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 nodemon.json diff --git a/.env.example b/.env.example index e8bb7de..2be76a1 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ PRODTOKEN= -TOKEN= +DEVTOKEN= MONGOURI= DEV= CLIENTID= diff --git a/index.js b/index.js index bac4e2a..4d13240 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,19 @@ const { Client, GatewayIntentBits, Partials, ActivityType, Events, Collection } = require('discord.js'); const { botLogChannel, color } = require('./config/options.json'); const env = require('dotenv').config(); -const token = process.env.TOKEN; const mongoURI = process.env.MONGOURI; const { connect } = require('mongoose'); const path = require('path'); const fs = require('fs'); +if (process.env.NODE_ENV === 'dev') { + console.log("Running in development mode."); + var token = process.env.DEVTOKEN; +} else { + console.log("Running in production mode."); + var token = process.env.PRODTOKEN; +} + const client = new Client({ intents: [ GatewayIntentBits.Guilds, diff --git a/nodemon.json b/nodemon.json new file mode 100644 index 0000000..97af0f1 --- /dev/null +++ b/nodemon.json @@ -0,0 +1,12 @@ +{ + "restartable": "rs", + "ignore": [ + ".git", + "node_modules/**/node_modules" + ], + "verbose": true, + "env": { + "NODE_ENV": "dev" + }, + "ext": "js,json" +} diff --git a/package.json b/package.json index ec2c080..a0f19f1 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,10 @@ "description": "", "main": "index.js", "scripts": { - "prod:build": "node scripts/deploy-commands.js --prod", - "dev:build": "node scripts/deploy-commands.js --dev" + "dev": "nodemon", + "dev:build": "node scripts/dev-deploy.js" + "prod:build:global": "node scripts/deploy-commands.js --prod", + "prod:build:user": "node scripts/deploy-commands.js --dev" }, "author": "Taken", "license": "ISC",