Files
xiao/commands/image-edit/color.js
T
Daniel Odendahl Jr 981f59b1b1 More Stoof
2017-10-13 17:33:29 +00:00

39 lines
896 B
JavaScript

const { Command } = require('discord.js-commando');
const { createCanvas } = require('canvas');
module.exports = class ColorCommand extends Command {
constructor(client) {
super(client, {
name: 'color',
aliases: ['colour'],
group: 'image-edit',
memberName: 'color',
description: 'Sends an image of the color you choose.',
throttling: {
usages: 1,
duration: 15
},
clientPermissions: ['ATTACH_FILES'],
args: [
{
key: 'color',
prompt: 'What color do you want to view? This can be #colorcode or a name.',
type: 'string',
parse: color => color.toLowerCase()
}
]
});
}
run(msg, { color }) {
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'
}] });
}
};