mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 14:19:56 +02:00
This API sucks but at least it's free
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
|
const { MASHAPE_KEY } = process.env;
|
||||||
|
|
||||||
module.exports = class GenderGuessCommand extends Command {
|
module.exports = class GenderGuessCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -13,7 +14,8 @@ module.exports = class GenderGuessCommand extends Command {
|
|||||||
{
|
{
|
||||||
key: 'name',
|
key: 'name',
|
||||||
prompt: 'What name do you want to determine the gender of?',
|
prompt: 'What name do you want to determine the gender of?',
|
||||||
type: 'string'
|
type: 'string',
|
||||||
|
parse: name => name.toLowerCase()
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -22,10 +24,12 @@ module.exports = class GenderGuessCommand extends Command {
|
|||||||
async run(msg, { name }) {
|
async run(msg, { name }) {
|
||||||
try {
|
try {
|
||||||
const { body } = await snekfetch
|
const { body } = await snekfetch
|
||||||
.get('https://api.genderize.io/')
|
.get('https://udayogra-find-gender-by-name-v1.p.mashape.com/analysis')
|
||||||
.query({ name });
|
.query({ firstname: name })
|
||||||
if (!body.gender) return msg.say(`I have no idea what gender ${body.name} is.`);
|
.set({ 'X-Mashape-Key': MASHAPE_KEY });
|
||||||
return msg.say(`I'm ${Math.round(body.probability * 100)}% sure ${body.name} is a ${body.gender} name.`);
|
if (!body.male || !body.female) return msg.say(`I have no idea what gender ${body.name} is.`);
|
||||||
|
const gender = body.male > body.female ? 'male' : 'female';
|
||||||
|
return msg.say(`I'm ${body[gender]}% sure ${body.name} is a ${gender} name.`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "45.0.5",
|
"version": "45.0.6",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user