No more cheerio, Color Command

This commit is contained in:
Daniel Odendahl Jr
2017-08-05 19:41:07 +00:00
parent 081bcfdeab
commit a41b475b50
3 changed files with 35 additions and 7 deletions
+31
View File
@@ -0,0 +1,31 @@
const Command = require('../../structures/Command');
const { createCanvas } = require('canvas');
module.exports = class ColorCommand extends Command {
constructor(client) {
super(client, {
name: 'color',
group: 'image-edit',
memberName: 'color',
description: 'Sends an image of the color you choose.',
clientPermissions: ['ATTACH_FILES'],
args: [
{
key: 'color',
prompt: 'What color do you want to view? This can be HTML (#colorcode) or a name.',
type: 'string',
parse: color => color.toLowerCase()
}
]
});
}
run(msg, args) {
const { color } = args;
const canvas = createCanvas(250, 250);
const ctx = canvas.getContext('2d');
ctx.fillStyle = color;
ctx.fillRect(0, 0, 250, 250);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'color.png' }] });
}
};
+3 -5
View File
@@ -1,6 +1,5 @@
const Command = require('../../structures/Command');
const snekfetch = require('snekfetch');
const cheerio = require('cheerio');
module.exports = class NeopetCommand extends Command {
constructor(client) {
@@ -28,9 +27,8 @@ module.exports = class NeopetCommand extends Command {
size: 5,
mood: 1
});
const $ = cheerio.load(text);
const link = $('textarea').first().text();
if (!link.includes('cp')) return msg.say('Invalid Pet Name.');
return msg.say(link);
const link = text.match(/http:\/\/pets\.neopets\.com\/cp\/.+\.png/);
if (!link) return msg.say('Invalid Pet Name.');
return msg.say(link[0]);
}
};
+1 -2
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "29.0.0",
"version": "29.1.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {
@@ -33,7 +33,6 @@
"dependencies": {
"bufferutil": "^3.0.2",
"canvas": "github:automattic/node-canvas",
"cheerio": "^1.0.0-rc.2",
"custom-translate": "github:dragonfire535/custom-translate",
"discord.js": "github:hydrabolt/discord.js",
"discord.js-commando": "github:gawdl3y/discord.js-commando",