Skip to content

Commit

Permalink
VERSION 1.6 PRODUCTION
Browse files Browse the repository at this point in the history
CHANGELOG:
 - Day statistics are created from two days.
 - Chalk deleted
  • Loading branch information
Jaroslav Kaňka committed Sep 6, 2020
1 parent 8e8c2c6 commit 14d8d13
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
package-lock.json
package-lock.json
.eslintrc.json
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions apireq.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
17 changes: 7 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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' })
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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"
}
}
3 changes: 1 addition & 2 deletions webserver.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const express = require('express');
const chalk = require('chalk');

function startWebServer() {
const app = express();
Expand All @@ -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 }

0 comments on commit 14d8d13

Please sign in to comment.