mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 22:32:52 +02:00
Finish removing "Oh no, an error occurred"
This commit is contained in:
+10
-14
@@ -30,19 +30,15 @@ module.exports = class NameCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { gender }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('https://randomuser.me/api/')
|
||||
.query({
|
||||
inc: 'name',
|
||||
noinfo: '',
|
||||
gender: gender === 'both' ? '' : gender,
|
||||
nat: 'AU,US,CA,GB'
|
||||
});
|
||||
const data = body.results[0].name;
|
||||
return msg.say(`${data.first} ${data.last}`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
const { body } = await request
|
||||
.get('https://randomuser.me/api/')
|
||||
.query({
|
||||
inc: 'name',
|
||||
noinfo: '',
|
||||
gender: gender === 'both' ? '' : gender,
|
||||
nat: 'AU,US,CA,GB'
|
||||
});
|
||||
const data = body.results[0].name;
|
||||
return msg.say(`${data.first} ${data.last}`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user