mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 13:56:25 +02:00
Fix
This commit is contained in:
@@ -22,8 +22,7 @@ module.exports = class CountryCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'query',
|
key: 'query',
|
||||||
prompt: 'What country would you like to search for?',
|
prompt: 'What country would you like to search for?',
|
||||||
type: 'string',
|
type: 'string'
|
||||||
parse: query => encodeURIComponent(query)
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -31,7 +30,7 @@ module.exports = class CountryCommand extends Command {
|
|||||||
|
|
||||||
async run(msg, { query }) {
|
async run(msg, { query }) {
|
||||||
try {
|
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 => {
|
const data = body.find(country => {
|
||||||
return country.name.toLowerCase() === query.toLowerCase()
|
return country.name.toLowerCase() === query.toLowerCase()
|
||||||
|| country.altSpellings.some(alt => alt.toLowerCase() === query.toLowerCase())
|
|| country.altSpellings.some(alt => alt.toLowerCase() === query.toLowerCase())
|
||||||
|
|||||||
Reference in New Issue
Block a user