-
Notifications
You must be signed in to change notification settings - Fork 59
/
covid.js
57 lines (50 loc) · 1.95 KB
/
covid.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const {
MessageEmbed
} = require('discord.js')
const axios = require('axios');
const colors = require("../lib/colors.json");
const countries = require('../lib/countries.json');
exports.run = async (client, message, args, level) => { // eslint-disable-line no-unused-vars
const language = client.getSettings(message.guild.id).language
const lang = require("../lib/languages/" + language + ".json")
try {
const url = 'https://api.covid19api.com/total/country/';
if (args.length === 0) {
message.reply(lang.NoArgumentSpecified)
} else if (!countries[args[0]]) {
message.reply(lang.InvalidArgument)
} else {
const slug = args[0]
const payload = await axios.get(`${url}${slug}`)
const covidData = payload.data.pop();
const country = args[0].charAt(0).toUpperCase() + args[0].substr(1).toLowerCase()
let embed = new MessageEmbed()
.setAuthor(`${lang.CovidStatisticsFor} ${country}`)
.setColor(colors.default)
.addField(lang.Confirmed, `${covidData.Confirmed}`, true)
.addField(lang.Deaths, `${covidData.Deaths}`, true)
.addField(lang.Recovered, `${covidData.Recovered}`, true)
.addField(lang.Active, `${covidData.Active}`, true)
.setFooter(`${lang.RespondingTo} ${message.author.tag}`, message.author.avatarURL())
.setTimestamp()
message.channel.send({
embeds: [embed]
})
}
} catch (err) {
const errors = require('../modules/errors.js')
errors.embedError(err, lang, message)
}
}
exports.conf = {
enabled: true,
aliases: ['corona', 'coronavirus', 'cv'],
guildOnly: false,
permLevel: 'User'
}
exports.help = {
name: 'covid',
category: 'Utility',
description: 'Shows COVID-19 statistics for a given country.',
usage: 'covid <country>'
}