This commit is contained in:
Dragon Fire
2021-01-17 23:32:59 -05:00
parent 181a1d1dca
commit 9bedfcd03a
+2 -3
View File
@@ -22,8 +22,7 @@ module.exports = class CountryCommand extends Command {
{
key: 'query',
prompt: 'What country would you like to search for?',
type: 'string',
parse: query => encodeURIComponent(query)
type: 'string'
}
]
});
@@ -31,7 +30,7 @@ module.exports = class CountryCommand extends Command {
async run(msg, { query }) {
try {
const { body } = await request.get(`https://restcountries.eu/rest/v2/name/${query}`);
const { body } = await request.get(`https://restcountries.eu/rest/v2/name/${encodeURIComponent(query)}`);
const data = body.find(country => {
return country.name.toLowerCase() === query.toLowerCase()
|| country.altSpellings.some(alt => alt.toLowerCase() === query.toLowerCase())