This commit is contained in:
Daniel Odendahl Jr
2018-02-17 14:05:01 +00:00
parent ffa081b363
commit 0ebd66a3c9
21 changed files with 334 additions and 58 deletions
+2 -1
View File
@@ -3,7 +3,7 @@ const { createCanvas, loadImage } = require('canvas');
const snekfetch = require('snekfetch');
const path = require('path');
const { list } = require('../../util/Util');
const hats = ['christmas', 'anime', 'tophat', 'pilgrim', 'birthday'];
const hats = require('../../assets/json/hat');
module.exports = class HatCommand extends Command {
constructor(client) {
@@ -12,6 +12,7 @@ module.exports = class HatCommand extends Command {
group: 'avatar-edit',
memberName: 'hat',
description: 'Draws a hat over a user\'s avatar.',
details: `**Hats**: ${hats.join(', ')}`,
throttling: {
usages: 1,
duration: 10
+1 -1
View File
@@ -30,7 +30,7 @@ module.exports = class AkinatorCommand extends Command {
answers.push('end');
await msg.say(stripIndents`
**${++data.step}.** ${data.question}
${data.answers.map(answer => answer.answer).join(' | ')} | End
${data.answers.map(answer => answer.answer).join(' | ')}
`);
const filter = res => res.author.id === msg.author.id && answers.includes(res.content.toLowerCase());
const msgs = await msg.channel.awaitMessages(filter, {
+1 -1
View File
@@ -51,7 +51,7 @@ module.exports = class BalloonPopCommand extends Command {
}
if (pump) {
await msg.say(`${user} pumps the balloon!`);
remains -= randomRange(50, 100);
remains -= randomRange(25, 75);
const popped = Math.floor(Math.random() * remains);
if (popped <= 0) {
await msg.say('The balloon pops!');
+1
View File
@@ -19,6 +19,7 @@ module.exports = class MathQuizCommand extends Command {
group: 'games',
memberName: 'math-quiz',
description: 'See how fast you can answer a math problem in a given time limit.',
details: `**Difficulties**: ${difficulties.join(', ')}`,
args: [
{
key: 'difficulty',
+4
View File
@@ -13,6 +13,10 @@ module.exports = class QuizCommand extends Command {
group: 'games',
memberName: 'quiz',
description: 'Answer a quiz question.',
details: stripIndents`
**Types**: ${types.join(', ')}
**Difficulties**: ${difficulties.join(', ')}
`,
args: [
{
key: 'type',
+1 -2
View File
@@ -11,8 +11,7 @@ module.exports = class SortingHatQuizCommand extends Command {
aliases: ['sorting-hat', 'pottermore', 'hogwarts'],
group: 'games',
memberName: 'sorting-hat-quiz',
description: 'Take a quiz to determine your Hogwarts house.',
details: '**Source**: <https://www.reddit.com/r/Pottermore/comments/44os14/pottermore_sorting_hat_quiz_analysis/>'
description: 'Take a quiz to determine your Hogwarts house.'
});
this.playing = new Set();
+1
View File
@@ -19,6 +19,7 @@ module.exports = class TypingTestCommand extends Command {
group: 'games',
memberName: 'typing-test',
description: 'See how fast you can type a sentence in a given time limit.',
details: `**Difficulties**: ${difficulties.join(', ')}`,
args: [
{
key: 'difficulty',
+1
View File
@@ -10,6 +10,7 @@ module.exports = class TemperatureCommand extends Command {
group: 'number-edit',
memberName: 'temperature',
description: `Converts temperatures to/from ${list(units, 'or')}.`,
details: `**Units**: ${units.join(', ')}`,
args: [
{
key: 'base',
+2 -1
View File
@@ -28,6 +28,7 @@ module.exports = class CoolnessCommand extends Command {
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.`);
return msg.say(`${user.username} smells like a sack of diapers.`);
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.`);
}
};
+8 -14
View File
@@ -1,6 +1,6 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { stripIndents } = require('common-tags');
module.exports = class RedditCommand extends Command {
constructor(client) {
@@ -10,7 +10,6 @@ module.exports = class RedditCommand extends Command {
group: 'random',
memberName: 'reddit',
description: 'Responds with a random post from a subreddit.',
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'subreddit',
@@ -30,18 +29,13 @@ module.exports = class RedditCommand extends Command {
const allowed = msg.channel.nsfw ? body.data.children : body.data.children.filter(post => !post.data.over_18);
if (!allowed.length) return msg.say('Could not find any results.');
const post = allowed[Math.floor(Math.random() * allowed.length)].data;
const embed = new MessageEmbed()
.setColor(0xFF4500)
.setAuthor('Reddit', 'https://i.imgur.com/DSBOK0P.png')
.setURL(`https://www.reddit.com${post.permalink}`)
.setTitle(post.title)
.addField(' Upvotes',
post.ups, true)
.addField(' Downvotes',
post.downs, true)
.addField(' Score',
post.score, true);
return msg.embed(embed);
return msg.say(stripIndents`
**${post.title}**
<https://www.reddit.com${post.permalink}>
${post.ups}
${post.downs}
`);
} catch (err) {
if (err.status === 403) return msg.say('This subreddit is private.');
if (err.status === 404) return msg.say('Could not find any results.');
+1
View File
@@ -11,6 +11,7 @@ module.exports = class DeviantartCommand extends Command {
group: 'search',
memberName: 'deviantart',
description: 'Responds with an image from a DeviantArt section, with optional query.',
details: `**Sections**: ${sections.join(', ')}`,
args: [
{
key: 'section',
-2
View File
@@ -3,8 +3,6 @@ const { createCanvas, loadImage, registerFont } = require('canvas');
const path = require('path');
const { elements, colors } = require('../../assets/json/periodic-table');
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' });
module.exports = class PeriodicTableCommand extends Command {
constructor(client) {
+16 -3
View File
@@ -1,7 +1,8 @@
const { Command } = require('discord.js-commando');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { shorten } = require('../../util/Util');
const { shorten, list } = require('../../util/Util');
const types = ['random', 'top'];
module.exports = class UrbanDictionaryCommand extends Command {
constructor(client) {
@@ -11,24 +12,36 @@ module.exports = class UrbanDictionaryCommand extends Command {
group: 'search',
memberName: 'urban-dictionary',
description: 'Defines a word, but with Urban Dictionary.',
details: `**Types**: ${types.join(', ')}`,
clientPermissions: ['EMBED_LINKS'],
args: [
{
key: 'word',
prompt: 'What word would you like to look up?',
type: 'string'
},
{
key: 'type',
prompt: 'Do you want to get the top answer or a random one?',
type: 'string',
default: 'top',
validate: type => {
if (types.includes(type.toLowerCase())) return true;
return `Invalid type, please enter either ${list(types, 'or')}.`;
},
parse: type => type.toLowerCase()
}
]
});
}
async run(msg, { word }) {
async run(msg, { word, type }) {
try {
const { body } = await snekfetch
.get('http://api.urbandictionary.com/v0/define')
.query({ term: word });
if (!body.list.length) return msg.say('Could not find any results.');
const data = body.list[Math.floor(Math.random() * body.list.length)];
const data = body.list[type === 'top' ? 0 : Math.floor(Math.random() * body.list.length)];
const embed = new MessageEmbed()
.setColor(0x32A8F0)
.setAuthor('Urban Dictionary', 'https://i.imgur.com/Fo0nRTe.png')
+1
View File
@@ -9,6 +9,7 @@ module.exports = class BinaryCommand extends Command {
group: 'text-edit',
memberName: 'binary',
description: 'Converts text to binary.',
details: `**Modes**: ${modes.join(', ')}`,
args: [
{
key: 'mode',
-27
View File
@@ -1,27 +0,0 @@
const { Command } = require('discord.js-commando');
module.exports = class ReloadCommand extends Command {
constructor(client) {
super(client, {
name: 'reload',
group: 'util',
memberName: 'reload',
description: 'Reloads a command.',
details: 'Only the bot owner(s) may use this command.',
ownerOnly: true,
guarded: true,
args: [
{
key: 'command',
prompt: 'Which command would you like to reload?',
type: 'command'
}
]
});
}
run(msg, { command }) {
command.reload();
return msg.say(`Reloaded \`${command.name}\`.`);
}
};