Country Command

This commit is contained in:
Dragon Fire
2020-03-27 12:11:37 -04:00
parent a3bb2db893
commit ce3aae2840
3 changed files with 59 additions and 2 deletions
+4 -1
View File
@@ -120,7 +120,7 @@ don't grant that permission.
## Commands
Total: 380
Total: 381
### Utility:
@@ -273,6 +273,7 @@ Total: 380
* **bulbapedia:** Searches Bulbapedia for your query.
* **character:** Searches AniList for your query, getting character results.
* **company:** Responds with the name and logo of a company.
* **country:** Responds with information on a country.
* **danbooru:** Responds with an image from Danbooru, with optional query. (NSFW)
* **define:** Defines a word.
* **derpibooru:** Responds with an image from Derpibooru.
@@ -959,6 +960,8 @@ here.
* subreddit ([API](https://www.reddit.com/dev/api/))
- [Redeeming God](https://redeeminggod.com/)
* approved ([Image](https://redeeminggod.com/courses/gospel-dictionary/lessons/gospel-dictionary-approved/))
- [Rest Countries](https://restcountries.eu/)
* country (API)
- [Right Stuf Anime](https://www.rightstufanime.com/)
* right-stuf (API)
- [Riot Games](https://www.riotgames.com/en)
+54
View File
@@ -0,0 +1,54 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const request = require('node-superfetch');
const { formatNumber } = require('../../util/Util');
module.exports = class CountryCommand extends Command {
constructor(client) {
super(client, {
name: 'country',
group: 'search',
memberName: 'country',
description: 'Responds with information on a country.',
clientPermissions: ['EMBED_LINKS'],
credit: [
{
name: 'Rest Countries',
url: 'https://restcountries.eu/',
reason: 'API'
}
],
args: [
{
key: 'query',
prompt: 'What country would you like to search for?',
type: 'string',
parse: query => encodeURIComponent(query)
}
]
});
}
async run(msg, { query }) {
try {
const { body } = await request.get(`https://restcountries.eu/rest/v2/name/${query}`);
const data = body[0];
const embed = new MessageEmbed()
.setColor(0x00AE86)
.setTitle(data.name)
.setThumbnail(`https://www.countryflags.io/${data.alpha2Code}/flat/64.png`)
.addField(' Population', formatNumber(data.population))
.addField(' Capital', data.capital, true)
.addField(' Currency', data.currencies[0].symbol, true)
.addField(' Location', data.subregion || data.region, true)
.addField(' Demonym', data.demonym, true)
.addField(' Native Name', data.nativeName, true)
.addField(' Area', `${formatNumber(data.area)}km`, true)
.addField(' Languages', data.languages.map(lang => lang.name).join('/'));
return msg.embed(embed);
} catch (err) {
if (err.status === 404) return msg.say('Could not find any results.');
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "112.17.1",
"version": "112.18.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {