From 83dcca0a0279ce6415a3e9d153c13d91284369b0 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 14 Oct 2023 10:38:46 -0400 Subject: Removed tokens.json now using environment vars; Modified dockerfile --- .dockerignore | 2 ++ .gitignore | 1 + Dockerfile | 2 -- bot_discord.js | 10 +++++----- commands/info.js | 2 -- package.json | 1 + yarn.lock | 5 +++++ 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3bfcb92..550aa8a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,5 @@ node_modules npm-debug.log .git +.env +database.sqlite diff --git a/.gitignore b/.gitignore index e773a52..541fcd0 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ ffprobe.exe json.sqlite package-lock.json database.sqlite +.env diff --git a/Dockerfile b/Dockerfile index 1256d22..f962f11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,6 @@ WORKDIR /usr/src/bot COPY package.json ./ -COPY tokens.json ./ - COPY yarn.lock ./ RUN yarn install diff --git a/bot_discord.js b/bot_discord.js index 0c09bfb..df2264f 100644 --- a/bot_discord.js +++ b/bot_discord.js @@ -17,6 +17,7 @@ * along with this program. If not, see . * * *************************************/ +require('dotenv').config() const Discord = require('discord.js'); const client = new Discord.Client({ allowedMentions: { @@ -33,7 +34,6 @@ const colors = require('colors'); //const i18next = require('i18next'); const web = express(); const settings = require('./storage/settings.json'); -const api = require('./tokens.json'); const { activity } = require('./storage/activities'); const active = new Map(); let autoRole = true; @@ -83,12 +83,12 @@ if (process.argv.indexOf('--debug') === -1) { } if (process.argv.indexOf('--beta') === -1) { - client.login(api.abtoken).catch(function() { + client.login(process.env.abtoken).catch(function() { console.log('[X] Login failed. The token that you put in is invalid, please put in a new one...'.red); process.exit(0); }); } else { - client.login(api.abbtoken).catch(function() { + client.login(process.env.abbtoken).catch(function() { console.log('[X] Login failed. The token that you put in is invalid, please put in a new one...'.red); process.exit(0); }); @@ -223,8 +223,8 @@ client.on('ready', async () => { res.send("Hello World! This is going to become the AleeBot dashboard..."); }); - web.listen(api.port, () => { - console.log(`Listening at https://localhost:${api.port}`) + web.listen(process.env.port, () => { + console.log(`Listening at https://localhost:${process.env.port}`) }) setInterval(function() { diff --git a/commands/info.js b/commands/info.js index 95eaebb..a74d73e 100644 --- a/commands/info.js +++ b/commands/info.js @@ -20,7 +20,6 @@ module.exports.run = async (client, message) => { const { MessageEmbed, version } = require('discord.js'); const os = require('os'); - const mongoose = require('mongoose'); const embed = new MessageEmbed() .setTitle('Information on AleeBot\'s Host') .addField('OS Hostname: ', os.hostname(), true) @@ -28,7 +27,6 @@ module.exports.run = async (client, message) => { .addField('Discord.JS Version: ', version, true) .addField('OS Platform: ', os.platform(), true) .addField('OS Version: ', os.release(), true) - .addField('Mongoose Version:', mongoose.version, true) .setColor('#1fd619'); await message.channel.send({ embeds: [embed] }); }; diff --git a/package.json b/package.json index 9a4f3c0..6e07caa 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "blessed": "^0.1.81", "colors": "^1.3.0", "discord.js": "^13.0.1", + "dotenv": "^16.3.1", "eslint": "^7.1.0", "express": "^4.17.1", "i18next": "^19.4.4", diff --git a/yarn.lock b/yarn.lock index e110dc7..5942f18 100644 --- a/yarn.lock +++ b/yarn.lock @@ -605,6 +605,11 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" +dotenv@^16.3.1: + version "16.3.1" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e" + integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ== + dottie@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/dottie/-/dottie-2.0.3.tgz#797a4f4c92a9a65499806be4051b9d9dcd5a5d77" -- cgit v1.2.3