Remove dotenv to use --env-file instead

This commit is contained in:
Supositware 2024-07-11 06:40:34 +02:00
parent 34ab603462
commit 23bcd036c0
6 changed files with 7 additions and 24 deletions

View file

@ -2,8 +2,6 @@ import fs from 'node:fs';
import path from 'node:path'; import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url'; import { fileURLToPath, pathToFileURL } from 'node:url';
import { Client, Collection, GatewayIntentBits, Partials } from 'discord.js'; import { Client, Collection, GatewayIntentBits, Partials } from 'discord.js';
import dotenv from 'dotenv';
dotenv.config();
const { token, NODE_ENV } = process.env; const { token, NODE_ENV } = process.env;
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);

9
package-lock.json generated
View file

@ -12,7 +12,6 @@
"@discordjs/rest": "^2.3.0", "@discordjs/rest": "^2.3.0",
"discord-api-types": "^0.37.91", "discord-api-types": "^0.37.91",
"discord.js": "^14.15.3", "discord.js": "^14.15.3",
"dotenv": "^16.0.1",
"mariadb": "^3.3.1", "mariadb": "^3.3.1",
"node-fetch": "^3.3.2", "node-fetch": "^3.3.2",
"sequelize": "^6.37.3", "sequelize": "^6.37.3",
@ -1559,14 +1558,6 @@
"node": ">=6.0.0" "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": { "node_modules/dottie": {
"version": "2.0.6", "version": "2.0.6",
"resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.6.tgz", "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.6.tgz",

View file

@ -4,9 +4,9 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node .", "start": "node --env-file .env .",
"deploy": "node scripts/deploy-commands.js", "deploy": "node --env-file .env scripts/deploy-commands.js",
"deployGlobally": "node scripts/deploy-commands.js global", "deployGlobally": "node --env-file .env scripts/deploy-commands.js global",
"lint": "eslint .", "lint": "eslint .",
"lintfix": "eslint . --fix", "lintfix": "eslint . --fix",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
@ -20,7 +20,6 @@
"@discordjs/rest": "^2.3.0", "@discordjs/rest": "^2.3.0",
"discord-api-types": "^0.37.91", "discord-api-types": "^0.37.91",
"discord.js": "^14.15.3", "discord.js": "^14.15.3",
"dotenv": "^16.0.1",
"mariadb": "^3.3.1", "mariadb": "^3.3.1",
"node-fetch": "^3.3.2", "node-fetch": "^3.3.2",
"sequelize": "^6.37.3", "sequelize": "^6.37.3",

View file

@ -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 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)) * yt-dlp ([a file can download it for you](scripts/updateytdlp.js))
* HandBrakeCLI (For [download](commands/utility/download.js)) * HandBrakeCLI (For [download](commands/utility/download.js))
* gifsicle (For [vid2gif](commands/utility/vid2gif.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. 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. 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 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) pm2 start index.js --name (insert name)
``` ```
If you are on linux and don't need automatic restart on crash you can just do 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 ## Built With

View file

@ -3,8 +3,6 @@ import { Routes } from 'discord-api-types/v9';
import fs from 'node:fs'; import fs from 'node:fs';
import path from 'node:path'; import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url'; import { fileURLToPath, pathToFileURL } from 'node:url';
import dotenv from 'dotenv';
dotenv.config();
const { clientId, guildId, token } = process.env; const { clientId, guildId, token } = process.env;
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);

View file

@ -1,9 +1,6 @@
import dotenv from 'dotenv';
import fetch from 'node-fetch'; import fetch from 'node-fetch';
import { Client, GatewayIntentBits } from 'discord.js'; import { Client, GatewayIntentBits } from 'discord.js';
dotenv.config();
const { botsggToken, botsggEndpoint, token } = process.env; const { botsggToken, botsggEndpoint, token } = process.env;
const client = new Client({ const client = new Client({