Last name

This commit is contained in:
Daniel Odendahl Jr
2017-11-14 21:59:51 +00:00
parent 68bed9552c
commit 3531795653
+16 -6
View File
@@ -11,19 +11,29 @@ module.exports = class GenderGuessCommand extends Command {
description: 'Determines the gender of name.',
args: [
{
key: 'name',
prompt: 'What name do you want to determine the gender of?',
key: 'first',
label: 'first name',
prompt: 'What first name do you want to determine the gender of?',
type: 'string',
max: 1950,
parse: name => encodeURIComponent(name)
max: 500,
parse: first => encodeURIComponent(first)
},
{
key: 'last',
label: 'last name',
prompt: 'What last name do you want to determine the gender of?',
type: 'string',
default: 'null',
max: 500,
parse: last => encodeURIComponent(last)
}
]
});
}
async run(msg, { name }) {
async run(msg, { first, last }) {
try {
const { body } = await snekfetch.get(`https://api.namsor.com/onomastics/api/json/gender/${name}/null`);
const { body } = await snekfetch.get(`https://api.namsor.com/onomastics/api/json/gender/${first}/${last}`);
if (body.gender === 'unknown') return msg.say(`I have no idea what gender ${body.firstName} is.`);
return msg.say(`I'm ${Math.abs(body.scale * 100)}% sure ${body.firstName} is a ${body.gender} name.`);
} catch (err) {