diff --git a/commands/image-edit/color.js b/commands/image-edit/color.js new file mode 100644 index 00000000..4d2d628a --- /dev/null +++ b/commands/image-edit/color.js @@ -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' }] }); + } +}; diff --git a/commands/search/neopet.js b/commands/search/neopet.js index ebe6b57d..d6a1b6b7 100644 --- a/commands/search/neopet.js +++ b/commands/search/neopet.js @@ -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]); } }; diff --git a/package.json b/package.json index 19da95b0..76d7c0e4 100644 --- a/package.json +++ b/package.json @@ -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",