mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
44 lines
1010 B
JavaScript
44 lines
1010 B
JavaScript
const Command = require('../../framework/Command');
|
|
const request = require('node-superfetch');
|
|
const genders = ['male', 'female', 'both'];
|
|
|
|
module.exports = class NameCommand extends Command {
|
|
constructor(client) {
|
|
super(client, {
|
|
name: 'name',
|
|
group: 'random-res',
|
|
description: 'Responds with a random name, with the gender of your choice.',
|
|
credit: [
|
|
{
|
|
name: 'Random User Generator',
|
|
url: 'https://randomuser.me/',
|
|
reason: 'API',
|
|
reasonURL: 'https://randomuser.me/documentation'
|
|
}
|
|
],
|
|
args: [
|
|
{
|
|
key: 'gender',
|
|
type: 'string',
|
|
default: 'both',
|
|
oneOf: genders,
|
|
parse: gender => gender.toLowerCase()
|
|
}
|
|
]
|
|
});
|
|
}
|
|
|
|
async run(msg, { gender }) {
|
|
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}`);
|
|
}
|
|
};
|