Face Analyze, Analyze group

This commit is contained in:
Daniel Odendahl Jr
2018-03-08 22:49:19 +00:00
parent 35f4bd0bbe
commit 10e9fc0c02
18 changed files with 88 additions and 21 deletions
-34
View File
@@ -1,34 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class CoolnessCommand extends Command {
constructor(client) {
super(client, {
name: 'coolness',
group: 'other',
memberName: 'coolness',
description: 'Determines a user\'s coolness.',
args: [
{
key: 'user',
prompt: 'Which user do you want to determine the coolness of?',
type: 'user',
default: msg => msg.author
}
]
});
}
run(msg, { user }) {
const coolness = user.id / this.client.user.id;
if (coolness < 0.2) return msg.say(`${user.username} is the coolest being to walk this Earth.`);
if (coolness < 0.4) return msg.say(`${user.username} is extremely amazingly amazing.`);
if (coolness < 0.6) return msg.say(`${user.username} is as cool as ice.`);
if (coolness < 0.8) return msg.say(`${user.username} is an extremely cool dude.`);
if (coolness < 1) return msg.say(`${user.username} is pretty sweet, not gonna lie.`);
if (coolness < 1.2) return msg.say(`${user.username} is okay, nothing special.`);
if (coolness < 1.4) return msg.say(`${user.username} is just not all that neat.`);
if (coolness < 1.6) return msg.say(`${user.username} is awful, honestly.`);
if (coolness < 1.8) return msg.say(`${user.username} smells like a sack of diapers.`);
return msg.say(`${user.username} is terrible in every way.`);
}
};
-43
View File
@@ -1,43 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
module.exports = class GenderGuessCommand extends Command {
constructor(client) {
super(client, {
name: 'gender-guess',
aliases: ['gender', 'guess-gender'],
group: 'other',
memberName: 'gender',
description: 'Determines the gender of a name.',
args: [
{
key: 'first',
label: 'first name',
prompt: 'What first name do you want to determine the gender of?',
type: 'string',
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, { first, last }) {
try {
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) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-41
View File
@@ -1,41 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const { GOOGLE_KEY } = process.env;
module.exports = class SevereToxicityCommand extends Command {
constructor(client) {
super(client, {
name: 'severe-toxicity',
aliases: ['severe-perspective', 'severe-comment-toxicity'],
group: 'other',
memberName: 'severe-toxicity',
description: 'Determines the toxicity of text, but less sensitive to milder language.',
args: [
{
key: 'text',
prompt: 'What text do you want to test the toxicity of?',
type: 'string'
}
]
});
}
async run(msg, { text }) {
try {
const { body } = await snekfetch
.post('https://commentanalyzer.googleapis.com/v1alpha1/comments:analyze')
.query({ key: GOOGLE_KEY })
.send({
comment: { text },
languages: ['en'],
requestedAttributes: { SEVERE_TOXICITY: {} }
});
const toxicity = Math.round(body.attributeScores.SEVERE_TOXICITY.summaryScore.value * 100);
if (toxicity >= 70) return msg.say(`Likely to be perceived as toxic. (${toxicity}%)`);
if (toxicity >= 40) return msg.say(`Unsure if this will be perceived as toxic. (${toxicity}%)`);
return msg.say(`Unlikely to be perceived as toxic. (${toxicity}%)`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
-41
View File
@@ -1,41 +0,0 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const { GOOGLE_KEY } = process.env;
module.exports = class ToxicityCommand extends Command {
constructor(client) {
super(client, {
name: 'toxicity',
aliases: ['perspective', 'comment-toxicity'],
group: 'other',
memberName: 'toxicity',
description: 'Determines the toxicity of text.',
args: [
{
key: 'text',
prompt: 'What text do you want to test the toxicity of?',
type: 'string'
}
]
});
}
async run(msg, { text }) {
try {
const { body } = await snekfetch
.post('https://commentanalyzer.googleapis.com/v1alpha1/comments:analyze')
.query({ key: GOOGLE_KEY })
.send({
comment: { text },
languages: ['en'],
requestedAttributes: { TOXICITY: {} }
});
const toxicity = Math.round(body.attributeScores.TOXICITY.summaryScore.value * 100);
if (toxicity >= 70) return msg.say(`Likely to be perceived as toxic. (${toxicity}%)`);
if (toxicity >= 40) return msg.say(`Unsure if this will be perceived as toxic. (${toxicity}%)`);
return msg.say(`Unlikely to be perceived as toxic. (${toxicity}%)`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};