From 14d8d13850be75c343e2d31cbd621b83aae81a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Ka=C5=88ka?= Date: Sun, 6 Sep 2020 22:03:40 +0200 Subject: [PATCH] VERSION 1.6 PRODUCTION CHANGELOG: - Day statistics are created from two days. - Chalk deleted --- .gitignore | 3 ++- Dockerfile | 1 - apireq.js | 4 ++-- config.json | 2 +- index.js | 17 +++++++---------- package.json | 6 ++++-- webserver.js | 3 +-- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 25c8fdb..4ef2e98 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -package-lock.json \ No newline at end of file +package-lock.json +.eslintrc.json \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index af22456..80bf023 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,6 @@ RUN apt-get update RUN npm install discord.js RUN npm install axios -RUN npm install chalk RUN npm install is-reachable RUN npm install express diff --git a/apireq.js b/apireq.js index 8e11e0b..ca075cb 100644 --- a/apireq.js +++ b/apireq.js @@ -1,5 +1,5 @@ const axios = require('axios'); -const { APILink, APILinkWorld } = require('./config.json'); +const { APILink } = require('./config.json'); const isReachable = require('is-reachable'); async function checkIfRightCountry(countryName) { @@ -11,7 +11,7 @@ async function checkIfRightCountry(countryName) { } async function getDataOfCountry(countryName) { - const data = axios.get(`${APILink}v2/countries/${countryName}`) + const data = axios.get(`${APILink}v2/countries/${countryName}?yesterday=1`) .then(res => res.data) .catch(err => err) return data diff --git a/config.json b/config.json index 643377e..845a163 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "prefix": ".corona", "token": "", - "version": "1.5 PRODUCTION", + "version": "1.6 PRODUCTION", "inviteLink": "https://jkanka.cz/invite", "APILink": "https://corona.lmao.ninja/", "embedColor": "#FF6347", diff --git a/index.js b/index.js index 6cbf854..cd64051 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,6 @@ const Discord = require('discord.js'); const client = new Discord.Client(); const os = require('os'); const { prefix, token, version, inviteLink, embedColor, coronaLogo } = require('./config.json'); -const chalk = require('chalk'); const apireq = require('./apireq'); const webserver = require('./webserver'); const dFormat = require('./data_formatting'); @@ -16,20 +15,19 @@ console.clear() client.once('ready', async () => { // Prints basic info about server and status - console.log(chalk.green.bold('[INFO]') + ' Bot is online! Bot version: ' + version) - console.log(chalk.green.bold('[INFO]') + ' Server is running on ' + systemName + ', Node.js version: ' + nodeVersion) - console.log(chalk.green.bold('[INFO]') + ' Total RAM on server: ' + systemRam) - console.log(chalk.green.bold('[INFO]') + ' Name: ' + client.user.username) - console.log(chalk.green.bold('[INFO]') + ' ID: ' + client.user.id) + console.log(`Bot is online! Bot version: ${version}`) + console.log(`Server is running on ${systemName}, Node.js version: ${nodeVersion}`) + console.log(`Total RAM on server: ${systemRam}`) + console.log(`Name: ${client.user.username}`) + console.log(`ID: ${client.user.id}`) // Start a webserver for online control webserver.startWebServer() // Checks if APIs works. If not stop bot. const apiStatus = await apireq.getAPIStatus() if (apiStatus === "API DOWN!") { - console.log(chalk.red.bold('[CRITICAL ERROR]') + ' API DOES NOT WORK.') - process.exit(1) + console.log('API DOES NOT WORK.') } else { - console.log(chalk.green.bold('[INFO]') + ' API works so bot can serve requests now.') + console.log('API works so bot can serve requests now.') } // Print Rich Presence client.user.setActivity('.corona help', { type: 'PLAYING' }) @@ -111,7 +109,6 @@ client.on('message', async message => { return message.channel.send(inviteEmbed) } else if (command === 'info') { - const data = await apireq.getDataOfWorld() const authorAvatarURL = message.author.avatarURL() const infoEmbed = new Discord.MessageEmbed() .setColor(embedColor) diff --git a/package.json b/package.json index 22a15f6..635c35a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coronabotjs", - "version": "1.5.0", + "version": "1.6.0", "description": "[![Discord Bots](https://top.gg/api/widget/status/692525015668621321.svg)](https://top.gg/bot/692525015668621321)", "main": "index.js", "scripts": { @@ -18,10 +18,12 @@ "homepage": "https://github.com/kankajm/CoronaDiscordBotJS#readme", "dependencies": { "axios": "^0.19.2", - "chalk": "^4.1.0", "delay": "^4.4.0", "discord.js": "^12.3.1", "express": "^4.17.1", "is-reachable": "^4.0.0" + }, + "devDependencies": { + "eslint": "^7.8.1" } } diff --git a/webserver.js b/webserver.js index 1986fcb..6228903 100644 --- a/webserver.js +++ b/webserver.js @@ -1,5 +1,4 @@ const express = require('express'); -const chalk = require('chalk'); function startWebServer() { const app = express(); @@ -10,7 +9,7 @@ function startWebServer() { "node_version": process.version}); }); const port = 5001; - app.listen(port, () => console.log(chalk.green.bold('[INFO]') + ' ONLINE CONTROL IS RUNNING ON PORT: ' + port)); + app.listen(port, () => console.log(`ONLINE CONTROL IS RUNNING ON PORT: ${port}`)); } module.exports = { startWebServer } \ No newline at end of file