mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +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 { 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) {
|
||||||
@@ -16,7 +15,7 @@ module.exports = class GenderGuessCommand extends Command {
|
|||||||
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',
|
||||||
max: 1950,
|
max: 1950,
|
||||||
parse: name => name.toLowerCase()
|
parse: name => encodeURIComponent(name)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -24,13 +23,9 @@ 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.namsor.com/onomastics/api/json/gender/${name}/null`);
|
||||||
.get('https://udayogra-find-gender-by-name-v1.p.mashape.com/analysis')
|
if (body.gender === 'unknown') return msg.say(`I have no idea what gender ${body.firstName} is.`);
|
||||||
.query({ firstname: name })
|
return msg.say(`I'm ${Math.abs(body.scale * 100)}% sure ${body.firstName} is a ${body.gender} 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.`);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
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": "github:hydrabolt/discord.js",
|
||||||
"discord.js-commando": "github:gawdl3y/discord.js-commando",
|
"discord.js-commando": "github:gawdl3y/discord.js-commando",
|
||||||
"erlpack": "github:discordapp/erlpack",
|
"erlpack": "github:discordapp/erlpack",
|
||||||
"mathjs": "^3.16.5",
|
|
||||||
"node-opus": "^0.2.7",
|
"node-opus": "^0.2.7",
|
||||||
"snekfetch": "^3.5.8",
|
"snekfetch": "^3.5.8",
|
||||||
"uws": "^8.14.1",
|
"uws": "^8.14.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user