mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 22:44:32 +02:00
stuff
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const math = require('mathjs');
|
||||
|
||||
module.exports = class MathCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'math',
|
||||
aliases: ['calculator', 'calc'],
|
||||
group: 'number-edit',
|
||||
memberName: 'math',
|
||||
description: 'Evaluates a math expression.',
|
||||
args: [
|
||||
{
|
||||
key: 'expression',
|
||||
prompt: 'What expression would you like to evaluate?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { expression }) {
|
||||
try {
|
||||
const answer = math.eval(expression).toString();
|
||||
return msg.say(answer).catch(() => msg.reply('Invalid expression.'));
|
||||
} catch (err) {
|
||||
return msg.reply('Invalid expression.');
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { MASHAPE_KEY } = process.env;
|
||||
|
||||
module.exports = class GenderGuessCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -16,7 +15,7 @@ module.exports = class GenderGuessCommand extends Command {
|
||||
prompt: 'What name do you want to determine the gender of?',
|
||||
type: 'string',
|
||||
max: 1950,
|
||||
parse: name => name.toLowerCase()
|
||||
parse: name => encodeURIComponent(name)
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -24,13 +23,9 @@ module.exports = class GenderGuessCommand extends Command {
|
||||
|
||||
async run(msg, { name }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://udayogra-find-gender-by-name-v1.p.mashape.com/analysis')
|
||||
.query({ firstname: name })
|
||||
.set({ 'X-Mashape-Key': MASHAPE_KEY });
|
||||
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.`);
|
||||
const { body } = await snekfetch.get(`https://api.namsor.com/onomastics/api/json/gender/${name}/null`);
|
||||
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!`);
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { WORDNIK_KEY } = process.env;
|
||||
|
||||
module.exports = class ReverseDictionaryCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'reverse-dictionary',
|
||||
aliases: ['reverse-define', 'wordnik-reverse-define', 'wordnik-reverse-dictionary'],
|
||||
group: 'search',
|
||||
memberName: 'reverse-dictionary',
|
||||
description: 'Responds with the closest word for a given definition.',
|
||||
args: [
|
||||
{
|
||||
key: 'definition',
|
||||
prompt: 'What definition would you like to look up?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { definition }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://api.wordnik.com/v4/words.json/reverseDictionary')
|
||||
.query({
|
||||
query: definition,
|
||||
limit: 1,
|
||||
api_key: WORDNIK_KEY
|
||||
});
|
||||
if (!body.results) return msg.say('Could not find any results.');
|
||||
const data = body.results[0];
|
||||
return msg.say(stripIndents`
|
||||
**${data.word}**
|
||||
${data.text}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -37,7 +37,6 @@
|
||||
"discord.js": "github:hydrabolt/discord.js",
|
||||
"discord.js-commando": "github:gawdl3y/discord.js-commando",
|
||||
"erlpack": "github:discordapp/erlpack",
|
||||
"mathjs": "^3.16.5",
|
||||
"node-opus": "^0.2.7",
|
||||
"snekfetch": "^3.5.8",
|
||||
"uws": "^8.14.1",
|
||||
|
||||
Reference in New Issue
Block a user