From 23bcd036c02d9f34f3e3fb32b4f4a51dfea1f587 Mon Sep 17 00:00:00 2001 From: Supositware Date: Thu, 11 Jul 2024 06:40:34 +0200 Subject: [PATCH] Remove dotenv to use `--env-file` instead --- index.js | 2 -- package-lock.json | 9 --------- package.json | 7 +++---- readme.md | 8 ++++---- scripts/deploy-commands.js | 2 -- scripts/updateBots.ggStats.js | 3 --- 6 files changed, 7 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index 82afd209..b2ad87da 100644 --- a/index.js +++ b/index.js @@ -2,8 +2,6 @@ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; import { Client, Collection, GatewayIntentBits, Partials } from 'discord.js'; -import dotenv from 'dotenv'; -dotenv.config(); const { token, NODE_ENV } = process.env; const __filename = fileURLToPath(import.meta.url); diff --git a/package-lock.json b/package-lock.json index 4893d828..64825407 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "@discordjs/rest": "^2.3.0", "discord-api-types": "^0.37.91", "discord.js": "^14.15.3", - "dotenv": "^16.0.1", "mariadb": "^3.3.1", "node-fetch": "^3.3.2", "sequelize": "^6.37.3", @@ -1559,14 +1558,6 @@ "node": ">=6.0.0" } }, - "node_modules/dotenv": { - "version": "16.0.3", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", - "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", - "engines": { - "node": ">=12" - } - }, "node_modules/dottie": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.6.tgz", diff --git a/package.json b/package.json index 4bd0c9eb..8bd0faa9 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ "description": "", "main": "index.js", "scripts": { - "start": "node .", - "deploy": "node scripts/deploy-commands.js", - "deployGlobally": "node scripts/deploy-commands.js global", + "start": "node --env-file .env .", + "deploy": "node --env-file .env scripts/deploy-commands.js", + "deployGlobally": "node --env-file .env scripts/deploy-commands.js global", "lint": "eslint .", "lintfix": "eslint . --fix", "test": "echo \"Error: no test specified\" && exit 1" @@ -20,7 +20,6 @@ "@discordjs/rest": "^2.3.0", "discord-api-types": "^0.37.91", "discord.js": "^14.15.3", - "dotenv": "^16.0.1", "mariadb": "^3.3.1", "node-fetch": "^3.3.2", "sequelize": "^6.37.3", diff --git a/readme.md b/readme.md index f3b80982..fad6a795 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,7 @@ These instructions will get you a copy of the project up and running on your loc You need to install the following -* ffmpeg (Optional but very recommanded: for yt-dlp to merge video/audio formats and Handbrake to compress videos.) +* ffmpeg & ffprobe (Optional but very recommanded: for yt-dlp to merge video/audio formats and Handbrake to compress videos.) * yt-dlp ([a file can download it for you](scripts/updateytdlp.js)) * HandBrakeCLI (For [download](commands/utility/download.js)) * gifsicle (For [vid2gif](commands/utility/vid2gif.js)) @@ -27,10 +27,10 @@ npm install ``` To run the bot for the first time you need to execute [deploy-commands.js](scripts/deploy-commands.js) so the commands can be registered, don't forget to set your .env accordingly. -``node scripts/deploy-commands.cjs`` +``node --env-file .env scripts/deploy-commands.cjs`` then you can just run it normally. -``node index.js`` +``node --env-file .env index.js`` If you want to run the bot automatically you can use pm2 ``` @@ -38,7 +38,7 @@ npm install -g pm2 pm2 start index.js --name (insert name) ``` If you are on linux and don't need automatic restart on crash you can just do -``nohup node index.js &`` +``nohup node --env-file .env index.js &`` ## Built With diff --git a/scripts/deploy-commands.js b/scripts/deploy-commands.js index e01d8b6f..e4e1ad94 100644 --- a/scripts/deploy-commands.js +++ b/scripts/deploy-commands.js @@ -3,8 +3,6 @@ import { Routes } from 'discord-api-types/v9'; import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; -import dotenv from 'dotenv'; -dotenv.config(); const { clientId, guildId, token } = process.env; const __filename = fileURLToPath(import.meta.url); diff --git a/scripts/updateBots.ggStats.js b/scripts/updateBots.ggStats.js index b2455dda..6b0f7225 100644 --- a/scripts/updateBots.ggStats.js +++ b/scripts/updateBots.ggStats.js @@ -1,9 +1,6 @@ -import dotenv from 'dotenv'; import fetch from 'node-fetch'; import { Client, GatewayIntentBits } from 'discord.js'; - -dotenv.config(); const { botsggToken, botsggEndpoint, token } = process.env; const client = new Client({